PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: EXNET OWNER on 17 June, 2004, 03:45:35

Title: EURO 2004 BOT - JUST NEED TO SEE IF I WROTE IT RIGHT?
Post by: EXNET OWNER on 17 June, 2004, 03:45:35
I worte a euro 2004 game in which there are two commands, !pass and !shoot. I think that I have written this correctly and just wanted someone to check it over. If you use it could you please PM me because it's my first script and I would like feedback, Thanks, Exile

                                  --Euro 2004 Bot by Exile--
--A little script for footy fans, it is my first one so tell me wot u think--

botName="Euro2004"

function Main()
sSek=60
frmHub:RegBot(botName)
OnOrOff="on"
SetTimer(1000*sSek)
A=0
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=="!pass") then
local Pass=random(1,7)
elseif (cmd=="!shoot") then
local Shoot=random(8,14)
 

if pass == 1 then
SendToAll(botName, " "..user.sName.. ", was that a pass or a shot on goal? Either way it woz shit, it went off... ")

elseif pass == 2 then
SendToAll(botName, " "..user.sName.. ", I really don't think you get the idea of this game...")
SendPmToNick(user.sName, botName, "I think that you should go to footy school...I could giv you a number of a really good coach, lol")

elseif pass == 3 then
SendToAll(botName, "YO"..user.sName..", A PASS IS WITH YOUR FEET, NOT KICKING SOMEONE IN THE HEAD!!! RED CARD")
StopTimer()
A = 0
OnOrOff="off"
user:Disconnect()

elseif pass ==4 then
A = 0
SendToAll(botName, ""..user.sName..", That woz a wicked pass, straight through the middle, well done son carry on woth a shot")

elseif pass ==5 then
A = 0
SendToAll(botName, "Good one "..user.sName..".")

elseif pass == 6 then
A = 0
SendToAll(botName, "Keep your eye on the ball" ..user.sName.." !")

elseif pass == 7 then
A = 0
SendToAll(botName, "Nice one " ..user.sName..", we all knew footy camp would pay off!")

elseif shoot == 8 then
A = 0
SendToAll (botName, "GOAL!!! " ..user.sName.." scored the winning goal!")

elseif shoot == 9 then
SendToAll(botName, " "..user.sName.. ", I really don't think you get the idea of this game...")
SendPmToNick(user.sName, botName, "I think that you should go to footy school...I could giv you a number of a really good coach, lol")

elseif shoot == 10 then
SendToAll(botName, "YO"..user.sName..", WHEN YOU TAKE A SHOT HIT THE BALL NOT THE GOAL KEEPERS NOSE, RED CARD!!!")  
user:Disconnect()

elseif shoot == 11 then
A = 0
SendToAll(botName, ""..user.sName..", shoots!!!...He Misses *holds head in hands*. Bad Luck")

elseif shoot == 12 then
A = 0
SendToAll(botName, "It's close! It's close! It's in!!! "..user.sName.." scores a brilliant goal!!!.")

elseif pass == 13 then
A = 0
SendToAll(botName, "He goes to shoot.....His boot fly's off and smacks his mum in the nose...bad luck " ..user.sName.." !")

elseif pass == 14 then
A = 0
SendToAll(botName, "BRILLIANT GOAL!!! " ..user.sName.." put one right in the top corner. He's on form today.")
end
end
end
if(strsub(data, 1, 4) == "$To:") then

data=strsub(data,1,strlen(data)-1)

s,e,whoTo = strfind(data,"$To:%s+(%S+)")

--SendToAll(botName, ""..data.."")

if (whoTo == botName) then

s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")

--s,e,cmd = strfind( data, "%b<>%s+(%S+)" )

--SendToAll(botName, ""..cmd.."")

if (cmd=="!euro") and (OnOrOff=="off") then

OnOrOff="on"

StartTimer()

SendToAll(botName, "Euro 2004 has started, type !eurohelp to find out rules")

elseif (cmd=="!euroend") and (OnOrOff=="on") then

OnOrOff="off"

SendToAll(botName, "All the teams decided to leave the competition, they needed a beer")

elseif (cmd=="!eurohelp") then

SendPmToNick(user.sName, botName, "Euro 2004 Help")

SendPmToNick(user.sName, botName, "To play you must first make at least 1 pass. If the message you recieve says 'SHOOT' at the end you may take a shot, if it doesn't, give another player a try")

SendPmToNick(user.sName, botName, "To start a game PM Euro2004 --> !euro")

SendPmToNick(user.sName, botName, "To stop the game PM Euro2004 --> !euroend")

SendPmToNick(user.sName, botName, "Pass the ball --> !pass")

SendPmToNick(user.sName, botName, "Shoot --> !shoot")
end

end

end

end



function OnTimer()

A=A+1

check()

end



function check()

if A==sSek then

A=0

OnOrOff="off"

SendToAll(botName, "Need to refresh for tomorrows match

StopTimer()

end

end
Title:
Post by: pHaTTy on 17 June, 2004, 11:05:51
dont forget to use the forum tags [c o d e] [/c o d e]


you had 1 end in wrong place ;-)

--Euro 2004 Bot by Exile--
--A little script for footy fans, it is my first one so tell me wot u think--

botName = "Euro2004"

function Main()
sSek=60
frmHub:RegBot(botName)
OnOrOff="on"
SetTimer(1000*sSek)
A=0
end

