Hi all, I'm working on a lua script that would give xp to new player under 1000xp. So they would have all skills. But I can't make it done... I tried 2 ways and both didn't worked well. My lua is based on a other script between. So I have been using this code for when the player spawn:
function et_ClientSpawn(clientNum, revived, teamChange, restoreHealth)
local valXP = getXP(clientNum)
if valXP < noexp then
setexp(clientNum)
end
end
The value of noexp is 1000. This is the first thing I tried (fonction setexp):
function setexp(playerID)
local name = et.gentity_get(playerID,"pers.netname")
local silentguid = et.gentity_get(playerID,"sess.guid")
if isBot(playerID) or noGuid(playerID) then return end
et.trap_SendServerCommand(-1,"chat \"^nCongratulations ^7"..name.."^n, ^nyou have ^nbeen ^nEXP! \"")
et.trap_SendConsoleCommand( et.EXEC_APPEND, "givexp "..silentguid.." SOLD 500 \n" )
et.trap_SendConsoleCommand( et.EXEC_APPEND, "givexp "..silentguid.." MED 500 \n" )
et.trap_SendConsoleCommand( et.EXEC_APPEND, "givexp "..silentguid.." ENG 500 \n" )
et.trap_SendConsoleCommand( et.EXEC_APPEND, "givexp "..silentguid.." FOPS 500 \n" )
et.trap_SendConsoleCommand( et.EXEC_APPEND, "givexp "..silentguid.." COV 500 \n" )
et.trap_SendConsoleCommand( et.EXEC_APPEND, "givexp "..silentguid.." LIGHT 500 \n" )
et.trap_SendConsoleCommand( et.EXEC_APPEND, "givexp "..silentguid.." BATTLE 500 \n" )
et.trap_SendConsoleCommand( et.EXEC_APPEND, "readconfig\n" )
end
But I realized that the command givexp use the silent ID when I'm using the Silent GUID because I didn't find any function that allow to get the silent ID. Maybe something that would only take the 8 last characters of the silent GUID could give the Silent ID, but I don't know how. (So I didn't got xp, I only seen the message) so then I tried this using the G_AddSkillPoints...
function setskill(playerID)
local name = et.gentity_get(playerID,"pers.netname")
if isBot(playerID) or noGuid(playerID) then return end
et.G_AddSkillPoints("..playerID..", 0, 500)
et.G_AddSkillPoints("..playerID..", 1, 500)
et.G_AddSkillPoints("..playerID..", 2, 500)
et.G_AddSkillPoints("..playerID..", 3, 500)
et.G_AddSkillPoints("..playerID..", 4, 500)
et.G_AddSkillPoints("..playerID..", 5, 500)
et.G_AddSkillPoints("..playerID..", 6, 500)
et.G_AddSkillPoints("..playerID..", 1, 500)
et.trap_SendServerCommand(-1,"chat \"^nCongratulations ^7"..name.."^n, ^nyou have ^nbeen ^nEXP! Welcome to MC ! \"")
et.trap_SendConsoleCommand( et.EXEC_APPEND, "readconfig\n" )
end
I think there are something missing, because the lua can get load when I type "/lua_status" I can see it. Thanks for you help Nachz