PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: night_hawk on 14 February, 2004, 15:53:20

Title: Need help with 2 scripts
Post by: night_hawk on 14 February, 2004, 15:53:20
Hi need to know how to use 2 scripts..I do not no there commands i tried 2 or 3 times and got nothing can someone help me please.....The scripts are Spinthebottle and Stab....I will Post the Scripts for someone the try it and let me know thank you......

 
Title: Stab
Post by: night_hawk on 14 February, 2004, 15:55:16
-------------------------------------------------------------------------------
-- Script         : stab
-- Date           : 4-4-2003 (started scripting version 0.001)
-- Version        : 0.003
-- Script Creator : klownietklowniet (for [SU]?Zeke's hub )
--                                   pm me if you find this script helpfull :-)
-------------------------------------------------------------------------------


BotName  = "Magic?"  -- also editable ;-)


--------------
--|Settings|--
--------------
owner="[UK]DT?"

-- Command first symbol
CS="!"-- leave empty for none like so: CS=""

-- user commands
CommandStab=CS.."stab"
CommandDeaths=CS.."kills"

-----------------
--|EndSettings|--
-----------------

deaths= {}

------------------------------------------------
--// This function is fired at the serving start
------------------------------------------------
function Main()
   frmHub:RegBot(BotName)
   SendToAll(BotName.." "..date(" launched at %B %d %Y %X "))
   deaths[owner]=0
end



---------------------------------------------------
--// This function is fired when new data arrives
---------------------------------------------------
function DataArrival(curUser,data)

   local MessageRecognized = 0
   pm=1
   if (isPM(data)==1) then
      whoto,from,message=ParsePM(data)
      MessageRecognized=1
      pm=1
   end
   if (isMCM(data)==1) then
      message=ParseMCM(data)
      from=curUser.sName
      whoto=BotName
      MessageRecognized=1
      pm=0
   end
   if ((MessageRecognized==1)and(whoto==BotName)) then
      r=HandleComand(curUser,message,pm)
      if (r==1) then
         return 1
      end
   end
end






------------------------------------------------------------------------------------------------------------
---------------------------------------------// Help Functions \\-------------------------------------------
------------------------------------------------------------------------------------------------------------



------------------------------------------------------------
--// Boolean function, true if message is from the main chat
------------------------------------------------------------
function isMCM(data)
   if( strsub(data, 1, 1) == "<" ) then
      return 1
   else
      return 0
   end
end


------------------------------------------------------------
--// Boolean function, true if message is a pm
------------------------------------------------------------
function isPM(data)
   if( strsub(data, 1, 3) == "$To" ) then
      return 1
   else
      return 0
   end
end


------------------------------------------------------------
--// This function parses the pm
------------------------------------------------------------
function ParsePM(data)
   s,e,whoTo,from,message = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.*)")
   --remove pipe
   message = strsub(message,1,strlen(message)-1)
   return whoTo,from,message
end


-------------------------------------------------------------
--// This function parses the message send from the main chat
-------------------------------------------------------------
function ParseMCM(data)
   s,e,message = strfind(data, "%b<> (.*)")
   --remove pipe
   message = strsub(message,1,strlen(message)-1)
   return message
