gg_gladiator(1 Vs 1 Knife)

Area to post and download Custom Addons, as well as ask the author/users for help or support.

gg_gladiator(1 Vs 1 Knife)

Postby Don » Sun Oct 19, 2008 7:41 pm

gg_gladiator

Notice: This addon will make all new players start at a higher level if you have glad_1_vs_1_only set to 0. Set it to 1 if you wish to disable the leveling function.


Description:
Gladiator is a custom addon written for Gun Game 5 Python. It adds a unique playing experience for all players, whether they are seasoned Gun Game addicts or the newest addition to your Clan.  It can be played in either normal or deathmatch modes.  Gun Game is played normally until there is at least one combatant on each team that have reached knife level.  This is when Gladiator Mode is entered.  In Gladiator Mode all players except the first player on each team to reach knife level are pushed to spectator and the two knife level players become Gladiators for their teams.  The map is won when one of the players either kills his opponent or either player kills himself by suicide or misfortune.  If a player commits suicide or is killed due to misfortune his opponent is given the Map win and a Gladiator Win. Once a player has reached Gladiator Mode status he is given a point. If he wins the Gladiator Mode round he is given a Gladiator Win point.  Statistics are kept and the Payoffs are as follows.

Statistics:
Number of Maps that a player has completed is kept as a statistic.
Number of times that a player reaches First Knifer is kept as a statistic.
Number of times that a player has Won Gladiator Mode is kept as a statistic.

Payoff:
The number of times that a player has reached First Knifer is divided by the number of Maps the player has competed in, this gives the Gladiator Ratio.  The Gladiator Ratio will push a player up/down in the next map gun cycle upon entering the next map. This is the main way that a player’s gun cycle level is determined when he enters the next map.
The number of Gladiator Wins is divided by the number of times that a player has competed in Gladiator Mode, this gives the Win Ratio.  The Win Ratio can give the player a pop up on his gun cycle level if his Win Ratio is above 50%.
The leveling feature can be turned off which will make the addon act like a simple 1 Vs 1 addon.

Bots:
Bots can be used and their starting level can be set in the config file based on botprofile.db. If you use bots you should set the following in your server.cfg or bot.cfg:
bot_quota_mode match
bot_quota 1 This is recommended but you can use more if you wish.


Note:
This addon is intended to give the players an added twist to Gun Game. It is encouraged that if you use the addon to have a Top Ten List of Gladiators and their Win Ratio displayed to give them the recognition they deserve. It also acts as a leveling technique for severs that have a mix of seasoned professionals and just the occasional avid player. The math for leveling the playing field is not complex, but a little convoluted, and when players first start out they may find their gun cycle level oscillating up and down until they have played a sufficient number of Maps and have reached Gladiator and Won. For the addon to work correctly the knife needs to be the last weapon in your weapon order.

Servers running this addon:
http://www.game-monitor.com/search.php? ... e=variable

EventScripts Addon Manager
http://addons.eventscripts.com/addons/view/gg_gladiator

Download
Note: Changed file to fix stuff XE_ManUp requested. New on 10/27/08
Note: Added Top Ten CSV file in custom_addons folder gg_glad_topten.csv. New on 11/09/08
Note: Added language ini file in cfg/gungame5/translations folder = gg_gladiator.ini. New on 11/17/08
Note: Added German translation. Thanks Tomelyr New on 11/17/08
Note: Finally fixed the option to remove leveling. Did not know it wasn't working until a few days ago. 7/02/09
I am 31% addicted to Counterstrike. What about you?
Don

Site Admin
Site Admin
User avatar
 
Posts: 529
Joined: Fri Sep 05, 2008 3:05 am
Location: The Valley
Steam Friends Name: Don
Xfire Name: donlafferty

Re: gg_gladiator

Postby XE_ManUp » Sun Oct 26, 2008 8:04 am

I just wanted to point out a few things that you may or may not know.

When custom addon configs (or any configs handled by GunGame, for that matter) are loaded, anything that is not commented out becomes a public variable. Therefore, the following settings (although I doubt you want them to be) become GunGame variables:

BOT Start Levels
// Set the level you want each bot personality to start on

Elite 1
Expert 2
VeryHard 3
Hard 4
Tough 5
Normal 6
Fair 7
Easy 8


...I would recommend that you place those in less generic variable names, or find a better way to implement them.

The other item that I see is that you are not taking advantage of the GunGame message class. This allows players to view your addon in multiple languages. I am well aware that this is not documented at this point. However, it might be something that you would want to look into for a future release. To create a translation file, you would create the following:

../cfg/gungame5/translations/gg_gladiator.ini


I will use the following messages as an example:

es.tell(userid,"Gladiator Addon Loaded")
es.msg("#multi", "#green", ctplayer.attributes['name'] + " #lightgreenhealth = #default" + str(ctplayer.get('health'))  + "    #green" + tplayer.attributes['name'] + " #lightgreenhealth = #default" + str(tplayer.get('health')))


Once you have created the language INI, you could take a message and place it in there like so:

[Gladiator_Loaded]
en="Gladiator Addon Loaded"

[Health_Message]
en="#green $ctName #lightgreenhealth = #default$ctHealth #green$tName #lightgreenhealth = #default$tHealth"


