lua .. /resetxp

Discussions about ET modding (sdk code, player/weapon modeling)

Moderators: Forum moderators, developers

Dee
Posts: 20
Joined: Fri Jun 01, 2007 2:36 pm

lua .. /resetxp

Post by Dee »

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?
User avatar
gotenks
Posts: 3465
Joined: Fri Nov 15, 2002 4:12 pm
Location: out of my mind
Contact:

Post by gotenks »

you can't change a person's xp, but you can change their stats
My Website
Image
After a night of binge drinking:
=FF=im2good4u wrote:WTF wanst i on top ?
Dee
Posts: 20
Joined: Fri Jun 01, 2007 2:36 pm

Post by Dee »

so if I change that, is it going to affect the overall xp ?

and if i reset weapon stats is it going to reset light weapon upgrades and such?
McSteve
Posts: 113
Joined: Tue Sep 12, 2006 7:41 am

Post by McSteve »

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.

Code: Select all

skill = et.gentity_get(cno, "sess.skill" , k)
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.
GhosT:McSteve
Ghostworks Gaming Community
User avatar
gotenks
Posts: 3465
Joined: Fri Nov 15, 2002 4:12 pm
Location: out of my mind
Contact:

Post by gotenks »

yes, 2nd post was basicall it... bani doesn't want an xp save option so he's not letting xp be setable...
My Website
Image
After a night of binge drinking:
=FF=im2good4u wrote:WTF wanst i on top ?
Dee
Posts: 20
Joined: Fri Jun 01, 2007 2:36 pm

Post by Dee »

thanks for the replies..

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

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..
McSteve
Posts: 113
Joined: Tue Sep 12, 2006 7:41 am

Post by McSteve »

"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:

Code: Select all

local cg_noSkillUpgrades = tonumber(et.trap_Cvar_Get("cg_noSkillUpgrades")) 
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:

Code: Select all

if cg_noSkillUpgrades then
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.
GhosT:McSteve
Ghostworks Gaming Community
Dee
Posts: 20
Joined: Fri Jun 01, 2007 2:36 pm

Post by Dee »

oh, I think I made a mistake, i was trying to fetch a client cvar.. crap, so how do i go around doing it?
Dee
Posts: 20
Joined: Fri Jun 01, 2007 2:36 pm

Post by Dee »

ps. what i'm trying to make is make an option per client to allow upgrades or not, some people prefer to play with level 0 some like more xp .. i just wanted to let the players choose for themselves
User avatar
gotenks
Posts: 3465
Joined: Fri Nov 15, 2002 4:12 pm
Location: out of my mind
Contact:

Post by gotenks »

you can't get a client cvar... server only, however you can get their config string... there is a way for them to set a cvar into this, but it's not normal (believe /sets) but most don't know this/won't do it right
My Website
Image
After a night of binge drinking:
=FF=im2good4u wrote:WTF wanst i on top ?
McSteve
Posts: 113
Joined: Tue Sep 12, 2006 7:41 am

Post by McSteve »

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:

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
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.
GhosT:McSteve
Ghostworks Gaming Community
Dee
Posts: 20
Joined: Fri Jun 01, 2007 2:36 pm

Post by Dee »

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..

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
if someone wants to investigate et_UpgradeSkill please follow up in this thread.
Dee
Posts: 20
Joined: Fri Jun 01, 2007 2:36 pm

Post by Dee »

PS. the above code goes in et_clientCommand function
McSteve
Posts: 113
Joined: Tue Sep 12, 2006 7:41 am

Post by McSteve »

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.
GhosT:McSteve
Ghostworks Gaming Community
Dee
Posts: 20
Joined: Fri Jun 01, 2007 2:36 pm

Post by Dee »

actually my solution isn't complete either, whenever i kill someone it upgrades my light weapons back to what the game think it should be
Post Reply