lua .. /resetxp
Moderators: Forum moderators, developers
lua .. /resetxp
hello, I'm making a bunch of client commands and one of them is /resetxp for people who wish to reset their xp every map or every while..
I don't seem to be able to find the variable for it, any suggestions?
I don't seem to be able to find the variable for it, any suggestions?
Some similar posts:
http://bani.anime.net/banimod/forums/vi ... php?t=6723
http://bani.anime.net/banimod/forums/vi ... php?t=6770
You can read xp from either of those, but you can't set it.
If its any help to you, you can access upgrades with sess.skill.
where "k" is an integer:
0 = battlesense
1 = engineering
2 = first-aid
3 = signals
4 = light weapons
5 = heavy weapons
6 = covert-ops
Tbh I've never tried to set any of these before, but I think this is what Gotenks was talking about in the 2nd link. Also see http://wolfwiki.anime.net/index.php/Lua_Mod_API#xp.
http://bani.anime.net/banimod/forums/vi ... php?t=6723
http://bani.anime.net/banimod/forums/vi ... php?t=6770
You can read xp from either of those, but you can't set it.
If its any help to you, you can access upgrades with sess.skill.
Code: Select all
skill = et.gentity_get(cno, "sess.skill" , k)
0 = battlesense
1 = engineering
2 = first-aid
3 = signals
4 = light weapons
5 = heavy weapons
6 = covert-ops
Tbh I've never tried to set any of these before, but I think this is what Gotenks was talking about in the 2nd link. Also see http://wolfwiki.anime.net/index.php/Lua_Mod_API#xp.
GhosT:McSteve
Ghostworks Gaming Community
Ghostworks Gaming Community
thanks for the replies..
so I used this:
and the msg prints well, but it doesn't skip the upgrade.. and if I use et_SetPlayerSkill the server freezes as it loads the mod..
so I used this:
Code: Select all
function et_UpgradeSkill( cno, skill )
local cg_noSkillUpgrades = tonumber(et.trap_Cvar_Get("cg_noSkillUpgrades"))
if cg_noSkillUpgrades then
clientConsole( cno, "Skill upgraded, use cg_noSkillUpgrades cvar to disable.")
return 1
else
clientConsole( cno, "Skill upgrade ignored. cg_noSkillUpgrades 0 to enable.")
return -1
end
end
"cg_noSkillUpgrades" is not a native cvar, but "b_noskillupgrades" is valid in ETPro if you wish to use that.
If you have created "cg_noKillUpgrades" in your server config and assigned a value to it, then the line:
is valid and will return the numeric value you assigned it in your config. If you have not created the cvar then et.trap_cvar_get will return a zero length string and tonumber will return 0 (not nil). Either way, I believe your statement:
will always run since "cg_noKillUpgrades" is never nil, i.e. your "else" condition is never entered so you never get a return of -1.
I get the gist, but I'm not 100% sure of what it is you are trying to do. If you can elaborate a little then hopefully someone here will be able to help if you still encounter problems with your script.
If you have created "cg_noKillUpgrades" in your server config and assigned a value to it, then the line:
Code: Select all
local cg_noSkillUpgrades = tonumber(et.trap_Cvar_Get("cg_noSkillUpgrades"))
Code: Select all
if cg_noSkillUpgrades then
I get the gist, but I'm not 100% sure of what it is you are trying to do. If you can elaborate a little then hopefully someone here will be able to help if you still encounter problems with your script.
GhosT:McSteve
Ghostworks Gaming Community
Ghostworks Gaming Community
If it helps, I did a similar kind of thing in http://www.bogeylicker.co.uk/et/lua/announcehp_v4.lua. Clients could turn on and off the hp notifications by using commands "showhpleft on" and "showhpleft off". The slightly tricky bit was getting the setting to be persistant, and I used a file to store the values so they could be carried over map change (so the client didn't have to keep typing the command each map).
You could use the same approach in your script and advertise your available commands with a banner and/or some !help commands. Using this approach, your clientcommand and upgradeskill functions would look something like this:
The above code is obviously incomplete, its just an example of a way you could do it without trying to read client cvars. However, if you slot the above into announcehp_v4.lua and make the necessary changes in the rest of the script, it should work.
You could use the same approach in your script and advertise your available commands with a banner and/or some !help commands. Using this approach, your clientcommand and upgradeskill functions would look something like this:
Code: Select all
function et_ClientCommand(cno, cmd)
if string.lower(cmd) == "skillupgrades" then
-- set skillupgrades[cno] and announce it to the client
if tonumber(et.trap_Argv(1)) == 1 then
skillupgrades[cno] = 1
et.trap_SendServerCommand( cno, "cpm \"SKILL UPGRADES ON \n\" " )
elseif tonumber(et.trap_Argv(1)) == 0 then
skillupgrades[cno] = 0
et.trap_SendServerCommand( cno, "cpm \"SKILL UPGRADES OFF \n\" " )
end
return 1
end
return 0
end
function et_UpgradeSkill( cno, skill )
if skillupgrades[cno] == 1 then
clientConsole( cno, "Skill upgraded, use skillupgrades 0 to disable.")
return 1
elseif skillupgrades[cno] == 0 then
clientConsole( cno, "Skill upgrade ignored, use skillupgrades 1 to enable.")
return -1
else
return 1
end
end
GhosT:McSteve
Ghostworks Gaming Community
Ghostworks Gaming Community
thanks steve, I liked your approach, but I'm pretty sure the et_UpgradeSkill is broken, i made an empty one that returns -1 and skills still gets upgraded.
I managed to get/set the skill levels and it works pretty well. It doesn't reflect on the GUI when +stats command is issued or in the limbo, so i made this command so that people will see what the skill levels actually are..
if someone wants to investigate et_UpgradeSkill please follow up in this thread.
I managed to get/set the skill levels and it works pretty well. It doesn't reflect on the GUI when +stats command is issued or in the limbo, so i made this command so that people will see what the skill levels actually are..
Code: Select all
elseif cmd == "resetskill" then
et.gentity_set( cn, "sess.skill", 0, 0 )
et.gentity_set( cn, "sess.skill", 1, 0 )
et.gentity_set( cn, "sess.skill", 2, 0 )
et.gentity_set( cn, "sess.skill", 3, 0 )
et.gentity_set( cn, "sess.skill", 4, 0 )
et.gentity_set( cn, "sess.skill", 5, 0 )
et.gentity_set( cn, "sess.skill", 6, 0 )
et.trap_SendServerCommand( cn, "print \"Skills has been reset. \n\" " )
return 1
elseif cmd == "showskill" then
et.trap_SendServerCommand( cn, "print \"- Battle Sense = "..et.gentity_get(cn,"sess.skill",0).." \n\" " )
et.trap_SendServerCommand( cn, "print \"- Engineering = "..et.gentity_get(cn,"sess.skill",1).." \n\" " )
et.trap_SendServerCommand( cn, "print \"- First Aid = "..et.gentity_get(cn,"sess.skill",2).." \n\" " )
et.trap_SendServerCommand( cn, "print \"- Signals = "..et.gentity_get(cn,"sess.skill",3).." \n\" " )
et.trap_SendServerCommand( cn, "print \"- Light Weapons = "..et.gentity_get(cn,"sess.skill",4).." \n\" " )
et.trap_SendServerCommand( cn, "print \"- Heavy Weapons = "..et.gentity_get(cn,"sess.skill",5).." \n\" " )
et.trap_SendServerCommand( cn, "print \"- Covert Ops = "..et.gentity_get(cn,"sess.skill",6).." \n\" " )
return 1
Hmm, I'm getting the same, -1 does not override (also tried 1 just in case). Plus I'm getting crashing too when fiddling about with et_setplayerskill, same as you.
Seems to be a complete absence of anyone else using it under Lua:users and idd on these forums so it could well be that no-one has tried it recently.
Seems to be a complete absence of anyone else using it under Lua:users and idd on these forums so it could well be that no-one has tried it recently.
GhosT:McSteve
Ghostworks Gaming Community
Ghostworks Gaming Community