Take note that in the above, variables are preceded with $variableName. The code that fires the above messages:

#gungamelib.msg(addonName, filter, message, variableDictionary=None)
gungamelib.msg('gg_gladiator', userid, 'Gladiator_Loaded')
# Tells the "es.tell()" to look in gg_gladiator.ini for the message "Gladiator_Loaded" and to send to the specified userid


Here's the more complicated message:

#gungamelib.msg(addonName, filter, message, variableDictionary)
gungamelib.msg('gg_gladiator', '#all', 'Health_Message', {'ctName': ctplayer.attributes['name'], 'ctHealth': str(ctplayer.get('health')), 'tName': tplayer.attributes['name'], 'tHealth': str(tplayer.get('health'))})


I hope the above helps you to understand the Message Class a little bit better. It is one of the things that I love about what we have done. I'm sure I will come up with more things to pester you with over time. ;)

My final request (for now :oops: ) would be that the sounds that you have be relocated into their own individual folder:

../sound/gungame/gg_gladiator/
XE_ManUp

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

Postby Don » Sun Oct 26, 2008 4:42 pm

I would have to ask why you decided to make everything in a cfg public? That seems rather foolish at first glance. I'm sure you have some valid reason but it escapes me. :?
Don

Site Admin
Site Admin
User avatar
 
Posts: 529
Joined: Fri Sep 05, 2008 3:05 am
Location: The Valley
Steam Friends Name: Don
Xfire Name: donlafferty

Re:

Postby XE_ManUp » Sun Oct 26, 2008 4:53 pm

Don wrote:I would have to ask why you decided to make everything in a cfg public? That seems rather foolish at first glance. I'm sure you have some valid reason but it escapes me. :?

In order to catch variable changes via the server_cvar event, we have to add the notify flag, which adds replicated. Needless to say, this has been around for quite some time. This way, if someone types (in your case):

gg_gladiator 0 // unloads
gg_gladiator 1 // loads


The server_cvar event is fired stating that the values were changed. We had to find a viable way of tracking the console cvars for direct changes.
XE_ManUp

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

Re: Re:

Postby Don » Sun Oct 26, 2008 5:05 pm

XE_ManUp wrote:
Don wrote:I would have to ask why you decided to make everything in a cfg public? That seems rather foolish at first glance. I'm sure you have some valid reason but it escapes me. :?

In order to catch variable changes via the server_cvar event, we have to add the notify flag, which adds replicated. Needless to say, this has been around for quite some time. This way, if someone types (in your case):

gg_gladiator 0 // unloads
gg_gladiator 1 // loads


The server_cvar event is fired stating that the values were changed. We had to find a viable way of tracking the console cvars for direct changes.

Ok, I knew there would be a reason. I just didn't see it. Thank you.
I am 31% addicted to Counterstrike. What about you?
Don

Site Admin
Site Admin
User avatar
 
Posts: 529
Joined: Fri Sep 05, 2008 3:05 am
Location: The Valley
Steam Friends Name: Don
Xfire Name: donlafferty

Postby Don » Tue Oct 28, 2008 12:25 am

This has been updated to reflect all changes requested. The config has been changed so you put in the percentage of full level each bot starts at.
Don

Site Admin
Site Admin
User avatar
 
Posts: 529
Joined: Fri Sep 05, 2008 3:05 am
Location: The Valley
Steam Friends Name: Don
Xfire Name: donlafferty

Postby Don » Sun Nov 09, 2008 8:34 pm

Updated to add a Top Ten file. It now outputs a csv file with Steam ID, Name, # Maps played, # Times First Knifer, # Gladiator Wins, and Win Ratio of the top ten players. This File could be used to create a Web Top Ten list.

I will probably add the ability to create a web page in a future version
Don

Site Admin
Site Admin
User avatar
 
Posts: 529
Joined: Fri Sep 05, 2008 3:05 am
Location: The Valley
Steam Friends Name: Don
Xfire Name: donlafferty

Re: gg_gladiator

Postby slipknot » Sun Nov 16, 2008 4:45 pm

Don,

Interesting post in http://forums.gungame5.com/viewtopic.php?f=35&t=232 How can this be done? / Can this be done?

I wonder how turning FF on after someone hits First Knifer would change gladiator play :?:
It's better to burn out, than fade away.
slipknot

Site Admin
Site Admin
User avatar
 
Posts: 72
Joined: Sun Sep 07, 2008 12:21 am
Location: Hawthorne, CA
Steam Friends Name: sfmeyer1
Xfire Name: slipknotsfm

Postby Tomelyr » Sun Nov 16, 2008 6:49 pm

If you make a new Version with a translation i will do a German Translation

btw good addon nice work ^^
Tomelyr

Moderator
Moderator
 
Posts: 41
Joined: Sat Nov 15, 2008 2:46 pm
Location: [Germany] Hamburg
Steam Friends Name: mr_fry
Xfire Name: tomelyr

Postby Don » Mon Nov 17, 2008 6:09 pm

Added the language file. I had it but had forgotten to add it.
Don

Site Admin
Site Admin
User avatar
 
