LUA script, extra grenades and medpack healing for XP


(NovaPrime) #1

I am looking for a non-complex LUA script to change the number of default grenades and medpack healing based on XP.

example:

if XP =100,000 grenades =10 & medpack healing = xxx

— end —

A one liner with only 100,000 XP would be enough. any idea how I can do this?


(Micha) #2

You could use the following lua as base or code a new one with foreach (look at pairs/ipairs) which sets for each given array (xp) the amount of grenades.
Medpack healing can not be changed with lua as far as I know (direct health can be set).

http://mnwa.bplaced.net/ftpfiles/Lua/autosetlevel.lua

Lua help:
http://lua-users.org/wiki/ForTutorial
http://mygamingtalk.com/wiki/Silent_Lua


(NovaPrime) #3

I am assuming I replace “setlevel(clientNum,1,lvl1xp)” with a grenade function?


(Micha) #4

kinda. you need et.gentity_set(cno, “ps.ammoclip”, 4, (et.gentity_get(clientNum, “ps.ammoclip”, 4) +1)
while clientNum is the clientnumber,
4 is axis grenade (WP_GRENADE_LAUNCHER)
and 1 the amount and the …_get part is to recieve the actual amount of grenades right now and add +x.

The number 9 is allies grenade (WP_GRENADE_PINEAPPLE).

Something like this:
if valXP >= lvl1xp and valXP < lvl2xp then
et.gentity_set(clientNum, “ps.ammoclip”, 4, (et.gentity_get(clientNum, “ps.ammoclip”, 4) +1)
et.gentity_set(clientNum, “ps.ammoclip”, 9, (et.gentity_get(clientNum, “ps.ammoclip”, 9) +1)
elseif valXP >= lvl2xp and valXP < lvl3xp then

You could add a check for the team and add if (team == 1) then
bla bla 4 bla
else
bla bla 9
end