end
Title: Stab rest of the script
Post by: night_hawk on 14 February, 2004, 15:56:00
-----------------------------------------------------------------------
--// This function check users message for command, trig, advertizement
-----------------------------------------------------------------------
function HandleComand(curUser,message,pm)
   command=GetCommand(message)
   
   if (command==CommandStab) then
      victim=GetOneParam(message)
      tempuser=GetItemByName(victim)
      if (curUser.sName==victim) then
         SendToAll( BotName, curUser.sName.." are you feeling suicidal??")
      elseif (victim==nil) then
         return 1
      elseif (tempuser==nil) then
         return 1
      else
         local kill=random(1,47)
         if kill == 1 then
            SendToAll( "* " .. curUser.sName .. " borrows Gackt's Magnum and shoots " .. victim .. " in the foot*")
         elseif kill == 2 then
            SendToAll( "* " .. curUser.sName.." find the famed silver toothpick on the ground, the uses it to poke holes into "..victim..", who then bleeds to death. Silver kills.*")
         elseif kill == 3 then
            SendToAll( "* "..curUser.sName.." brandishes the 'Fork of DOOM' and shoves it into "..victim.."'s leg, then tugs sharply upward to " ..victim.."'s chest and lets all the innards falls out* *plop*")
         elseif kill == 4 then
            SendToAll( "* "..curUser.sName.." slips a spatula into "..victim.."'s pants, then laughs*")
         elseif kill == 5 then
            SendToAll( "* "..curUser.sName.." places marbles gently into "..victim.."'s ears, then beats them in with a hammer until they are deep in "..victim.."'s skull*")
         elseif kill == 6 then
            SendToAll( "* "..curUser.sName.." fills "..victim.."'s mouth full of marshmellows until "..victim.." suffocates*")
         elseif kill == 7 then
            SendToAll( "* "..curUser.sName.." crams a can of Coke into "..victim.."'s nose. Yummy.*")
         elseif kill == 8 then
            SendToAll( "* "..curUser.sName.." places a rusty nail under "..victim.."'s foot. "..victim.." steps on the nail, and in a matter of minutes develops gangrene and dies*")
         elseif kill == 9 then
            SendToAll( "* "..curUser.sName.." sneakily takes out a box cutter, and gently slits "..victim.."'s throat*")
         elseif kill == 10 then
            SendToAll( "* "..curUser.sName.." combs "..victim.."'s scalp with a razor comb*")
         elseif kill == 11 then
            SendToAll( "* "..curUser.sName.." gets behind the wheel of a Volvo and back up over "..victim.."'s dog*")
         elseif kill == 12 then
            SendToAll( "* "..curUser.sName.." swings an axe, trying to hit "..victim..", but misses*")
         elseif kill == 13 then
            SendToAll( "* "..curUser.sName.." smacks "..victim.." with a fluffy pillow, and "..victim.." smacks back with a lead pan*")
         elseif kill == 14 then
            SendToAll( "* "..curUser.sName.." tosses "..victim.." into a pungee pit. The feces smeared onto the bamboo spikes then infects "..victim.."'s body and turns it into icky mush*")
         elseif kill == 15 then
            SendToAll( "* "..curUser.sName.." stabs "..victim.." with the blunt edge of a 'Happy Noodle Boy' action figure. Instant death!*")
         elseif kill == 16 then
            SendToAll( "* "..curUser.sName.." flings itching powder into "..victim.."'s eyes, and watches as "..victim.." digs their own eyes out*")
         elseif kill == 17 then
            SendToAll( "* "..curUser.sName.." fillets "..victim.."'s body with a pointy bucket. Two points!*")
         elseif kill == 18 then
            SendToAll( "* "..curUser.sName.." slays "..victim.." with a bag of poo*")
         elseif kill == 19 then
            SendToAll( "* "..curUser.sName.." stabs "..victim.." in the eye and "..victim.." howls in pain, clutching a bloody occular gash*")
         elseif kill == 20 then
            SendToAll( "* "..curUser.sName.." tucks "..victim.." into bed, kisses "..victim.." on the forehead, then begins to mechanically stab away with a kitchen knife*")
         elseif kill == 21 then
            SendToAll( "* "..curUser.sName.." calls over ".. owner..", and together they go and beat the bloody hell out of "..victim.." until only bloody pulp and mooshy things are left. Children run over and begin to play in "..victim.."'s remains*")
         elseif kill == 22 then
            SendToAll( "* "..curUser.sName.." splits "..victim.."'s kneecaps with a hammer and stake*")
         elseif kill == 23 then
            SendToAll( "* "..curUser.sName.." catches "..victim.." taking a library book, and then gives "..victim.." a fatal beating. You scoundrel!*")
         elseif kill == 24 then
            SendToAll( "* "..curUser.sName.." pours popcorn down "..victim.."'s throat, then puts "..victim.." on the stove. The popcorn heats up and explodes, ripping "..victim.." apart, and sending out a lovely blood covered treat for all the happy people of the hub*")
         elseif kill == 25 then
            SendToAll( "* "..curUser.sName.." goes into a malevolent fury and skins "..victim.." with a potato peeler*")
         elseif kill == 26 then
            SendToAll( "* "..curUser.sName.." decapitates "..victim..", then throws the head in a blender and makes pretty smoothies for everyone. Yay!*")
         elseif kill == 27 then
            SendToAll( "* "..curUser.sName.." licks "..victim.."'s skin off. With a power-sander. Grind-y...*")
         elseif kill == 28 then
            SendToAll( "* "..curUser.sName.." pinches "..victim..", and then "..victim.." licks "..curUser.sName.."'s cheek. It's love!")
         elseif kill == 29 then
            SendToAll( "* "..curUser.sName.." smacks "..victim.." with a chicken. Famer Lain comes out and shoves his pitchfork into "..curUser.sName.."'s backside for bothering his chickens.*")
         elseif kill == 30 then
            SendToAll( "* "..curUser.sName.." shoves a porcupine into "..victim.."'s pants, then beats the quills in with a small hammer*")
         elseif kill == 31 then
            SendToAll( "* "..curUser.sName.." stabs "..victim.." repeatedly with a toothpick*")
         elseif kill == 32 then
            SendToAll( "* "..curUser.sName.." pulls out a longsword and swings it at "..victim..", causing all of "..victim.."'s limbs to suddenly dissapear.*")
         elseif kill == 33 then
            SendToAll( "* "..curUser.sName.." sets loose a ferocious cat-girl on "..victim.." who maims "..victim.." completely to death*")
         elseif kill == 34 then
            SendToAll( "* "..curUser.sName.." sets loose a ferocious cat-girl on "..victim..", but the cat-girl leaps back and licks "..curUser.sName.." passionately*")
         elseif kill == 35 then
            SendToAll( "* "..curUser.sName.." pours boiling b33r into "..victim.."'s pants, as neither coffee nor tea should be wasted*")
         elseif kill == 36 then
            SendToAll( "* "..curUser.sName.." cannot decide if "..victim.." should be made into soup or into steaks, so "..victim.." is simply carved up with a spork and eaten, somehow. The best of both worlds...*")
         elseif kill == 37 then
            SendToAll( "* "..curUser.sName.." spins the bottle, which lands on "..victim..". "..curUser.sName.." takes a Magnum and pops a bullet into "..victim.."'s head. Everybody wins!*")
         elseif kill == 38 then
            SendToAll( "* "..curUser.sName.." stabs "..victim.." with a kookie crumb*")
         elseif kill == 39 then
            SendToAll( "* "..curUser.sName.." loads paintball gun with liquid nitrogen pellets... and shoots "..victim.." repeatedly until they are frozen, and then creams them with a hammer, shattering them into a million messy slivers*")
         elseif kill == 40 then
            SendToAll( "* "..curUser.sName.." carves up "..victim.."'s head with a flesching knife, then puts a large candle in it so that the eyes glow. Picking up the glowing skull, "..curUser.sName.." throws it at "..owner..", shattering bone and tendons in a blaze of flying skulls*")
         elseif kill == 41 then
            SendToAll( "* "..curUser.sName.." digs out "..victim.."'s throat with a fork, then eats it with some fava beans and a light chianti*")
         elseif kill == 42 then
            SendToAll( "* "..curUser.sName.." picks up Miiroku9 and uses his head as a battering ram to break down the gates of "..victim.."'s house, and then uses Miiroku9's bloody remains as a gag so that "..victim+ " suffocates*")
         elseif kill == 43 then
            SendToAll( "* "..curUser.sName.." sneaks a thin slice of fugu meat into "..victim.."'s lunch, and then waits 24 hours...*")
         elseif kill == 44 then
            SendToAll( "* "..curUser.sName.." jabs a long sharp pole into "..victim.."'s back, to the left of the spine, just below the shoulderblades. "..curUser.sName.." proceeds to jam the pole through "..victim.."'s  lungs, stomach, and various other internal organs, then starts to move it around... effectively tearing "..victim.."'s innards to shreds*")
         elseif kill == 45 then
            SendToAll( "* "..curUser.sName.." lobs a scimitar at "..victim.."'s head."..victim.." catches the scimitar and     becomes a self-proclaimed Emperor.*")
         elseif kill == 46 then
            SendToAll( "* "..curUser.sName.." throws a flesh eating banana-slug at "..victim.."'s head. "..victim.." runs around flailing and screaming '' Aaaah! Get it off me! Get it off me!'' Ironically, as soon as "..victim.." manages to peel the slug off, they run off a cliff and fall to a much more painful death on the sharp jagged rocks below.*")
         elseif kill == 47 then
            SendToAll( "* "..curUser.sName.." runs and jumps 15 feet in the air screaming ''Pink pencil brain impaler!!!'' before jamming a neon pink art pencil into "..victim.."'s eye and wiggling it around, thus making puree from their retarded synapses*")
         end
      end
      deaths[owner] = deaths[owner] + 1
      return 1
   elseif (command==CommandDeaths) then
      SendToAll( "* "..deaths[owner].." have been slaughtered! *")
      return 1
   end