Posts: 529
Joined: Fri Sep 05, 2008 3:05 am
Location: The Valley
Steam Friends Name: Don
Xfire Name: donlafferty

Postby Tomelyr » Mon Nov 17, 2008 9:13 pm

[Gladiator_Loaded]
en="Gladiator Addon Loaded"
de="Gladiator Addon geladen"

[Health_Message]
en="#green $ctName #lightgreenhealth = #default$ctHealth #green$tName #lightgreenhealth = #default$tHealth"
de="#green $ctName #lightgreenhealth = #default$ctHealth #green$tName #lightgreenhealth = #default$tHealth"

[First_T_Gladiator]
en="#green$tName #defaultis First T Gladiator"
de="#green$tName #default ist der erste Gladiator der Terroristen"

[First_CT_Gladiator]
en="#green$ctName #defaultis First CT Gladiator"
de="#green$ctName #defaultist der erste Gladiator der Counter-Terroristen"

[T_Gladiator]
en="#green$tName #default= T Gladiator"
de="#green$tName #default= T Gladiator"

[CT_Gladiator]
en="#green$ctName #default= CT Gladiator"
de="#green$ctName #default= CT Gladiator"

[Glad_Mode]
en="#greenGladiator Mode #lightgreenEntered"
de="#greenGladiator Modus #lightgreenaktiviert"

[Your_Stats]
en="$maps Maps $glads Gladiator $wins Wins Win Ratio $win_ratio Level $level"
de="$maps Maps $glads Gladiator $wins Siege Win Ratio $win_ratio Level $level"

[Spectate]
en="You must spectate for the rest of this game."
de="Du musst den rest des Spiels beobachten."
Tomelyr

Moderator
Moderator
 
Posts: 41
Joined: Sat Nov 15, 2008 2:46 pm
Location: [Germany] Hamburg
Steam Friends Name: mr_fry
Xfire Name: tomelyr

Re: gg_gladiator(1 Vs 1 Knife)

Postby SerGun » Sun Jun 14, 2009 1:22 pm

Good day!
Is it possible to do the level limit for new players? 14 level is default, but it is very hight. It will be nice, if I can make a choice from 0-some. May be it can looks like as a menu 'handicap' in a standart server.
Thank you.
SerGun

Recruit
Recruit
 
Posts: 1
Joined: Sun Jun 14, 2009 11:13 am
Steam Friends Name: SerGun

Postby Don » Sun Jun 14, 2009 9:22 pm

You could just change the setting of glad_1_vs_1_only to 1. That way it won't handicap at all. You can then use the GG5 built-in handicapping.
Don

Site Admin
Site Admin
User avatar
 
Posts: 529
Joined: Fri Sep 05, 2008 3:05 am
Location: The Valley
Steam Friends Name: Don
Xfire Name: donlafferty

Re: gg_gladiator(1 Vs 1 Knife)

Postby ipchillout » Mon Jun 15, 2009 11:22 am

SerGun wrote:Good day!
Is it possible to do the level limit for new players? 14 level is default, but it is very hight. It will be nice, if I can make a choice from 0-some. May be it can looks like as a menu 'handicap' in a standart server.
Thank you.


Hi brothers!
Sorry my bad English,all)
...but gg_gladiator plugins all new players give 14 level....
...i change my setting of glad_1_vs_1_only to 1 but level give 14((((
...& very good options ADD in plugins -qestions yes ore no knife, choise "NO" ADD in stat mayby name stats "loser"= 11))))))))))))) andestend me?
ipchillout

Recruit
Recruit
 
Posts: 2
Joined: Sat Jun 13, 2009 5:46 am

Re: gg_gladiator(1 Vs 1 Knife)

Postby ipchillout » Sat Jun 27, 2009 10:32 pm

There is who live???
The server is started in a mode
Still there is such problem that at one of gladiators can be at a meeting not a knife and previous the weapon and it should 1 on 1 pass levels to a knife including, it would be necessary that at it a knife at this time))))


... As the problem remained all entering gives 14 level, it is not so good))))

Excuse I use online the translator
ipchillout

Recruit
Recruit
 
Posts: 2
Joined: Sat Jun 13, 2009 5:46 am

Re:

Postby Don » Sat Jun 27, 2009 11:24 pm

Don wrote:You could just change the setting of glad_1_vs_1_only to 1. That way it won't handicap at all. You can then use the GG5 built-in handicapping.
I am 31% addicted to Counterstrike. What about you?
Don

Site Admin
Site Admin
User avatar
 
Posts: 529
Joined: Fri Sep 05, 2008 3:05 am
Location: The Valley
Steam Friends Name: Don
Xfire Name: donlafferty

Re: gg_gladiator(1 Vs 1 Knife)

Postby Aclinoe » Sun Jun 28, 2009 10:25 pm

Is this how it should look? The seetings below still gives new players a high level and I do not have the handicaped setting inabled. I also tried this glad_1_vs_1_only 0 and still it gives that high level.
I removed this addon from my server and all was right. I really like this addon but no one likes new players getting level 14 when they are like lever 5 or 6. Pls help

// Gladiator Addon Config File
// This file holds the configuration information for the
// GunGame 5 Custom Addon Gladiator
//
// You can cutomize certain features of the addon by changing values below
//
//

