Game Script
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Game Script

Started by (!(Tys?kan)=), 17 April, 2004, 14:25:38

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

(!(Tys?kan)=)

Who can write game "Number's", for Example:

This number is within 0 and 100!
!n 5
5>Number
!n 3
3 !n 4
Congratulations, Nick1 you are WINNER!
Next number!


Ty
--Ty--

nErBoS

Hi,

Hope it helps...

--Requested by (!(Tys?kan)=)
--Made by nErBoS

sBot = "Number's Bot"

play = "off"
gNum = 0


function Main()
	frmHub:RegBot(sBot)
end

function DataArrival(user, data)
	if (strsub(data,1,1) == "<") then
		data = strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if (cmd == "!turn" and user.bOperator) then	--## Command to active the game ##--
			local s,e,opt = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (opt == nil) then
				user:SendData(sBot, "Syntax Error, !turn , you must write on or off.")
			elseif (strlower(opt) == "on") then
				if (play == "off") then
					play = "on"
					SendToAll(sBot, "The Number's Game as been Started.")
					SendToAll(sBot, "This number is within 0 and 100! ")
					SendToAll(sBot, "Use the command !n  to guess which number is.")
					gNum = random(1, 100)
				else
					user:SendData(sBot, "The Game is already in role.")
				end
			elseif (strlower(opt) == "off") then
				if (play == "on") then
					play = "off"
					SendToAll(sBot, "The Number's Game as Ended.")
					SendToAll(sBot, "To the one's that didn?t win, better luck in next time.")
				else
					user:SendData(sBot, "The Game is already stopped.")
				end
			end
			return 1
		elseif (cmd == "!n") then	--## Command to play ##--
			local s,e,num = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (num == nil or tonumber(num) == nil) then
				user:SendData(sBot, "Syntax Error, !n , you must write a number 0 - 100.")
			elseif (play == "off") then
				user:SendData(sBot, "The Game is stopped.")
			elseif (tonumber(num) == gNum) then
				SendToAll(sBot, "Congratulations, "..user.sName.." you are WINNER!")
				SendToAll(sBot, "Next number!")
				gNum = random(1, 100)
			else
				user:SendData(sBot, "Wrong number better luck next time.")
			end
			return 1
		end
	end
end

Best regards, nErBoS
--## nErBoS Spot ##--

(!(Tys?kan)=)

10x u very much!!! :D
--Ty--

[UC]Dennis

#3
hello people , this is my first post , and rightaway its an request  :))

Well i am doing Phatty's lua course now , but i had this numbergame introduced in my hub , but6 i want some mod's in it if possible.

I tried  but i messed up the script so bad , that i had to reinstal it  X(

But can the game be played , WITHOUTH typing !n before it each time ?

And Can u have an sentense like
65
Sorry user34 , that was too high  <--- send to all
12
Sorry user34 , that was too low  <--- send to all



I would be fully pleased .... :]  :]


P.S. can i translate the game to the dutch language ?

Corayzon

#4
here ya go (!(Tys?kan)=)

-- :: Some Game For (!(Tys?kan)=)

-- Editable Settings
sBot = "Some Bot"
sGameName = "Some Game"
cmdGameStart = "+startgame"
cmdGameEnd = "+endgame"
cmdGuess = "+guess"
msgGameStart1 = "*** #g been Started."
msgGameStart2 = "*** #g Picked a number between 0 and 100"
msgGameStart3 = "*** To have a crack at it, just type #cmd and your guess into the main chat"
msgGameStop = "*** #g has been stoped"	
msgGameStarted = "You have started #g"
msgGameStoped = "*** You have stoped #g"
msgGuessHigh = "Sorry #u, that was to high!"
msgGuessLow = "Sorry #u, that was to low!"
msgCorrect = "#u has guessed the magic number! :: #n"
iGameCount = 10

-- Non Editable
bPlaying, iNum, iCount = 0, 0, 0

function Main()
	frmHub:RegBot(sBot)
end

function DataArrival(tUser, sData)

	if strsub(sData, 1, 1) == "<" then

		sData = strsub(sData,1,strlen(sData)-1)
		local _,_, cmd = strfind(sData, "%b<>%s+(%S+)")
		cmd = strlower(cmd)

		if cmd == cmdGameStart and tUser.bOperator then

			bPlaying, iNum = 1, random(1, 100)
			tUser:SendData(sBot, translateString(msgGameStarted, "#g", sGameName))
			SendToAll(sBot, translateString(msgGameStart1, "#g", sGameName))
			SendToAll(sBot, translateString(msgGameStart2, "#g", sGameName))
			SendToAll(sBot, translateString(msgGameStart3, "#g", sGameName, "#cmd", cmdGuess))
			return 1

		elseif cmd == cmdEndGame and tUser.bOperator then

			bPlaying, iNum = 0, 0
			tUser:SendData(sBot, translateString(msgGameStoped, "#g", sGameName))
			return 1

		elseif cmd == cmdGuess then

			local _,_,sUsername, iGuess = strfind(sData, "<(%S+)>%s+%S+%s+(%S+)")
			iGuess = tonumber(iGuess) or nil
			if iGuess == nil then return end

			if iGuess == iNum then

				SendToAll(sBot, msgCorrect)
				iCount = iCount + 1

				if iCount > iGameCount then
					bPlaying, iNum = 0, 0
					SendToAll(sBot, translateString(msgGameStop, "#g", sGameName))
				else
					bPlaying, iNum = 1, random(1, 100)
					SendToAll(sBot, translateString(msgGameStart1, "#g", sGameName))
					SendToAll(sBot, translateString(msgGameStart2, "#g", sGameName))
					SendToAll(sBot, translateString(msgGameStart3, "#g", sGameName))
				end

			elseif iGuess >= iNum then
				SendToAll(sBot, translateString(msgGuessHigh, "#g", sGameName, "#u", sUsername))

			elseif iGuess <= iNum then
				SendToAll(sBot, translateString(msgGuessLow, "#g", sGameName, "#u", sUsername))
			end
		end
	end