end
 
------------------------------------------------------
--// This function parses the command given to the bot
------------------------------------------------------
function GetCommand(message)
s,e,command=strfind(message,"(%S+)")
return command
end


---------------------------------------------------------
--// This function returns the first parameter of message
---------------------------------------------------------
function GetOneParam(message)
   s,e,param1=strfind(message,"%S+%s(.+)")
   return param1
end

------------------------------------------------------------------------
Title: Spin the bottle
Post by: night_hawk on 14 February, 2004, 15:56:51
--
-- [BottleBot] - v0.451
--
-- Spin the bottle!
-- Written by bonki 2003
--
-- ABOUT:
-- Just an average SPIN THE BOTTLE game =)
--
-- CREDITS/THANKS:
-- Manic_Depresiv_Santa (I've taken the sentences from his VB-version)
-- RabidWombat (thanks to you mate :))
--
-- USED FILES (don't forget to create the "scripts/txt" folder!!!):
-- txt/BottleBot.template.txt (optional!): template file where you can change the sentences :)
--
-- [nick1] / [nick2] will be replaced with the users' nicks
-- [num1] / [num2] -||- [nickx]'s "number"
--
-- AVAILABLE COMMANDS:
-- Type !bb.help for further details.
--
-- TODO:
-- any suggestions?
--
-- BUGS/LIMITATIONS:
-- o) reconnecting may cause a user to be removed from the list only
-- o) only user who connect after the bot will be added to the list
--
-- CHANGELOG:
-- v0.451: Bugfix: Interval now in seconds, not milliseconds
-- v0.45: Optimized: code rewritten module-alike :)
-- v0.4: Added: !spinrandom{start/stop}
-- v0.31: Bugfix: fixed add/remove user bug
-- v0.3: Bugfix: fixed several bugs
-- v0.25: Optimized: replaced table algorithm (thx RabidWombat :)
-- v0.2: Added: added template file support
--


