GG Scoreboard

Request a custom addon/script you would like to see made.

GG Scoreboard

Postby zeroibis » Wed Feb 04, 2009 12:05 am

Replace the kills column on the scoreboard with the players current gg level. This makes it quick and easy for players to see how the rest of the server is doing in comparison to themselves.
zeroibis

Private
Private
 
Posts: 6
Joined: Thu Nov 27, 2008 12:46 am

Re: GG Scoreboard

Postby addem1234 » Tue Feb 10, 2009 8:48 pm

Hello there!
I had the same idea once and did a try, it didnt work so well... but here it is annyway :)



'''
    Title: gg_scoreboard
    Version: 0.1
    Description: shows gg level on scoreboard.
'
''
# ==============================================================================
#   IMPORTS
# ==============================================================================
# Python imports

# EventScripts imports
import es

# GunGame imports
import gungamelib

# ==============================================================================
#   ADDON REGISTRATION
# ==============================================================================
# Register this addon with EventScripts
info = es.AddonInfo()
info.name     = 'Scoreboard Addon for GunGame5'
info.version  = '0.1'
info.url      = ''
info.basename = 'gungame/custom_addons/gg_scoreboard'
info.author   = 'addem1234'

# ==============================================================================
#   GAME EVENTS
# ==============================================================================
def load():
    addon = gungamelib.registerAddon('gg_scoreboard')
    addon.setDisplayName('GG Scoreboard')
   
def unload():
    gungamelib.unregisterAddon('gg_scoreboard')

def player_spawn(event_var):
    level = gungamelib.getPlayer(event_var['userid'])['level']
    es.server.cmd('est_killset %s %s' % (event_var['userid'], level)

def gg_leveldown(event_var):
    es.server.cmd('est_killset %s %s' % (event_var['userid'], int(event_var['new_level'])))
   
def gg_levelup(event_var):
    es.server.cmd('est_killset %s %s' % (event_var['userid'], int(event_var['new_level'])))
 


Note that this does not work (completly) and needs some more work... but its a start :)

EDIT: the config: (lol)
//Config for gg_scoreboard

//enable = 1 disable = 0
gg_scoreboard 1
Last edited by addem1234 on Tue Feb 10, 2009 9:46 pm, edited 1 time in total.
0mg i can haz sig?!?!?!?
addem1234

Private
Private
User avatar
 
Posts: 13
Joined: Thu Nov 27, 2008 5:09 pm
Location: Sweden

Re: GG Scoreboard

Postby addem1234 » Tue Feb 10, 2009 9:44 pm

updated working code...
'''
    Title: gg_scoreboard
    Version: 0.1
    Description: shows gg level on scoreboard.
'
''
# ==============================================================================
#   IMPORTS
# ==============================================================================
# Python imports
import gamethread

# EventScripts imports
import es

# GunGame imports
import gungamelib

# ==============================================================================
#   ADDON REGISTRATION
# ==============================================================================
# Register this addon with EventScripts
info = es.AddonInfo()
info.name     = 'Scoreboard Addon for GunGame5'
info.version  = '0.1'
info.url      = ''
info.basename = 'gungame/custom_addons/gg_scoreboard'
info.author   = 'addem1234'

# ==============================================================================
#   GAME EVENTS
# ==============================================================================
def load():
    addon = gungamelib.registerAddon('gg_scoreboard')
    addon.setDisplayName('GG Scoreboard')
   
def unload():
    gungamelib.unregisterAddon('gg_scoreboard')

def player_spawn(event_var):
    es.server.queuecmd('est_killset %s %s' % (event_var['userid'], int(gungamelib.getPlayer(event_var['userid'])['level'])))

def player_death(event_var):
    gamethread.delayed(0.1, es.server.queuecmd,('est_killset %s %s' % (event_var['userid'], int(gungamelib.getPlayer(event_var['userid'])['level']))))
   
    attackerWeapon = gungamelib.getLevelWeapon(gungamelib.getPlayer(event_var['attacker'])['level'])
    if attackerWeapon == "hegrenade":
        es.server.queuecmd('est_killset %s %s' % (event_var['attacker'], int(gungamelib.getPlayer(event_var['attacker'])['level'])))
   
def gg_leveldown(event_var):
    es.server.queuecmd('est_killset %s %s' % (event_var['userid'], int(event_var['new_level'])))
   
def gg_levelup(event_var):
    es.server.queuecmd('est_killset %s %s' % (event_var['userid'], int(event_var['new_level'])))
0mg i can haz sig?!?!?!?
addem1234

Private
Private
User avatar
 
Posts: 13
Joined: Thu Nov 27, 2008 5:09 pm
Location: Sweden

Postby PitBull » Wed Feb 11, 2009 2:05 pm

I don't think that this code would work. In each queuecmd you use:
'est_killset %s %s' % (event_var['userid'], int(gungamelib.getPlayer(event_var['userid'])['level']))

But that will not work without errors. %s is a wildcard for a string, not for an integer. So this line would be correct:
'est_killset %s %s' % (event_var['userid'], gungamelib.getPlayer(event_var['userid'])['level'])

