PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: XPMAN on 17 January, 2004, 17:42:26

Title: something simple
Post by: XPMAN on 17 January, 2004, 17:42:26
I have tried myself...(newbie).... I was needing a simple script with the +slap command.

for example  +slap

would like for it not appear in the userlist as a bot either.

No rush on this, just something i would like some help with. I know its in some of the packaged chat progies.

Title:
Post by: kepp on 18 January, 2004, 00:38:25
Bot = "Slapper"

function DataArrival(curUser, data)
   if strsub(data,1,1) == "<" then
   data=strsub(data,1,strlen(data)-1)
   s,e,cmd,arg = strfind(data,"%b<>%s+(%S+)%s+(.*)")
   
      if cmd=="+slap" then
         SendToAll(Bot, curUser.sName.." slaps "..arg.." with a fresh herring") return 1
       end
    end
end

Hope this help
Title: Perfect.......
Post by: XPMAN on 18 January, 2004, 01:23:21
Thnx....just what i was looking for.   :))
Title:
Post by: pHaTTy on 20 January, 2004, 11:01:47
dont forget you can use randomization as well ;)

Bot = "Slapper"

prefix = "!"
command = "slap"

function DataArrival(curUser, data)
if strsub(data,1,1) == "<" then
data=strsub(data,1,strlen(data)-1)
s,e,cmd,arg = strfind(data,"%b<>%s+(%S+)%s+(.*)")
   
if cmd == prefix..command then
local spin = random(4) --//how many will be random in spin
if spin == 1 then
SendToAll(Bot, curUser.sName.." slaps "..arg.." with a fresh herring") return 1
elseif spin == 2 then
SendToAll(Bot, curUser.sName.." slaps "..arg.." with a razar blade") return 1
elseif spin == 3 then
SendToAll(Bot, curUser.sName.." slaps "..arg.." with a strawberry jam jar :p") return 1
else
SendToAll(Bot, curUser.sName.." wips "..arg.." ass") return 1
end
end
end
end

Title:
Post by: pHaTTy on 20 January, 2004, 11:09:14
you also will want to do checks otherwise slapping will be unreal, youlll be only slappung text ;)

ie !slap him will say

phatty slapped him

so you need to check

Bot = "Slapper"

prefix = "+"
command = "slap"

function DataArrival(slapped, dstring)
if strsub(dstring,1,1) == "<" then
dstring=strsub(dstring,1,strlen(dstring)-1)
s,e,cmd,arg = strfind(dstring,"%b<>%s+(%S+)%s+(%S+)") --// no need to find more words after it
   
if cmd == prefix..command then
if arg == nil then
user:SendData(Bot,"Please enter nick of who you want to slap")

else
if GetItemByName(arg) then
local spin = random(4) --//how many will be random in spin
if spin == 1 then
SendToAll(Bot, slapped.sName.." slaps "..arg.." with a fresh herring") return 1
elseif spin == 2 then
SendToAll(Bot, slapped.sName.." slaps "..arg.." with a razar blade") return 1
elseif spin == 3 then
SendToAll(Bot, slapped.sName.." slaps "..arg.." with a strawberry jam jar :p") return 1
else
SendToAll(Bot, slapped.sName.." wips "..arg.." ass") return 1
end
else
user:SendData(Bot,"This user does not exist")
end
end
end
end
end

Title: Nice
Post by: XPMAN on 20 January, 2004, 17:37:50
Very nice indeed.........Thank u very much.