gg_gladiator 1

// Set this to 1 if you do not want to set players to the handicap level calculated by
// maps/times gladiator/wins and only want to use the 1 Vs 1 mode.
// Set it to 1 if you want to use the leveling function

glad_1_vs_1_only 1

// BOT Start Levels
// Set the % of knife level you want each bot personality to start on

gg_glad_elite 1
gg_glad_expert 1
gg_glad_veryhard 1
gg_glad_hard 20
gg_glad_tough 20
gg_glad_normal 30
gg_glad_fair 40
gg_glad_easy 40


If not Please re-paste with the right setting. Thanks so much
Aclinoe

Private
Private
User avatar
 
Posts: 9
Joined: Sat Jun 20, 2009 10:59 pm
Steam Friends Name: Aclinoe
Xfire Name: Aclinoe

Re: gg_gladiator(1 Vs 1 Knife)

Postby Aclinoe » Sun Jun 28, 2009 11:20 pm

Here is the .py file info
''' (c) 2008 by the GunGame Coding Team

    Title: gg_gladiator
    Version: 0.0.91
    Description: Custom addon.
'''

# ==============================================================================
#   IMPORTS
# ==============================================================================
# Python imports


# EventScripts imports
import es
import os
import gamethread
import playerlib
import random
import repeat
import datetime
import popuplib
from sqlite3 import dbapi2 as sqlite

# GunGame imports
import gungamelib

# ==============================================================================
#   ADDON REGISTRATION
# ==============================================================================
# Register this addon with EventScripts
info = es.AddonInfo()
info.name     = 'Gladiator Addon for GunGame: Python'
info.version  = '0.0.91'
info.url      = ''
info.basename = 'gungame/custom_addons/gg_gladiator'
info.author   = 'Don & Slipknot'

first_t_knifer = 0
first_ct_knifer = 0
bot_start_levels = {}
glad_stats = {}
topten = []
cfg_file  = es.ServerVar("eventscripts_gamedir")  + "/cfg/gungame5/custom_addon_configs/gg_gladiator.cfg"
botprofile  = es.ServerVar("eventscripts_gamedir")  + "/botprofile.db"
gg_gladtoptenfile = es.ServerVar("eventscripts_gamedir")  + "/addons/eventscripts/gungame/custom_addons/gg_gladiator/gg_glad_topten.csv"
gPlayers = set()
nsPlayers = set()
one_v_one_mode = 0
win_sound = ''
knife_level = 0
one_v_one_only = 0
__version__ = '0.0.91'
es.ServerVar('gg_glad_ver', __version__).makepublic()

class connection(object):
    def __init__(self,path):
        self.con = sqlite.connect(path)
        self.cur = self.con.cursor()
    def execute(self,sql):
        self.cur.execute(sql)
        self.con.commit()
    def query(self,sql):
        self.cur.execute(sql)
#        return self.cur.fetchall()
        return convertQuery(self.cur.fetchall())
    def close(self):
        self.con.close()

# ==============================================================================
#   GAME EVENTS
# ==============================================================================
def load():
    global knife_level
    gg_gladiator = gungamelib.registerAddon('gg_gladiator')
    gg_gladiator.setDisplayName('GG Gladiator')
    gg_gladiator.loadTranslationFile()
    es.stringtable('downloadables', 'sound/gungame/gg_gladiator/gladdiewithhonor.wav')
    es.stringtable('downloadables', 'sound/gungame/gg_gladiator/gladkill.wav')
    es.stringtable('downloadables', 'sound/gungame/gg_gladiator/gladcrowd1.wav')
    es.stringtable('downloadables', 'sound/gungame/gg_gladiator/gladcrowdcheer.wav')
    knife_level = gungamelib.getTotalLevels()
    load_bot_levels()
    db.execute("CREATE TABLE IF NOT EXISTS [UserStats] ([SteamID]VARCHAR(30) UNIQUE NOT NULL,[Name]VARCHAR(30),[Maps]INT,[Glads]INT,[Wins]INT,[Win_Ratio]FLOAT,[LastConnect]VARCHAR(30))")
    if not es.exists('saycommand', '!gladstats'):
        es.regsaycmd('!gladstats', 'gungame/custom_addons/gg_gladiator/gladstats', 'Say command for displaying the stats')
    if not es.exists('saycommand', '!gladranks'):
        es.regsaycmd('!gladranks', 'gungame/custom_addons/gg_gladiator/gladranks', 'Say command for displaying the ranks')

    stats = db.query("SELECT * FROM UserStats")
    for line in stats:
        glad_stats[line[0]] = (line[2],line[3],line[4],line[5],line[1],line[6])
    repeat.create('crowd', playcrowdsound, ())
    reset_game()
 
def unload():
    repeat.delete('crowd')
    es.unregisterClientCommandFilter(specfilter)
    gungamelib.unregisterAddon('gg_gladiator')
    if es.exists('saycommand', '!gladstats'):
        es.unregsaycmd('!gladstats')
    if es.exists('saycommand', '!gladranks'):
        es.unregsaycmd('!gladranks')
    db.close()

