Page 1 of 1

gg_setlevel

PostPosted: Fri Jul 16, 2010 2:13 pm
by Abort
Is there a new/different command for this, or has it been removed completely? :cry: This ability came in very handy for lo3's.

PostPosted: Fri Jul 16, 2010 2:30 pm
by XE_ManUp
There is not a gg_setlevel command included, although the python code for setting a player's level is relatively easy to do:

from gungame51.core.players.shortcuts import Player

# Loop through all players and set their level to 1
def set_to_one():
    for userid in es.getUseridList():
        Player(userid).level = 1


Another example:

from gungame51.core.players.shortcuts import setAttribute

def set_to_one():
    setAttribute("#all", "level", 1)


Beyond that, you would have to use the es.regcmd() function to register the command gg_setlevel_all to execute the set_to_one() functions above:

import es

def load():
    es.regcmd("gg_setlevel_all", "script_name/set_to_one", "Sets every player's level to level 1")


This is a quick and poor example, but it should work.

PostPosted: Fri Jul 16, 2010 2:34 pm
by Abort
I am not too familiar with making scripts or python for that matter. Is there anyone willing to help with this? Just basicly need a command that will reset everyone's level to 1.

PostPosted: Fri Jul 16, 2010 2:38 pm
by XE_ManUp
That's kinda what the entire thing above does, you just caught me as I was editing it!

PostPosted: Fri Jul 16, 2010 2:44 pm
by Abort
Ok so I put all that in a .py file and upload it as set_to_one.py ?

PostPosted: Fri Jul 16, 2010 2:44 pm
by XE_ManUp
import es
from gungame51.core.players.shortcuts import setAttribute

def load():
    es.regcmd("gg_reset_player_levels", "gg_reset_player_levels/set_to_one", "Sets every player's level to level 1")

def set_to_one():
    setAttribute("#all", "level", 1)


You would name the above script/file "gg_reset_player_levels.py", then place it in:

../cstrike/addons/eventscripts/gg_reset_player_levels/gg_reset_player_levels.py


Then, you would load it AFTER gungame51...

es_load gungame51
es_load gg_reset_player_levels


To reset player levels - you issue the command: gg_reset_player_levels in console.

PostPosted: Fri Jul 16, 2010 2:46 pm
by Abort
Ok, thank you kind sir! :D I will try this right now.

PostPosted: Fri Jul 16, 2010 2:52 pm
by XE_ManUp
Sure. Let me know if you run into any complications.

PostPosted: Fri Jul 16, 2010 3:25 pm
by Abort
This works perfect! Thanks for your help. <3 the GG support from dev's. Goes beyond the call.

PostPosted: Fri Jul 16, 2010 3:35 pm
by XE_ManUp
Excellent. I haven't lost my touch.