Nachz
-
Posts
8 -
Joined
-
Last visited
-
Days Won
1
Reputation Activity
-
Nachz got a reaction from Zelly in Need help with a lua script.
Thanks for the cvar, I really forgot this one.
Also I'm working on something else and the lua module don't want to load so I guess there is a problem with one of these function:
function et_Obituary(victim,killer,meansOfDeath) getkiller(victim,killer) end function getkiller(victimID,killerID) local hpkiller = et.gentity_get(killerID,"ps.stats",0) local name = et.gentity_get(killerID,"pers.netname") et.trap_SendServerCommand(victimID,"chat \"^7 "..name.." was at ^1"..hpkiller.." ^7HP when he killed you !\"") -- et.trap_SendConsoleCommand( et.EXEC_APPEND, "readconfig\n" ) -- Pretty sure you don't need readconfig in this situation end end Thanks !
Edit: Right after I posted the code I saw my error ^^ Fixed.
-
Nachz got a reaction from Zelly in Need help with a lua script.
The new getXP fonction you gave me, works pretty well.
And I added this to my setskills function:
local gamestate = tonumber( et.trap_Cvar_Get('gamestate') ) if gamestate == 0 then 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) And the good gamestate number was 0, because 1 is for warmup and 0 is for when the game is started.
Thanks a lot, my problem is fixed !
-
Nachz reacted to Zelly in Need help with a lua script.
Hmm... to fix warmup xp gain is pretty simple just check gamestate I always forget the correct number though.
I think it is this:
local gamestate = tonumber( et.trap_Cvar_Get('gamestate') ) if gamestate == 1 then -- do xp stuff here. end So are you saying it gives xp to players that have more than 1000 xp every spawn? or Just once.If it is just once then I assume it is related to a small bug, where xp from lua is 0 until at least one xp is gained: http://mygamingtalk.com/forums/topic/3346-lua-get-xp-value/
I would have to do some more testing my self again to verify a good method to get xp in lua, I forget which method I normally use.
Try this:
(Disclaimer this is off the top of my head not sure if this is right)
function getXP(clientNum) local xp = 0 for k=0, 6 do xp = xp + tonumber(et.gentity_get(clientNum,"sess.skillpoints",k)) end return xp end Hope that helps, I didn't do any fact checking. -
Nachz got a reaction from Zelly in Need help with a lua script.
Thanks for the fast answer, I will try it
Edit: It worked, thanks you
Also to you know how to force the client to downlaod a .pk3 files in the etmain folder. The sv_pure only force the client to download pk3 files in the silent folder.
Thanks you again
-
Nachz reacted to gaoesa in Need help with a lua script.
Also, you can get the 8 character id from the sess.guid with substring
string.sub(s, i [, j]) http://lua-users.org/wiki/StringLibraryTutorial. The last 8 characters of the sess.guid is the silent id for the command.
-
Nachz reacted to Zelly in Need help with a lua script.
I am curious if all your trying to accomplish is to have players start with all skills then I think it would be easier to just set the skill levels to 0.
http://mygamingtalk.com/wiki/Silent_Mod_Server_Cvar#skill_soldier
You then wouldn't need to bother with lua, everyone that joined would automatically have the skill levels.
In your server config:
set skill_soldier "0 0 0 0" set skill_medic "0 0 0 0" set skill_engineer "0 0 0 0" set skill_fieldops "0 0 0 0" set skill_covertops "0 0 0 0" set skill_battlesense "0 0 0 0" set skill_lightweapons "0 0 0 0" However if you wanted to do this for some newer players that like receiving xp.You are trying to concatenate a string into where you are supposed to be supplying an integer(the client number)
Try this:
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" ) -- Pretty sure you don't need readconfig in this situation end Also you are sending your congratulations message to everyone that is connected. Not sure if this is intended or not, if not replace -1 with playerID
Hope that helps, btw if you can check your console log around the time the map is getting loaded it will show if there are any errors when loading your lua. They are usually pretty useful when trying to pinpoint what is wrong.
-
Nachz got a reaction from Zelly in Need help with a lua script.
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