@es.addons.registerClientCommandFilter
def specfilter(userid, args):
    uid = playerlib.uniqueid(userid)
    team = args[1] if len(args) >= 2 else 2
    team = str(team)
    if uid not in gPlayers:
        return True
    if args[0] == 'jointeam' and team != '1':
        gungamelib.msg('gg_gladiator', userid, 'Spectate')
        return False
    return True


   
def unload():
    gungamelib.unregisterAddon('gg_gladiator')
    es.addons.unregisterClientCommandFilter(specfilter)

db = connection(es.ServerVar("eventscripts_gamedir")  + '/addons/eventscripts/gungame/custom_addons/gg_gladiator/gladstats.db')

def reset_game():
    playerlist = playerlib.getPlayerList('#all')
    for player in playerlist:
        player_userid = int(player)
        reset_player(player_userid)
    es.server.cmd("es_set mp_restartgame 1")
   
def es_map_start(event_var):
    repeat.stop('crowd')
    global first_t_knifer, first_ct_knifer, one_v_one_mode
    first_t_knifer = 0
    first_ct_knifer = 0
    gPlayers.clear()
    nsPlayers.clear()
    es.stringtable('downloadables', 'sound/gungame/gg_gladiator/gladdiewithhonor.wav')
    es.stringtable('downloadables', 'sound/gungame/gg_gladiator/gladkill.wav')
    es.stringtable('downloadables', 'sound/gungame/gg_gladiator/gladcrowd1.wav')
    es.stringtable('downloadables', 'sound/gungame/gg_gladiator/gladcrowdcheer.wav')
    one_v_one_mode = 0

def player_activate(event_var):
    userid = event_var['userid']
    reset_player(userid)
    if (one_v_one_mode == 1):
        uid = playerlib.uniqueid(userid)
        gPlayers.add(uid)



def player_death(event_var):
    if (one_v_one_mode == 1):
        if (int(event_var['attacker']) == 0):
            if (int(es.getplayerteam(event_var['userid'])) == 2):
                gungamePlayer = gungamelib.getPlayer(first_ct_knifer)
                userid = first_ct_knifer
            else:
                gungamePlayer = gungamelib.getPlayer(first_t_knifer)
                userid = first_t_knifer
            gungamePlayer.levelup(1, userid, 'kill')
       
def player_hurt(event_var):
    if (one_v_one_mode == 1):
        es.emitsound('player', event_var['userid'], 'gungame/gg_gladiator/gladcrowd1.wav', 1, 0)
        if (int(event_var['es_userteam']) == 2):
            tplayer = playerlib.getPlayer(event_var['userid'])
            ctplayer = playerlib.getPlayer(event_var['attacker'])
        else:
            ctplayer = playerlib.getPlayer(event_var['userid'])
            tplayer = playerlib.getPlayer(event_var['attacker'])
        gungamelib.msg('gg_gladiator', '#all', 'Health_Message', {'ctName': ctplayer.attributes['name'], 'ctHealth': str(ctplayer.get('health')), 'tName': tplayer.attributes['name'], 'tHealth': str(tplayer.get('health'))})
       
def player_spawn(event_var):
    if (one_v_one_mode == 1):
        userid = event_var['userid']
        if es.isbot(userid):
            gungamePlayer = gungamelib.getPlayer(userid)
            if (gungamePlayer['level'] != knife_level):
                gungamePlayer.level = knife_level


def gg_levelup(event_var):
    global first_t_knifer, first_ct_knifer
    if int(event_var['old_level']) != gungamelib.getTotalLevels():
        newLevel = int(event_var['new_level'])
        if gungamelib.getLevelWeapon(newLevel) == 'knife':
            killerteam = int(event_var['es_attackerteam'])
            if first_t_knifer == 0 and first_ct_knifer == 0:
                if killerteam == 2:
                    #es.centermsg(event_var['es_attackername'] + " is First T Gladiator")
                    gungamelib.centermsg('gg_gladiator', '#all', 'First_T_Gladiator', {'tName': event_var['es_attackername']})
                    gungamelib.msg('gg_gladiator', '#all', 'First_T_Gladiator', {'tName': event_var['es_attackername']})
                    first_t_knifer = int(event_var['attacker'])
                elif killerteam == 3:
                    es.centermsg(event_var['es_attackername'] + " is First CT Gladiator")
                    gungamelib.centermsg('gg_gladiator', '#all', 'First_CT_Gladiator', {'ctName': event_var['es_attackername']})
                    gungamelib.msg('gg_gladiator', '#all', 'First_CT_Gladiator', {'ctName': event_var['es_attackername']})
                    first_ct_knifer = int(event_var['attacker'])
            elif ((first_t_knifer == 0) and (first_ct_knifer > 0) and (killerteam == 2)):
                first_t_knifer = int(event_var['attacker'])
                gamethread.delayed(.1, do_gladiator, (first_t_knifer, first_ct_knifer))
            elif ((first_t_knifer > 0) and (first_ct_knifer == 0) and (killerteam == 3)):
                first_ct_knifer = int(event_var['attacker'])
                gamethread.delayed(.1, do_gladiator, (first_t_knifer, first_ct_knifer))
       
       
