PtokaX forum

Development Section => Your Developing Problems => Topic started by: Madman on 13 December, 2004, 18:16:44

Title: Nicks In Table - Help
Post by: Madman on 13 December, 2004, 18:16:44
JointUserTable = {}
JointUsers = 0
Bot = "FunScript"

function DataArrival(curUser,data)
if strsub(data, 1, 1) == "<" then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
-------------------------------Ask For Joint And For Joint(curUser)
--==NewCommand==--
if cmd == "!askj" then
SendToAll(Bot, curUser.sName.. " asks if someone gould give him/her a joint")
Joint(curUser)
JointUsers = 1
return 1
end
-------------------------------
--==NewVictimCommand==--
if cmd == "!givej" then
local s,e,victim = strfind(data, "%b<>%s+%S+%s+(%S+)")
if victim == nil then
curUser:SendData(Bot, "Syntax: "..cmd.." nick")
return 1
end
vUser = GetItemByName(victim)
if not vUser then
curUser:SendData(Bot, " *** " ..victim.." is not online or wrong name...")
return 1
end
if JointUsers==1 then
local s,e,JointUserVic = strfind(data, "%b<>%s+%S+%s+(%S+)")
if JointUserTable[Jointed.sName] == 1 then
JointUserTable[Jointed.sName] = nil; --//Remove User From Table
SendToAll(Bot, curUser.sName.." passes the joint to " ..Jointed.sName.." 1")
elseif JointUserTable[Jointed.sName] == nil then
JointUser = GetItemByName(JointUserVic)
SendToAll(Bot, curUser.sName.." passes the joint to " ..JointUser.sName.." 3")
end
elseif JointUsers==0 then
vUser = GetItemByName(victim)
SendToAll(Bot, curUser.sName.." passes the joint to "..vUser.sName.." 2")
end
return 1
end
-------------------------------Show Jointed Users Table
if cmd == "!showj" then ShowJointed(curUser) return 1 end
-------------------------------
end
end

function ShowJointed(curUser)
local names = ""
for index, value in JointUserTable do
local line = index
names = names.." "..line.."\r\n"
end
curUser:SendData(Bot,"\r\n\r\nJointUser User..\r\n\r\n"..names)
end
-------------------------------Save Users In Table
function Joint(curUser)
Jointed = GetItemByName(curUser.sName) --//Jointed Is CurUser
if JointUserTable[Jointed.sName] == nil then --//If Not User Is In Table
JointUserTable[Jointed.sName] = 1 --//Then Add User
end
end

Need some help here...

Users = A,B,C,D

A uses cmd !askj and get added to JointUserTable
B uses cmd !askj to, and gets added to

C tries to give D a joint
--But beacue of table
C gives B a joint
--B is removed from table
--A is still in Table
--D is ignored

C tries to give D a joint again
--And Here is the problem!
C gives D a joint
--A is ignored and remains in table

It Should be
C tries to give D a joint again
--But becuse of table
C gives A a joint
--A is removed from table
--D is ignored

Why does the table only give B a joint?
I have checked A is in the table
What do i need to do, to make the script understand that it is more nicks in the table?
Title:
Post by: Madman on 14 December, 2004, 09:10:49
Can somebody please help?
Title:
Post by: bastya_elvtars on 14 December, 2004, 12:16:54
function Joint(curUser)
if not JointUserTable[curUser.sName] then --//If Not User Is In Table

JointUserTable[curUser.sName] = 1 --//Then Add User

end

end

do not overcomplicate a script. Will have more time evening, then ill check.