function DataArrival(user, data)
if( strsub(data, 1, 1) == "<" ) then
data=strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind( data, "%b<>%s+(%S+)" )

if (cmd=="!pass") then
local Pass=random(1,7)
elseif (cmd=="!shoot") then
local Shoot=random(8,14)

end; -- // You missed this end;

if pass == 1 then
SendToAll(botName, " "..user.sName.. ", was that a pass or a shot on goal? Either way it woz shit, it went off... ")

elseif pass == 2 then
SendToAll(botName, " "..user.sName.. ", I really don't think you get the idea of this game...")
SendPmToNick(user.sName, botName, "I think that you should go to footy school...I could giv you a number of a really good coach, lol")

elseif pass == 3 then
SendToAll(botName, "YO"..user.sName..", A PASS IS WITH YOUR FEET, NOT KICKING SOMEONE IN THE HEAD!!! RED CARD")
StopTimer()
A = 0
OnOrOff="off"
user:Disconnect()

elseif pass ==4 then
A = 0
SendToAll(botName, ""..user.sName..", That woz a wicked pass, straight through the middle, well done son carry on woth a shot")

elseif pass ==5 then
A = 0
SendToAll(botName, "Good one "..user.sName..".")

elseif pass == 6 then
A = 0
SendToAll(botName, "Keep your eye on the ball" ..user.sName.." !")
elseif pass == 7 then
A = 0
SendToAll(botName, "Nice one " ..user.sName..", we all knew footy camp would pay off!")

elseif shoot == 8 then
A = 0
SendToAll (botName, "GOAL!!! " ..user.sName.." scored the winning goal!")

elseif shoot == 9 then
SendToAll(botName, " "..user.sName.. ", I really don't think you get the idea of this game...")
SendPmToNick(user.sName, botName, "I think that you should go to footy school...I could giv you a number of a really good coach, lol")

elseif shoot == 10 then
SendToAll(botName, "YO"..user.sName..", WHEN YOU TAKE A SHOT HIT THE BALL NOT THE GOAL KEEPERS NOSE, RED CARD!!!")
user:Disconnect()
elseif shoot == 11 then
A = 0
SendToAll(botName, ""..user.sName..", shoots!!!...He Misses *holds head in hands*. Bad Luck")

elseif shoot == 12 then
A = 0
SendToAll(botName, "It's close! It's close! It's in!!! "..user.sName.." scores a brilliant goal!!!.")

elseif pass == 13 then
A = 0
SendToAll(botName, "He goes to shoot.....His boot fly's off and smacks his mum in the nose...bad luck " ..user.sName.." !")

elseif pass == 14 then
A = 0
SendToAll(botName, "BRILLIANT GOAL!!! " ..user.sName.." put one right in the top corner. He's on form today.")
end;
end;
--// you had added the end here, a common mistake;

if(strsub(data, 1, 4) == "$To:") then
data=strsub(data,1,strlen(data)-1)
local s,e,whoTo = strfind(data,"$To:%s+(%S+)")

if (whoTo == botName) then
local s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")
if (cmd=="!euro") and (OnOrOff=="off") then
OnOrOff="on"
StartTimer()
SendToAll(botName, "Euro 2004 has started, type !eurohelp to find out rules")
elseif (cmd=="!euroend") and (OnOrOff=="on") then
OnOrOff="off"
SendToAll(botName, "All the teams decided to leave the competition, they needed a beer")
elseif (cmd=="!eurohelp") then
SendPmToNick(user.sName, botName, "Euro 2004 Help")
SendPmToNick(user.sName, botName, "To play you must first make at least 1 pass. If the message you recieve says 'SHOOT' at the end you may take a shot, if it doesn't, give another player a try")
SendPmToNick(user.sName, botName, "To start a game PM Euro2004 --> !euro")
SendPmToNick(user.sName, botName, "To stop the game PM Euro2004 --> !euroend")
SendPmToNick(user.sName, botName, "Pass the ball --> !pass")
SendPmToNick(user.sName, botName, "Shoot --> !shoot")
end;
end;
end;
end;



function OnTimer()
A=A+1
check()
end


function check()
if A==sSek then
A=0
OnOrOff="off"
SendToAll(botName, "Need to refresh for tomorrows match
StopTimer()
end;
end;
Title:
Post by: Troubadour on 17 June, 2004, 23:37:20
next error will be this line


function check()
   if A==sSek then
      A=0
      OnOrOff="off"
      SendToAll(botName, "Need to refresh for tomorrows match
      StopTimer()
   end;
end;

it should be


function check()
   if A==sSek then
      A=0
      OnOrOff="off"
      SendToAll(botName, "Need to refresh for tomorrows match ")
      StopTimer()
   end;
end;

Regards,
Troubadour
Title:
Post by: pHaTTy on 18 June, 2004, 02:11:13
QuoteOriginally posted by Troubadour
next error will be this line


function check()
   if A==sSek then
      A=0
      OnOrOff="off"
      SendToAll(botName, "Need to refresh for tomorrows match
      StopTimer()
   end;
end;

it should be


function check()
   if A==sSek then
      A=0
      OnOrOff="off"
      SendToAll(botName, "Need to refresh for tomorrows match ")
      StopTimer()
   end;
end;

Regards,
Troubadour

well spotted
Title:
Post by: Troubadour on 24 June, 2004, 21:45:45
thnks