MugMod

From EventScripts Community Encyclopedia

Example MugMod 2.0 script written in Python: mugmod/mugmod.py

# // ******************************
# // Mattie's MugMod v2.0
# //      for Counter-Strike: Source
# //
# // * Description:
# //      Any knife kill will steal the victim's money.
# //
# // * Install instructions:
# //       1. Copy mugmod.py and strings.ini to:
# //            cstrike/addons/eventscripts/mugmod
# //
# //       2. Add the following line somewhere in autoexec.cfg:
# //           es_load mugmod
# //
# // ******************************
import es
import langlib
import playerlib
import random
 
info = es.AddonInfo()
info.name     = "Mattie's Mugmod"
info.version  = "2.0"
info.url      = "http://addons.eventscripts.com/addons/view/mugmod"
info.basename = "mugmod"
info.author   = "Mattie"
 
 
# all MugMod server variables are declared here for convenience
mattie_mugmod     = es.ServerVar("mattie_mugmod",     1, "Enable/disable Mattie's MugMod")
mugmod_announce   = es.ServerVar("mugmod_announce",   1, "Announces MugMod each round.")
mugmod_taunt      = es.ServerVar("mugmod_taunt",      1, "Taunts the mugging victim with a random message.")
mugmod_percentage = es.ServerVar("mugmod_percentage", 100, "Percentage of money stolen during a mugging.")
mugmod_sounds     = es.ServerVar("mugmod_sounds",     1, "Enables kill sounds for MugMod")
mugmod_soundfile  = es.ServerVar("mugmod_soundfile",  "bot/owned.wav", "Sound played for a mugging if mugmod_sounds is 1")
 
text = None
 
def load():
    global text
    mattie_mugmod.makepublic()
    # load our strings
    text = langlib.Strings(es.getAddonPath("mugmod") + "/strings.ini")
 
def round_start(event_var):
  if mattie_mugmod > 0 and mugmod_announce > 0:
      es.msg("#multi", text("mugmod announcement"))
 
def player_death(event_var):
    if mattie_mugmod > 0:
        if event_var['weapon'] == "knife":
             # don't mug if they're on the same team.
             if event_var['es_attackerteam'] != event_var['es_userteam']:
                  victim = playerlib.getPlayer(event_var['userid'])
                  attacker = playerlib.getPlayer(event_var['attacker'])
                  # take money
                  killercash = attacker.get("cash")
                  victimcash = victim.get("cash")
                  muggedamount = (victimcash * mugmod_percentage) / 100
                  # complete the transaction
                  victim.set("cash", victimcash - muggedamount)
                  attacker.set("cash", killercash + muggedamount)
 
                  # build the tokens for string replacement
                  tokens = {}
                  tokens['attacker'] = attacker.get("name")
                  tokens['victim']   =   victim.get("name")
                  tokens['dollars']  = muggedamount
                 
                  # tell the victim
                  es.tell(victim, text("mugged notice", tokens, victim.get("lang")))
                  # tell the attacker
                  es.tell(attacker, text("mugger notice", tokens, attacker.get("lang")))
                 
                  # play sound
                  if mugmod_sounds > 0:
                      es.emitsound("player", int(attacker), str(mugmod_soundfile), 1, 0.6)
                 
                  if mugmod_taunt > 0:
                    # say message
                    if muggedamount <= 200:
                       es.sexec(attacker, "say %s" % text("poor victim"))
                    else:
                       # rich victim
                       choices = [x for x in text.keys() if x[0:8] == 'mugging:']
                       chosen = random.choice(choices)
                       es.sexec(attacker, "say %s" % text(chosen))
             else:
                if mugmod_taunt > 0:
                  # team knifer!
                  es.sexec(attacker, "say %s" % text("team mugger"))
 
 
# ******************************
#   END MUGMOD SCRIPT
# ****************************** 


mugmod/strings.ini

[mugmod announcement]
en="#green[MugMod]#default Mugging is enabled. Steal a player's money by killing them with a knife."
es="#green[MugMod]#default Mugging esta activo. Roba el dinero del enemigo cuando lo matas con tu cuchillo."
fi="#green[MugMod]#default Ryöstö on aktivoitu. Puukota vihollinen ja varasta rahat."
de="#green[MugMod]#default Mugging ist aktiviert. Klaue das Geld eines Spielers, in dem du ihn mit dem Messer tötest."
fr="#green[MugMod]#default est activé. Volez l'argent d'un joueur en le tuant au couteau." 
 