end

function translateString(sString, s1, sr1, s2, sr2, s3, sr3)

	if s1 ~= nil then if strfind(sString, s1) then sString,_ = gsub(sString, s1, sr1 or "nothing") end end
	if s2 ~= nil then if strfind(sString, s2) then sString,_ = gsub(sString, s2, sr2 or "nothing") end end
	if s3 ~= nil then if strfind(sString, s3) then sString,_ = gsub(sString, s3, sr3 or "nothing") end end
	return sString
	
end

[UC]Dennis

yes thank you very very very much , but 1 thing
first i had to type !n to guess
now i have to type +guess to guess

QuoteBut can the game be played , WITHOUT typing !n before it each time ?

that way it will be more fun for the users  :]

nErBoS

Hi,

Here is it...

--Requested by (!(Tys?kan)=)
--Made by nErBoS

sBot = "Number's Bot"

play = "off"
gNum = 0


function Main()
	frmHub:RegBot(sBot)
end

function DataArrival(user, data)
	if (strsub(data,1,1) == "<") then
		data = strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if (cmd == "!turn" and user.bOperator) then	--## Command to active the game ##--
			local s,e,opt = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (opt == nil) then
				user:SendData(sBot, "Syntax Error, !turn , you must write on or off.")
			elseif (strlower(opt) == "on") then
				if (play == "off") then
					play = "on"
					SendToAll(sBot, "The Number's Game as been Started.")
					SendToAll(sBot, "This number is within 0 and 100! ")
					SendToAll(sBot, "Use the command !n  to guess which number is.")
					gNum = random(1, 100)
				else
					user:SendData(sBot, "The Game is already in role.")
				end
			elseif (strlower(opt) == "off") then
				if (play == "on") then
					play = "off"
					SendToAll(sBot, "The Number's Game as Ended.")
					SendToAll(sBot, "To the one's that didn?t win, better luck in next time.")
				else
					user:SendData(sBot, "The Game is already stopped.")
				end
			end
			return 1
		elseif (cmd == "+guess") then	--## Command to play ##--
			local s,e,num = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (num == nil or tonumber(num) == nil) then
				user:SendData(sBot, "Syntax Error, +guess , you must write a number 0 - 100.")
			elseif (play == "off") then
				user:SendData(sBot, "The Game is stopped.")
			elseif (tonumber(num) == gNum) then
				SendToAll(sBot, "Congratulations, "..user.sName.." you are WINNER!")
				SendToAll(sBot, "Next number!")
				gNum = random(1, 100)
			else
				user:SendData(sBot, "Wrong number better luck next time.")
			end
			return 1
		end
	end
end

Best regards, nErBoS
--## nErBoS Spot ##--

[UC]Dennis

thank you life saver , gunna try it right now

??????Hawk??????

#8
How About a Higher / Lower   Hint  .......


--Requested by (!(Tys?kan)=)
--Made by nErBoS
-- higher lower by ??????Hawk??????
sBot = "Number's Bot"

play = "off"
gNum = 0


function Main()
	frmHub:RegBot(sBot)
end

function DataArrival(user, data)
	if (strsub(data,1,1) == "<") then
		data = strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if (cmd == "+turn" and user.bOperator) then	--## Command to active the game ##--
			local s,e,opt = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (opt == nil) then
				user:SendData(sBot, "Syntax Error, !turn , you must write on or off.")
			elseif (strlower(opt) == "on") then
				if (play == "off") then
					play = "on"
					SendToAll(sBot, "The Number's Game as been Started.")
					SendToAll(sBot, "This number is within 0 and 100! ")
					SendToAll(sBot, "Use the command +guess  to guess which number is.")
					gNum = random(1, 100)
				else
					user:SendData(sBot, "The Game is already in role.")
				end
			elseif (strlower(opt) == "off") then
				if (play == "on") then
					play = "off"
					SendToAll(sBot, "The Number's Game as Ended.")
					SendToAll(sBot, "To the one's that didn?t win, better luck in next time.")
				else
					user:SendData(sBot, "The Game is already stopped.")
				end
			end
			return 1
		elseif (cmd == "+guess") then	--## Command to play ##--
			local s,e,num = strfind(data, "%b<>%s+%S+%s+(%S+)")
			if (num == nil or tonumber(num) == nil) then
				user:SendData(sBot, "Syntax Error, +guess , you must write a number 0 - 100.")
			elseif (play == "off") then
				user:SendData(sBot, "The Game is stopped.")
			elseif (tonumber(num) == gNum) then
				SendToAll(sBot, "Congratulations, "..user.sName.." you are WINNER!")
				SendToAll(sBot, "Next number!")
				gNum = random(1, 100)
			elseif (tonumber(num) < gNum) then
				SendToAll(sBot, "Higher!")
			elseif (tonumber(num) > gNum) then
				SendToAll(sBot, "Lower!")
			end
		end
	end
end

Corayzon

#9
QuoteOriginally posted by [UC]Dennis
yes thank you very very very much , but 1 thing
first i had to type !n to guess
now i have to type +guess to guess

QuoteBut can the game be played , WITHOUT typing !n before it each time ?

that way it will be more fun for the users  :]

um...if u look at the top of my script there is settings u can edit ;)

<< just change cmdguess to what u want the command to be ;) >>>

and for using it when no command prefix...i was tring to do this when i wrote it for ya...but the data in wouldnt arrive unless there was a + prefix for some reason :S

SMF spam blocked by CleanTalk