def do_gladiator(first_t_knifer, first_ct_knifer):
    global gPlayers, one_v_one_mode, win_sound,nsPlayers
    if (es.ServerVar('bot_quota') > 0):
        if ((es.isbot(first_t_knifer) and not es.isbot(first_ct_knifer)) or not (es.isbot(first_t_knifer) and es.isbot(first_ct_knifer))):
            es.server.cmd("es_set bot_quota 1")
        elif (not es.isbot(first_t_knifer) and not es.isbot(first_ct_knifer)):
            es.server.cmd("es_set bot_quota 0")
        elif (es.isbot(first_t_knifer) and es.isbot(first_ct_knifer)):
            es.server.cmd("es_set bot_quota 2")
            es.server.cmd("es_set bot_join_after_player 0")
            es.server.cmd("es_set bot_quota_mode fill")
    one_v_one_mode = 1
    win_sound = gungamelib.getSound('winner')
    tplayer=playerlib.getPlayer(first_t_knifer)
    tplayer.set('health', 100)
    tplayer.set('armor', 100)
    ctplayer=playerlib.getPlayer(first_ct_knifer)
    ctplayer.set('health', 100)
    ctplayer.set('armor', 100)
    gungamelib.msg('gg_gladiator', '#all', 'T_Gladiator', {'tName': tplayer.attributes['name']})
    gungamelib.msg('gg_gladiator', '#all', 'CT_Gladiator', {'ctName': ctplayer.attributes['name']})
    playerlist = playerlib.getPlayerList('#all')
    for player in playerlist:
        player_userid = int(player)
        uid = playerlib.uniqueid(player_userid)
        if player_userid != first_t_knifer and player_userid != first_ct_knifer:
            if uid == 'BOT':
                playerlib.getPlayer(player_userid).kick('No Bots in 1 vs 1')
    for player in playerlist:
        player_userid = int(player)
        uid = playerlib.uniqueid(player_userid)
        gamethread.delayed(1.2, es.playsound, (player_userid,'gungame/gg_gladiator/gladdiewithhonor.wav', 1))
        if player_userid != first_t_knifer and player_userid != first_ct_knifer:
            gPlayers.add(uid)
            if (int(es.getplayerteam(player_userid)) > 1 and uid != 'BOT'):
                nsPlayers.add(uid)
            es.changeteam(player_userid, 1)
    gungamelib.centermsg('gg_gladiator', '#all', 'Glad_Mode')
    gungamelib.msg('gg_gladiator', '#all', 'Glad_Mode')
    repeat.start('crowd', 6.27, 50)
   
def gg_win(event_var):
    if repeat.status('crowd') > 1:
        repeat.stop('crowd')
    playerlist = playerlib.getPlayerList('#all')
    for player in playerlist:
        player_userid = int(player)
        steamid = es.getplayersteamid(player_userid)
        if (player_userid == int(event_var['winner'])):
            winner_steam = steamid
        if ((player_userid == first_t_knifer or player_userid == first_ct_knifer) and steamid != 'BOT'):
            add_glad(steamid)
            if (steamid != 'BOT'):
                add_map(steamid)
    for steamid in nsPlayers:
        add_map(steamid)
    if (one_v_one_mode == 1):
        gamethread.delayed(.2, play_final, event_var['winner'])
        if (winner_steam != 'BOT'):
            add_win(winner_steam)
    top_ten()

def play_final(winner):
    playerlist = playerlib.getPlayerList('#all')
    for player in playerlist:
        player_userid = int(player)
        es.stopsound(player_userid, win_sound)
    gamethread.delayed(1.6,es.emitsound, ('player', winner, 'gungame/gg_gladiator/gladkill.wav', 1, 0))

def parse_botprofile():
    botlevels = {}
    fp = open(xaskins_skinfiles_path + skinnames[i] +".txt")
    for line in fp:
        line = line.strip("\n")
        line = line.strip("\r")
        if line[0:1] == '"':
            skinfile = line[findsplit(line)+1:len(line)]
            skinname = line[0:findsplit(line)]
            skinname = skinname.strip('"')
            skinmodel = makedownloadable(skinfile,skinnames[i])
            skinlist[skinnames[i]][skinname] = skinmodel