iInterval = 30; -- seconds

-- You may change sBotName but PLEASE leave the rest as it is, thx :-)

bot = { sBotName = "BottleBot",

sBotVer = "v0.451",

sBotEmail = "bonki@no-spam.net",

sBotSpeed = "Sol",

sBotDescr = "BottleBot - v0.451 - written by bonki 2003",

iBotShare = 0 };

sCrLf = "rn";

sOpHelpOutput = sCrLf..sCrLf.."OP Commands:"..sCrLf..sCrLf;

sHelpOutput = sCrLf.."Commands:"..sCrLf..sCrLf;

sBotInfo = ""

sTemplateFile = "txt/"..bot.sBotName..".template.txt";

tUsers = {};

s = {};

function Main()

frmHub:RegBot(bot.sBotName);

UpdateBotInfo();

ReadTemplate();

randomseed(clock());

tCommands = {

[ "!bb.help" ] = { CmdShowHelp, 0, "Display this help message" },

[ "!bb.spin" ] = { CmdSpin, 0, "Spin the bottle!" },

[ "!bb.startrandom" ] = { CmdSpinRandomStart, 1, "Start random spinning!" },

[ "!bb.stoprandom" ] = { CmdSpinRandomStop, 1, "Stop random spinning!" },

};

for sCmd, tCmd in tCommands do

