Page 1 of 2

[SCRIPT] ammo

Posted: Wed Jun 05, 2013 3:12 pm
by thepolm3
This is a script to change and edit amunition of a player far beyond the usual limitations.
This+rapid=EPIC WIN
CODE:
Code: Select all
from pyspades.server import weapon_reload
from commands import add, admin, get_player

@admin
def reload(connection,*args):
    player=connection
    ammo=255
    clip=255
    try:
        if len(args)>2: player=get_player(args[2])
        if len(args)>0: ammo=int(args[0])
        if len(args)>1: clip=int(args[1])
    except Exception:
        return "Invalid, use /reload [ammo] [clip] [player]"
    player.set_ammo(int(ammo),int(clip))
    connection.refresh_ammo()
    return "Reloaded"

@admin
def ammo(connection):
    ammo=connection.ammo
    return "You have "+str(ammo[0])+" ammo and a clip of "+str(ammo[1])+"."

@admin
def autoreload(connection):
    connection.autoReload= not connection.autoReload
    connection.refresh_ammo()
    return "Auto reloading is "+["OFF","ON"][connection.autoReload]
   
add(reload)
add(ammo)
add(autoreload)
def apply_script(protocol, connection, config):
    
    class ammoConnection(connection):
        ammo=(0,0)
        autoReload=False
        
        def refresh_ammo(self):
            if self.autoReload:
                self.set_ammo(255,255)
            self.ammo=(self.weapon_object.current_ammo,self.weapon_object.current_stock)

        def on_reload(self):
            self.refresh_ammo()
            connection.on_reload(self)

        def on_spawn(self,pos):
            self.refresh_ammo()
            connection.on_spawn(self, pos)
    
        def on_shoot_set(self, fire):
            self.refresh_ammo()
            connection.on_shoot_set(self, fire)

        def on_refill(self):
            self.refresh_ammo()
            connection.on_refill(self)

        def on_input_update(self):
            self.refresh_ammo()
            connection.on_input_update(self)

        def set_ammo(self, new_ammo, new_stock=None):
            new_ammo=max(min(255,new_ammo),0)
            new_stock=max(min(255,new_stock),0)
            weapon=self.weapon_object
            weapon_reload.player_id = self.player_id
            weapon_reload.clip_ammo = weapon.current_ammo
            weapon.current_ammo = new_ammo
            if new_stock:
                weapon.current_stock = new_stock
            weapon_reload.reserve_ammo = weapon.current_stock
            self.send_contained(weapon_reload)
            self.ammo=(new_ammo,new_stock)
    
    return  protocol, ammoConnection

Have fun!

Re: [SCRIPT] ammo

Posted: Wed Jun 05, 2013 4:24 pm
by Vengeance
Cool! Blue_BigSmile

Re: [SCRIPT] ammo

Posted: Thu Jun 06, 2013 1:21 pm
by MrHaaax
We will have an LMG soon enough D:

Re: [SCRIPT] ammo

Posted: Thu Jun 06, 2013 8:40 pm
by TB_
So do you specify how much ammo you start with? Is it possible to start with even less than 10?

Re: [SCRIPT] ammo

Posted: Thu Jun 06, 2013 8:53 pm
by thepolm3
no, you can though. Would you like a script like that? This one is more of a building block for scripts that change ammo, /autoreload is cool. It makes it so that you don't need to reload, and it keeps your ammo at 255/255

Re: [SCRIPT] ammo

Posted: Fri Jun 07, 2013 7:54 am
by TB_
nah don't worrya bout that, BR_ probably already did it with his OIC mode:)

Re: [SCRIPT] ammo

Posted: Fri Jun 07, 2013 5:23 pm
by IceCream
THIS IS FUCKING AWESOME

SMG+Rapid+Autoreload=Happy happy joy joy

Re: [SCRIPT] ammo

Posted: Fri Jun 07, 2013 5:43 pm
by thepolm3
:D

Re: [SCRIPT] ammo

Posted: Sun Jun 09, 2013 11:21 am
by Kamikaze_Blargle
IceCraft wrote:
SMG+Rapid+Autoreload=Happy happy joy joy
Why on earth would you need SMG and Rapid? xD

Re: [SCRIPT] ammo

Posted: Wed Jun 19, 2013 9:33 am
by MaxyBlack
can some one create new download link ?

Re: [SCRIPT] ammo

Posted: Wed Jun 19, 2013 3:03 pm
by thepolm3
what's wrong with this one?

Re: [SCRIPT] ammo

Posted: Wed Jun 19, 2013 6:32 pm
by Venator
thepolm3 do you think you could turn the smg into an hmg with your superior scripting skills?

Re: [SCRIPT] ammo

Posted: Wed Jun 19, 2013 6:38 pm
by thepolm3
what do you mean by heavy machine gun?
technicly, i mean;
like faster fire & more damage?
Bigger clip and less damage?
What?

Re: [SCRIPT] ammo

Posted: Wed Jun 19, 2013 7:52 pm
by Venator
ok:
Slightly faster firing.
Really low damage (like 5hp for body and 10 for head?)
200 round clip.
Immense recoil.

Re: [SCRIPT] ammo

Posted: Sat Jun 22, 2013 9:00 am
by MrHaaax
Venator wrote:
ok:
Slightly faster firing.
Really low damage (like 5hp for body and 10 for head?)
200 round clip.
Immense recoil.
Actually here's how a HMG should be IMO:
Lower firerate.
Med-damage(lower than SMG's a bit)
200 rds and high recoil.