def load_bot_levels():
    global elite, expert, veryhard, hard, tough, normal, fair, easy
    one_v_one_only = es.ServerVar('1_vs_1_only')
    elite = int(float(es.ServerVar('gg_glad_elite'))/100 * knife_level)
    expert = int(float(es.ServerVar('gg_glad_expert'))/100 * knife_level)
    veryhard = int(float(es.ServerVar('gg_veryhard_elite'))/100 * knife_level)
    hard = int(float(es.ServerVar('gg_glad_hard'))/100 * knife_level)
    tough = int(float(es.ServerVar('gg_glad_tough'))/100 * knife_level)
    normal = int(float(es.ServerVar('gg_glad_normal'))/100 * knife_level)
    fair = int(float(es.ServerVar('gg_glad_fair'))/100 * knife_level)
    easy = int(float(es.ServerVar('gg_glad_easy'))/100 * knife_level)
    if (elite == 0): elite = 1
    if (expert == 0): expert = 1
    if (veryhard == 0): veryhard = 1
    if (hard == 0): hard = 1
    if (tough == 0): tough = 1
    if (normal == 0): normal = 1
    if (fair == 0): fair = 1
    if (easy == 0): easy = 1
    fp = open(botprofile)
    for line in fp:
        if ("Elite" in line and "Template" not in line):
            bot_start_levels[line.split()[1]] = elite
        if ("Expert" in line and "Template" not in line):
            bot_start_levels[line.split()[1]] = expert
        if ("VeryHard" in line and "Template" not in line):
            bot_start_levels[line.split()[1]] = veryhard
        if ("Hard" in line and "Template" not in line and "VeryHard" not in line):
            bot_start_levels[line.split()[1]] = hard
        if ("Tough" in line and "Template" not in line):
            bot_start_levels[line.split()[1]] = tough
        if ("Normal" in line and "Template" not in line):
            bot_start_levels[line.split()[1]] = normal
        if ("Fair" in line and "Template" not in line):
            bot_start_levels[line.split()[1]] = fair
        if ("Easy" in line and "Template" not in line):
            bot_start_levels[line.split()[1]] = easy
   
def add_map(steamid):
    maps = glad_stats[steamid][0]
    maps = int(maps) + 1
    glad_stats[steamid] = (maps,glad_stats[steamid][1],glad_stats[steamid][2])
    db.execute("UPDATE UserStats SET Maps='%s' WHERE SteamID='%s'" % (maps, steamid))

def add_glad(steamid):
    glads = glad_stats[steamid][1]
    glads = int(glads) + 1
    wins = glad_stats[steamid][2]
    win_ratio = float(wins)/float(glads)
    glad_stats[steamid] = (glad_stats[steamid][0],glads,glad_stats[steamid][2])
    db.execute("UPDATE UserStats SET Glads='%s' WHERE SteamID='%s'" % (glads, steamid))
    db.execute("UPDATE UserStats SET Win_Ratio='%s' WHERE SteamID='%s'" % (win_ratio, steamid))

def add_win(steamid):
    wins = glad_stats[steamid][2]
    glads = glad_stats[steamid][1]
    wins = int(wins) + 1
    win_ratio = float(wins)/float(glads)
    glad_stats[steamid] = (glad_stats[steamid][0],glad_stats[steamid][1],wins)
    db.execute("UPDATE UserStats SET Wins='%s' WHERE SteamID='%s'" % (wins, steamid))
    db.execute("UPDATE UserStats SET Win_Ratio='%s' WHERE SteamID='%s'" % (win_ratio, steamid))

def playcrowdsound():
    playerlist = playerlib.getPlayerList('#human')
    for player in playerlist:
        player_userid = int(player)
        es.playsound(player_userid,'gungame/gg_gladiator/gladcrowdcheer.wav', 0.25)
       

def reset_player(userid):
    steamid = es.getplayersteamid(userid)
    name = es.getplayername(userid)
    gungamePlayer = gungamelib.getPlayer(userid)
    if (steamid != 'BOT'):
        gungamelib.msg('gg_gladiator', userid, 'Gladiator_Loaded')
        stats = db.query("SELECT * FROM UserStats WHERE SteamID='%s'" % steamid)
        if not stats:
            db.execute("INSERT INTO UserStats ('SteamID', 'Name', 'Maps', 'Glads', 'Wins', 'Win_Ratio', 'LastConnect') VALUES ('%s', '%s', 0, 0, 0, 0, '%s')" % (steamid, name, datetime.date.today()))
            glad_stats[steamid] = (0,0,0,0.0,name,datetime.date.today())
        else:
            db.execute("UPDATE UserStats SET LastConnect='%s' WHERE SteamID='%s'" % (datetime.date.today(), steamid))
            glad_stats[steamid] = (stats[0][2],stats[0][3],stats[0][4],stats[0][5],name,datetime.date.today())
    if (one_v_one_only != 1):
        if es.isbot(userid):
            # The following line removes the Bot Prefix from the Bot's name so we can get their level
            bot_name = name
            if (es.ServerVar('bot_prefix') != ''):
                bot_name = name.split(str(es.ServerVar('bot_prefix')))[1].strip()
            newlevel = int(bot_start_levels[bot_name])
            gungamePlayer.level = newlevel
            myPlayer_level = gungamePlayer['level']
        else:
            if steamid not in glad_stats.keys():
                newlevel = int(knife_level/2)
                gungamePlayer.level = newlevel
            else:
                if (int(glad_stats[steamid][0]) < 1):
                    stat = 0.0
                else:
                    stat = float(glad_stats[steamid][1]) / float(glad_stats[steamid][0])
                gc1 = ((float(knife_level)/2) + 1) - ((float(knife_level)/2) * 2 * stat)
                if (gc1 < 1): gc1 = 1
                if (float(glad_stats[steamid][1]) != 0):
                    win_ratio = float(glad_stats[steamid][2]) / float(glad_stats[steamid][1])
                else:
                    win_ratio = 0.0
                if (win_ratio > 0.4999999):
                    gc2 = gc1 + (gc1/1.22 * win_ratio)
                else:
                    gc2 = gc1
                newlevel = int(gc2)
                gungamePlayer.level = newlevel
                gungamelib.msg('gg_gladiator', userid, 'Your_Stats', {'maps': glad_stats[steamid][0], 'glads': glad_stats[steamid][1], 'wins': glad_stats[steamid][2], 'win_ratio': round(win_ratio,3), 'level': newlevel})

 