[poor victim]
en="[MUGGING] JUST GREAT. All that work and nothing to show for it."
es="[MUGGING] QUE BIEN. Tanto trabajo y nada me queda para demostrarlo."
fi="[MUGGING] MAHTAVAA. Kaikki se työ turhan takia."
de="[MUGGING] EINFACH TOLL. All die Arbeit und nichts dafür vor zu zeigen."
fr="[MUGGING] SIMPLEMENT FORMIDABLE. Autant de travail et rien à montrer."
 
[team mugger]
en="[MUG ATTEMPT] *** I'm a team back-stabber! ***"
es="[MUG ATTEMPT] *** ¡Le meto el cuchillo por la espalda as mi propia gente! ***"
fi="[MUG ATTEMPT] *** Olen joukkuepetturi! ***"
de="[MUG ATTEMPT] *** Ich ersteche mein eigenes Team ***"
fr="[MUG ATTEMPT] *** Je suis un traitre! ***"
 
[mugged notice]
en="[MugMod] You have been mugged by $attacker and lost $$$dollars."
es="[MugMod] $attacker te asalto y perdiste $$$dollars."
fi="[MugMod] $attacker ryösti sinulta $$$dollars."
de="[MugMod] Du wurdest von $attacker gemugged und verlierst $$$dollars."
fr="[MugMod] Tu as été découpé par $attacker et tu perds $$$dollars." 
 
[mugger notice]
en="[MugMod] You mugged $victim and stole $$$dollars."
es="[MugMod] Asaltaste a $victim y le robaste $$$dollars."
fi="[MugMod] Ryöstit uhrilta $victim $$$dollars."
de="[MugMod] Du hast $victim gemugged und erhälst $$$dollars."
fr="[MugMod] Tu as découpé $victim et tu lui as volé $$$dollars." 
 
[mugging:money or your life]
en="[MUGGING] Your money or your life. Well, I guess I'll take both."
es="[MUGGING] Tu dinero o tu vida. Bueno, te quito las dos."
fi="[MUGGING] Rahat vai henki. Taidan ottaa molemmat."
de="[MUGGING] Geld oder Leben. Gut, ich denke ich nehme beides."
fr="[MUGGING] La bourse ou la vie. Bien, je suppose que je vais prendre les deux." 
 
[mugging:won't need wallet]
en="[MUGGING] So I guess he's not going to be needing this wallet."
es="[MUGGING] Bueno parece que ya no necesita esta cartera."
fi="[MUGGING] Hän ei taida tarvita lompakkoaan."
de="[MUGGING] Ich denke, dass er die Brieftasche nicht brauch."
fr="[MUGGING] Je suppose qu'il n'aura pas besoin de cette valise." 
 
[mugging:can't take it with you]
en="[MUGGING] They say you can't take it with you."
es="[MUGGING] Dicen que no puedes llevartelo a la tumba."
fi="[MUGGING] Sanotaan, ettet voi ottaa sitä mukaasi."
de="[MUGGING] Sie sagen, dass du es nicht mit dir tragen kannst."
fr="[MUGGING] Ils disent que tu ne peux pas le prendre avec toi." 
 
[mugging:lunch money]
en="[MUGGING] Next time cough up the lunch money, loser."
es="[MUGGING] La proxima vez me das el dinero del almuerzo, marica."
fi="[MUGGING] Käytäs ensi kerralla lounasrahasi, luuseri."
de="[MUGGING] Nächstes mal hustest du das Essensgeld aus, Verlierer."
fr="[MUGGING] La prochaine fois craches l'argent du déjeuné, petit." 
 
[mugging:chaching]
en="[MUGGING] CHA-CHING!"
es="[MUGGING] CHA-CHING!"
fi="[MUGGING] CHA-CHING!"
de="[MUGGING] CHA-CHING!"
fr="[MUGGING] DECOUPE!" 
 
[mugging:easy come]
en="[MUGGING] Easy come, easy go."
es="[MUGGING] Asi de facil que biene, facil se va."
fi="[MUGGING] Helppo homma."
de="[MUGGING] Einfaches kommen und gehen."
fr="[MUGGING] Approche facile, départ facile." 
 
[mugging:money fool]
en="[MUGGING] A fool and his money are soon parted."
es="[MUGGING] Un tonto y su dinero se despiden rapido."
fi="[MUGGING] Typerys ja hänen rahansa erotetaan pian."
de="[MUGGING] Ein Idiot und sein Geld sind bald getrennt." 
fr="[MUGGING] Un imbécile et son argent vont bientôt être séparés."

See Also

blog comments powered by Disqus