if(tCmd[2] == 1) then

sOpHelpOutput = sOpHelpOutput..sCmd.."t: "..tCmd[3]..sCrLf;

else

sHelpOutput = sHelpOutput..sCmd.."tt: "..tCmd[3]..sCrLf;

end

end

end

-------------------------------------------------------------------------------

function CmdSpin(curUser)

local sUserName1, iUserNum1 = nil;

local sUserName2, iUserNum2 = nil;

repeat

iUserNum2, sUserName2 = tGetRandomUser(tUsers);

if (iUserNum2 == -1) then

if (curUser) then

SendToAll(bot.sBotName, "There's nobody to play with :("); end;

return;

end;

if (curUser) then

iUserNum1 = tGetUserIndex(tUsers, curUser);

sUserName1 = curUser.sName;

else

iUserNum1, sUserName1 = tGetRandomUser(tUsers);

end;

until (sUserName1 ~= sUserName2);

local iRndNum = random(getn(s));

local sSentence = s[iRndNum];

if (strfind(sSentence, "%[nick1%]")) then sSentence = gsub(sSentence, "%[nick1%]", sUserName1); end;

if (strfind(sSentence, "%[nick2%]")) then sSentence = gsub(sSentence, "%[nick2%]", sUserName2); end;

if (strfind(sSentence, "%[num1%]")) then sSentence = gsub(sSentence, "%[num1%]", iUserNum1); end;

if (strfind(sSentence, "%[num2%]")) then sSentence = gsub(sSentence, "%[num2%]", iUserNum2); end;

SendToAll(bot.sBotName, sSentence);

end

-------------------------------------------------------------------------------

function CmdSpinRandomStart()

SetTimer(iInterval * 1000);

StartTimer();

SendToAll(bot.sBotName, "Random spinning started!");

end

-------------------------------------------------------------------------------

function CmdSpinRandomStop()

StopTimer();

SendToAll(bot.sBotName, "Random spinning stopped!");

end

function CmdShowHelp(curUser)

curUser:SendData(bot.sBotName, sOpHelpOutput..sHelpOutput);

end

-------------------------------------------------------------------------------

function OnTimer()

CmdSpin();

end

-------------------------------------------------------------------------------

function DataArrival(curUser, sData)

local _, _, cmd, args = strfind(sData, "%b<>%s+(%S+)%s*([^%|]*)%|$");

if(cmd == nil) then

return 0; end

cmd = strlower(cmd);

if (tCommands[cmd]) then

curUser:SendData(sData);

if (tCommands[cmd][2] == 0 or curUser.bOperator) then

tCommands[cmd][1](curUser, args);

else

curUser:SendData(bot.sBotName, "You do not have sufficient rights to run that command!");

end

return 1;

end

end

-------------------------------------------------------------------------------

function OpConnected(curUser)

curUser:SendData(sBotInfo);

tAddUser(tUsers, curUser);

end

-------------------------------------------------------------------------------

function OpDisconnected(curUser)

tRemoveUser(tUsers, curUser);

end

-------------------------------------------------------------------------------

function NewUserConnected(curUser)

curUser:SendData(sBotInfo);

tAddUser(tUsers, curUser);

end

-------------------------------------------------------------------------------

function UserDisconnected(curUser)

tRemoveUser(tUsers, curUser);

end

-------------------------------------------------------------------------------

function UpdateBotInfo()

sBotInfo = "$MyINFO $ALL "..bot.sBotName.." "..bot.sBotDescr.."$ $"..bot.sBotSpeed..strchar(1).."$"..bot.sBotEmail.."$"..bot.iBotShare.."$" ;

end

-------------------------------------------------------------------------------

function ReadTemplate()

local flTemplateFile = openfile(sTemplateFile, "r");

if (flTemplateFile) then

local line = read(flTemplateFile);

while (line) do

tinsert(s, 1, line);

line = read(flTemplateFile);

end

closefile(flTemplateFile);

else