def gladranks():
    userid = es.getcmduserid()
    buildRanksMenu(userid)
    popuplib.send('gladRanksMenu', userid)
 
 
def gladstats():
    userid = es.getcmduserid()
    steamid = es.getplayersteamid(userid)
    line = db.query("SELECT * FROM UserStats WHERE SteamID='%s'" % steamid)[0]
    if (int(glad_stats[steamid][0]) < 1):
        stat = 0.0
    else:
        stat = float(glad_stats[steamid][1]) / float(glad_stats[steamid][0])
    gc1 = ((float(knife_level)/2) + 1) - ((float(knife_level)/2) * 2 * stat)
    if (gc1 < 1): gc1 = 1
    if (float(glad_stats[steamid][1]) != 0):
        win_ratio = float(glad_stats[steamid][2]) / float(glad_stats[steamid][1])
    else:
        win_ratio = 0.0
    if (win_ratio > 0.4999999):
        gc2 = gc1 + (gc1/1.22 * win_ratio)
    else:
        gc2 = gc1
    newlevel = int(gc2)
    gungamelib.msg('gg_gladiator', userid, 'Your_Stats', {'maps': glad_stats[steamid][0], 'glads': glad_stats[steamid][1], 'wins': glad_stats[steamid][2], 'win_ratio': round(win_ratio,3), 'level': newlevel})

def buildRanksMenu(userid):
    # Un-send and delete the menu
    pname = es.getplayername(userid)
    if popuplib.exists('gladRanksMenu'):
        popuplib.unsendname('gladRanksMenu', playerlib.getUseridList('#human'))
        popuplib.delete('gladRanksMenu')
   
    # Get stats
    stats = db.query("SELECT * FROM UserStats ORDER BY Win_Ratio DESC LIMIT 10")
   
    # Create the "gladRanksMenu" popup
    gladRanksMenu = popuplib.create('gladRanksMenu')
    gladRanksMenu.addline('#  Win Ratio      Name')
    # Add ranks
    index = 1
    for line in stats:
        if pname == line[1]:
            gladRanksMenu.addline('->%s    %s             %s' % (str(index), str(round(line[5],3)), line[1]))
        else:
            gladRanksMenu.addline('%s    %s             %s' % (str(index), str(round(line[5],3)), line[1]))
        index += 1
   
    # Finish off the menu
    gladRanksMenu.addline('----------------------------------------')
    gladRanksMenu.addline('0. Exit')
    gladRanksMenu.timeout('send', 5)
    gladRanksMenu.timeout('view', 5)

# Thanks to GodJonez for this snippet of code to handle UTF-8
def utfcode(value):
    """ converts value into utf-8 coded string if it is unicode, otherwise returns the value itself """
    if type(value).__name__ == 'unicode':
        return value.encode('utf-8')
    return value

def convertQuery(result):
    """ converts all unicode strings in a full SQLite query result to utf-8 string objects """
    newresult = list()
    for row in result:
        newrow = [utfcode(item) for item in row]
        newresult.append(newrow)
    return newresult
   
def top_ten():
    global topten
    stats = db.query("SELECT * FROM UserStats ORDER BY Win_Ratio DESC LIMIT 10")
    topten.append("Steam ID,Name,Maps,Glads,Wins,Win Ratio \n")
    for line in stats:
        p = str(line[0])+ "," + str(line[1])+ "," + str(line[2])+ "," + str(line[3]) + "," + str(line[4]) + "," + str(line[5]) + "\n"
        topten.append(p)
    file = open(gg_gladtoptenfile, "w")
    b = file.writelines(topten)
    file.close()
    topten = [][[
Aclinoe

Private
Private
User avatar
 
Posts: 9
Joined: Sat Jun 20, 2009 10:59 pm
Steam Friends Name: Aclinoe
Xfire Name: Aclinoe

Postby Don » Mon Jun 29, 2009 12:31 am

I'll be darned.

On line 295 change this line:

   one_v_one_only = es.ServerVar('1_vs_1_only')
 
to this

   one_v_one_only = es.ServerVar('glad_1_vs_1_only')
 
and see if that fixes the issue.
Don

Site Admin
Site Admin
User avatar
 
Posts: 529
Joined: Fri Sep 05, 2008 3:05 am
Location: The Valley
Steam Friends Name: Don
Xfire Name: donlafferty

Re: gg_gladiator(1 Vs 1 Knife)

Postby Aclinoe » Mon Jun 29, 2009 4:29 pm

I did as you instructed but ended with the same results. New players get levels 14 to 12. I really like this addon and want it in my server. The server feels Incomplete without it. I have pm'd you and attached the py file right from my server
Aclinoe

Private
Private
User avatar
 
Posts: 9
Joined: Sat Jun 20, 2009 10:59 pm
Steam Friends Name: Aclinoe
Xfire Name: Aclinoe

Next


Return to Downloads

Who is online

Users browsing this forum: No registered users and 1 guest

cron