Or you use %i instead of %s:
'est_killset %s %i' % (event_var['userid'], int(gungamelib.getPlayer(event_var['userid'])['level']))

Also, EventScripts allows you to set kills without ES_Tools (but not deaths). With ES, the command would be:
es.server.queuecmd('score set %s %s' % (event_var['userid'], gungamelib.getPlayer(event_var['userid'])['level']))

What I don't understand either: why do you only set the attackers kills back to the level value after a nade-kill? And why do you set the victims level again?
A working script should be:
'''
    Title: gg_scoreboard
    Version: 0.1
    Description: shows gg level on scoreboard.
'
''
# ==============================================================================
#   IMPORTS
# ==============================================================================
# Python imports
import gamethread

# EventScripts imports
import es

# GunGame imports
import gungamelib

# ==============================================================================
#   ADDON REGISTRATION
# ==============================================================================
# Register this addon with EventScripts
info = es.AddonInfo()
info.name     = 'Scoreboard Addon for GunGame5'
info.version  = '0.1'
info.url      = ''
info.basename = 'gungame/custom_addons/gg_scoreboard'
info.author   = 'addem1234 (modified by PitBull0993)'

# ==============================================================================
#   GAME EVENTS
# ==============================================================================
def load():
    gg_scoreboard = gungamelib.registerAddon('gg_scoreboard')
    gg_scoreboard.setDisplayName('GG Scoreboard')
   
def unload():
    gungamelib.unregisterAddon('gg_scoreboard')

def player_spawn(event_var):
    es.server.queuecmd('score set %s %s' % (event_var['userid'], gungamelib.getPlayer(event_var['userid'])['level']))

def player_death(event_var):
    gamethread.delayed(0.1, es.server.queuecmd, ('score set %s %s' % (event_var['attacker'], gungamelib.getPlayer(event_var['userid'])['level'])))
   
def gg_leveldown(event_var):
    es.server.queuecmd('score set %s %s' % (event_var['userid'], event_var['new_level']))

def gg_levelup(event_var):
    es.server.queuecmd('score set %s %s' % (event_var['userid'], event_var['new_level']))


Best Regards,
PitBull
PitBull

GunGame5 Developer
GunGame5 Developer
User avatar
 
Posts: 66
Joined: Mon Nov 10, 2008 7:05 pm
Steam Friends Name: wergup_pitbull

Re: GG Scoreboard

Postby addem1234 » Wed Feb 11, 2009 9:45 pm

What I don't understand either: why do you only set the attackers kills back to the level value after a nade-kill? And why do you set the victims level again?


well at first i didnt include that part, but then the vicim's level was set to the killers levels so i added (in def player_death():):

es.server.queuecmd(score set %s %s' % (event_var['userid'], gungamelib.getPlayer(event_var['userid'])['level'])))


that didnt work ither so i added

gamethread.delayed(0.1, es.server.queuecmd,('score set %s %s' % (event_var['userid'], gungamelib.getPlayer(event_var['userid'])['level'])))


and then i taught: if earn nade is on they will get kills anyway! so this is needed:

attackerWeapon = gungamelib.getLevelWeapon(gungamelib.getPlayer(event_var['attacker'])['level'])
if attackerWeapon == "hegrenade":
    es.server.queuecmd('score set %s %s' % (event_var['attacker'], gungamelib.getPlayer(event_var['attacker'])['level']))


%s is a wildcard for a string, not for an integer.

thanks, didn't know that! i am kinda python newbie...

Also, EventScripts allows you to set kills without ES_Tools (but not deaths)

thanks for tip :)


new code attached.
Attachments
gg_scoreboard.py
note the info.author :)
(1.97 KiB) Downloaded 826 times
0mg i can haz sig?!?!?!?
addem1234

Private
Private
User avatar
 
Posts: 13
Joined: Thu Nov 27, 2008 5:09 pm
Location: Sweden

Postby PitBull » Thu Feb 12, 2009 1:58 pm

I still think the hegrenade-part is not needed. If you set the attackers level every time he kills someone to his current level, it doesn't matter which weapon he used or how many kills he made. Also, you set the victims level every time he dies. Why the one of the victim? You need to set the one of the attacker, because he got the kill. The victims level ony changes if it's a suicide, and then gg_leveldown sets the score again. And if you set the attackers level on player_death, you also need to check if the kill was made by a player and not by world. So the check would be:
if event_var['attacker'] == 0: # If it's death with world
    return # Stop here

And the whole block:
def player_death(event_var):
    if event_var['attacker'] == 0:
        return
    gamethread.delayed(0.1, es.server.queuecmd, ('score set %s %s' % (event_var['attacker'], gungamelib.getPlayer(event_var['userid'])['level']))))


Best Regards,
PitBull
PitBull

GunGame5 Developer
GunGame5 Developer
User avatar
 
Posts: 66
Joined: Mon Nov 10, 2008 7:05 pm
Steam Friends Name: wergup_pitbull



Return to Script Requests

Who is online

Users browsing this forum: No registered users and 0 guests

cron