Well, i have put prints behind each function, so as they execute in the server i can follow the routes that the calls are being executed, but it seems as though lua is just not writing to the same table, or.... it's just not writing anything at all.
Here is the code in it's entirety (i know the structure is probably shiet : ) ):
Code: Select all
--[[ ZeN mod - by Feengur ]]--
zen_mod=0.5
pos= {}
apos={}
xpos={}
sd = {}
wd = {}
gd = {}
--[[ MISC CLIENT FUNCTIONS ]]--
function et_ClientConnect( clientNum, firstTime, isBot)
pos[clientNum] = nil
apos[clientNum] = nil
xpos[clientNum] = nil
sd[clientNum] = false
wd[clientNum] = false
gd[clientNum] = false
end
function et_ClientDisonnect(clientNum)
pos[clientNum] = nil
apos[clientNum] = nil
xpos[clientNum] = nil
sd[clientNum] = false
wd[clientNum] = false
gd[clientNum] = false
end
function getTeam(playerID)
return et.gentity_get(playerID, "sess.sessionTeam")
end
--[[ END ]]--
--[[ SERVER COMMAND INTERCEPTION ]]--
function et_ClientCommand(clientNum,command)
if command=="save" then
scheck(clientNum)
return 1
end
if command=="load" then
lcheck(clientNum)
return 1
end
if command=="donotfollow" then
donotfollow(clientNum)
return 1
end
if command=="notwanted" then
notwanted(clientNum)
return 1
end
return 0
end
function et_ConsoleCommand()
if et.trap_Argv(0)=="goto" then
gcheck(et.trap_Argv(1), et.trap_Argv(2))
return 1
end
if et.trap_Argv(0)=="iwant" then
wcheck(et.trap_Argv(1), et.trap_Argv(2))
return 1
end
if et.trap_Argv(0)=="sdisable" then
sdisable(et.trap_Argv(1), et.trap_Argv(2))
return 1
end
if et.trap_Argv(0)=="senable" then
senable(et.trap_Argv(1), et.trap_Argv(2))
return 1
end
if et.trap_Argv(0)=="rmsaves" then
rmsaves(et.trap_Argv(1), et.trap_Argv(2))
return 1
end
return 0
end
--[[ END ]]--
--[[ COMMAND AVAILABILITY CHECKS ]]--
function speccheck(playerID)
if getTeam(playerID) == 3 then
et.trap_SendServerCommand(playerID, "cpm \"^7|^1Z^7e^1N^7| ^7Not while spec!\"" )
return false
elseif getTeam(playerID) ~= 3 then
return true
end
end
function scheck(playerID)
if sd[playerID] then
et.trap_SendServerCommand(playerID, "cpm \"^7|^1Z^7e^1N^7| ^7You are not allowed to save at this time\"" )
return
else
save(playerID,getTeam(playerID))
return 1
end
end
function lcheck(playerID)
if sd[playerID] then
et.trap_SendServerCommand(playerID, "cpm \"^7|^1Z^7e^1N^7| ^7You are not allowed to load at this time\"" )
return
else
load(playerID,getTeam(playerID))
return 1
end
end
function gcheck(playerID, clientID)
if gd[clientID] then
et.trap_SendServerCommand(playerID, "cpm \"^7|^1Z^7e^1N^7| ^7The player does not wish to be followed\"" )
return
else
goto(playerID, clientID)
return 1
end
end
function wcheck(playerID, clientID)
if wd[clientID] then
et.trap_SendServerCommand(playerID, "cpm \"^7|^1Z^7e^1N^7| ^7The player does not wish to be followed\"" )
return
else
iwant(playerID, clientID)
return 1
end
end
--[[ END ]]--
--[[ COMMANDS BEGIN ]]--
function save(playerID,teamID)
if teamID == 1 then
apos[playerID] = et.gentity_get(playerID, "origin")
et.trap_SendServerCommand(playerID, "cpm \"^7|^1Z^7e^1N^7| ^7Position - ^1saved\"" )
elseif teamID == 2 then
xpos[playerID] = et.gentity_get(playerID, "origin")
et.trap_SendServerCommand(playerID, "cpm \"^7|^1Z^7e^1N^7| ^7Position - ^1saved\"" )
end
return 1
end
function load(playerID,teamID)
if teamID == 1 then
et.gentity_set(playerID, "origin", apos[playerID])
et.trap_SendServerCommand(playerID, "cpm \"^7|^1Z^7e^1N^7| ^7Position - ^1loaded\"" )
elseif teamID == 2 then
et.gentity_set(playerID, "origin", xpos[playerID])
et.trap_SendServerCommand(playerID, "cpm \"^7|^1Z^7e^1N^7| ^7Position - ^1loaded\"" )
end
return 1
end
function iwant(playerID,clientID)
pos[clientID] = et.gentity_get(clientID, "origin")
et.gentity_set(clientID, "origin", et.gentity_get(playerID, "origin"))
et.trap_SendServerCommand(playerID, "cpm \"^7|^1Z^7e^1N^7| ^7Your previous postion has been saved. Use ^1!^7goback to return\"" )
end
function goto(playerID,clientID)
et.gentity_set(playerID, "origin", et.gentity_get(clientID, "origin"))
end
function gotohell(playerID,clientID)
et.gentity_set(clientID, "health", -200)
et.trap_SendServerCommand(playerID, "cpm \"^7|^1Z^7e^1N^7| ^7LoL~1!\"" )
et.trap_SendServerCommand(clientID, "cpm \"^7|^1Z^7e^1N^7| ^7Die~1!!!!\"" )
end
function goback(playerID)
et.gentity_set(playerID, "origin", pos[clientID])
pos[clientID] = nil
et.trap_SendServerCommand(playerID, "cpm \"^7|^1Z^7e^1N^7| ^7Previous position restored\"" )
end
function rmsaves(playerID,clientID)
apos[clientNum] = nil
xpos[clientNum] = nil
et.trap_SendServerCommand(playerID, "cpm \"^7|^1Z^7e^1N^7| ^7Saved positions have been removed from the player\"" )
et.trap_SendServerCommand(clientID, "cpm \"^7|^1Z^7e^1N^7| ^7Your saved positions have been removed\"" )
end
function sdisable(playerID,clientID)
sd[clientID] = true
et.trap_SendServerCommand(playerID, "cpm \"^7|^1Z^7e^1N^7| ^7Player commands revoked\"" )
et.trap_SendServerCommand(clientID, "cpm \"^7|^1Z^7e^1N^7| ^7Your ability to ^1save^7/^1load^7 has been revoked\"" )
end
function senable(playerID,clientID)
sd[clientID] = false
et.trap_SendServerCommand(playerID, "cpm \"^7|^1Z^7e^1N^7| ^7Player commands restored\"" )
et.trap_SendServerCommand(clientID, "cpm \"^7|^1Z^7e^1N^7| ^7Your ability to ^1save^7/^1load^7 has been restored\"" )
end
function donotfollow(playerID)
if gd[playerID] == false then
gd[playerID] = true
et.trap_SendServerCommand(playerID, "cpm \"^7|^1Z^7e^1N^7| ^7!goto's : ^1disabled\"" )
elseif gd[playerID] == true then
gd[playerID] = false
et.trap_SendServerCommand(playerID, "cpm \"^7|^1Z^7e^1N^7| ^7!goto's : ^1enabled\"" )
end
end
function notwanted(playerID)
if wd[playerID] == false then
wd[playerID] = true
et.trap_SendServerCommand(playerID, "cpm \"^7|^1Z^7e^1N^7| ^7!iwant's : ^1disabled\"" )
elseif wd[playerID] == true then
wd[playerID] = false
et.trap_SendServerCommand(playerID, "cpm \"^7|^1Z^7e^1N^7| ^7!iwant's : ^1enabled\"" )
end
end
--[[ END ]]--
The command rmsaves is what i'm concerned about above anything else, but i think it has more to do with the fact that my variables aren't acting properly. My checks before the functions are working properly as far as the prints go, so I know that the code is following through as it should... but like I said, my variables aren't returning the values that they should.
I'm thinking now that since I am unfarmiliar with vars in lua that my declaration is incorrect? Maybe the global variables declared up top should be declared as global, or is this automatic? And since they are all tables, do I need to declare indexes for the tables as well? i.e
Code: Select all
global pos[1 to 100] = {}
I've read the lua reference, but it seems to be very vague on this subject. Thanks for the help!
-Feengur