s = {

"< * The bottle lands on [num2] and [num2] faints at the site of [nick1] * >",

"< * [nick1] tackle huggles [nick2] and faits from all the excitement * >",

"< * [nick2] is kissed passionately by [nick1] * >",

"< * [nick2] and [nick1] giggle and run towards the closet holding hands * >",

"< * [nick2] picks up the bottle and breaks it on [nick1]'s head * >",

"< * [nick2] picks up and throws [nick1] across the room * >",

"< * [nick2] doesn't want to be kissed so gives [nick1] a cactus in place * >",

"< * [nick2] runs home crying * >",

"< * [nick2] *kneels*. If you wish to kiss me you have to ask my parents, [nick1]. * >",

"< * [nick2] and [nick1] interlock eyes and run towards eachother while the cellos play * >",

"< * [nick2] gets restraining order against [nick1] * >",

"< * [nick2] and [nick1] sitting in a tree, K I S S I N G... * >",

"< * This is the spin that doesnt end, yes it goes on and on my friend, some people started spinning me without knowing where I'd land. Now I'll continue spinning forever just because... * >",

"< * [nick1] spins the bottle and it lands on [nick1]. [nick1] goes and hides in the closet * >",

"< * The bottle lands on [num2]. [num2] then looks at [nick1]. Then stares at the bottle again. Eventually [num2] chooses the bottle over [nick1]. And they all live happily ever after! * >";

};

end

end

-------------------------------------------------------------------------------

function tGetUserIndex(tTable, uUser)

local iFind = tBinarySearch(tTable, uUser.sName);

if(iFind ~= -1) then

return -1;

else

return iFind;

end

end

-------------------------------------------------------------------------------

function tGetRandomUser(tTable)

local n = getn(tTable);

if (n < 2) then

return -1, nil;

else

local iRnd = random(n);

return iRnd, tTable[iRnd];

end

end

-------------------------------------------------------------------------------

function tAddUser(tTable, uUser)

local iFind, iInsert = tBinarySearch(tTable, uUser.sName);

if(iFind == -1) then

tinsert(tTable, iInsert, uUser.sName);

return 1;

else

return 0;

end;

end

-------------------------------------------------------------------------------

function tRemoveUser(tTable, uUser)

local iFind = tBinarySearch(tTable, uUser.sName);

if(iFind ~= -1) then

tremove(tTable, iFind);

return 1;

else

return 0;

end;

end

-------------------------------------------------------------------------------

function tBinarySearch(tTable, SearchVar)

assert(tTable and SearchVar);

local iBot, iMid, iTop = 1, nil, getn(tTable);

local CompVal = nil;

if(getn(tTable) == 0) then

return -1, 1; end;

while(iBot <= iTop) do

iMid = floor((iTop + iBot) / 2);

CompVal = tTable[iMid];

if(CompVal == nil) then

return -1, -1; end;

if(SearchVar < CompVal) then

iTop = iMid - 1;

elseif(SearchVar > CompVal) then

iBot = iMid + 1;

else

return iMid, -1;

end

end

if(SearchVar > CompVal) then

iMid = iMid + 1; end;

return -1, iMid;

end
Title:
Post by: plop on 15 February, 2004, 06:24:39
night_hawk can you edit your posts and disable the smilies and pref place the code between [ c o d e ] script here [ / c o d e ]
without the spaces offcourse. lol
thx.

plop
Title:
Post by: night_hawk on 15 February, 2004, 06:31:32
there you go hope you can help me with this my users really want this and i do not know how to make them work
Title: Help please
Post by: night_hawk on 16 February, 2004, 23:56:39
Hi i need help with theses sritps and how to make them work can someone plzzz......help me out
Title: hi all
Post by: night_hawk on 20 February, 2004, 03:01:28
is there anyone that can plz... help me with these two files please and thank you
Title: hi all
Post by: night_hawk on 20 February, 2004, 03:04:00
is there anyone that can plz... help me with these two files please and thank you
Title: hi all
Post by: night_hawk on 20 February, 2004, 03:06:32
is there anyone that can plz... help me with these two files please and thank you
Title: hi all
Post by: night_hawk on 20 February, 2004, 03:09:02
is there anyone that can plz... help me with these two files please and thank you