gg_setlevel

Ask questions and share info about GunGame 5

gg_setlevel

Postby Abort » Fri Jul 16, 2010 2:13 pm

Is there a new/different command for this, or has it been removed completely? :cry: This ability came in very handy for lo3's.
Abort

Private
Private
 
Posts: 7
Joined: Tue Jul 13, 2010 8:27 pm
Steam Friends Name: abort_fetus

Postby XE_ManUp » Fri Jul 16, 2010 2:30 pm

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

Site Admin
Site Admin
 
Posts: 662
Joined: Sat Sep 06, 2008 3:36 am

Postby Abort » Fri Jul 16, 2010 2:34 pm

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

Private
Private
 
Posts: 7
Joined: Tue Jul 13, 2010 8:27 pm
Steam Friends Name: abort_fetus

Postby XE_ManUp » Fri Jul 16, 2010 2:38 pm

That's kinda what the entire thing above does, you just caught me as I was editing it!
XE_ManUp

Site Admin
Site Admin
 
Posts: 662
Joined: Sat Sep 06, 2008 3:36 am

Postby Abort » Fri Jul 16, 2010 2:44 pm

Ok so I put all that in a .py file and upload it as set_to_one.py ?
Abort

Private
Private
 
Posts: 7
Joined: Tue Jul 13, 2010 8:27 pm
Steam Friends Name: abort_fetus

Postby XE_ManUp » Fri Jul 16, 2010 2:44 pm

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

Site Admin
Site Admin
 
Posts: 662
Joined: Sat Sep 06, 2008 3:36 am

Postby Abort » Fri Jul 16, 2010 2:46 pm

Ok, thank you kind sir! :D I will try this right now.
Abort

Private
Private
 
Posts: 7
Joined: Tue Jul 13, 2010 8:27 pm
Steam Friends Name: abort_fetus

Postby XE_ManUp » Fri Jul 16, 2010 2:52 pm

Sure. Let me know if you run into any complications.
XE_ManUp

Site Admin
Site Admin
 
Posts: 662
Joined: Sat Sep 06, 2008 3:36 am

Postby Abort » Fri Jul 16, 2010 3:25 pm

This works perfect! Thanks for your help. <3 the GG support from dev's. Goes beyond the call.
Abort

Private
Private
 
Posts: 7
Joined: Tue Jul 13, 2010 8:27 pm
Steam Friends Name: abort_fetus

Postby XE_ManUp » Fri Jul 16, 2010 3:35 pm

Excellent. I haven't lost my touch.
XE_ManUp

Site Admin
Site Admin
 
Posts: 662
Joined: Sat Sep 06, 2008 3:36 am



Return to General Discussion

Who is online

Users browsing this forum: No registered users and 25 guests