Note: This forum is merely an archive. It is no longer possible to register or post. - StackOverflow
New Ace of Spades Forums: http://buildandshoot.com/

smgsucks.py - Forbids SMG from being selected on a server

Finished a script? Pop it in here.

smgsucks.py - Forbids SMG from being selected on a server

Postby GreaseMonkey » Tue Jul 17, 2012 11:31 am

This script bans SMG from the server by making it unselectable, and forwarding the player to the rifle. This is the script we've all been waiting for.

Tested with the 0.76 branch of pyspades, on a local network with 2 players (me and me). Assumed to work on 0.75, but not confirmed.

Download it from Gist: smgsucks.py (click the Download button on the page, or the "raw" link if you prefer)
GreaseMonkey
Bastion Member
 
Posts: 84
Joined: Tue Dec 13, 2011 10:14 pm
Location: ←        

Re: smgsucks.py - Forbids SMG from being selected on a serve

Postby DUHsoALEX » Tue Jul 17, 2012 11:35 am

Would people be allowed to use the shotgun?
DUHsoALEX
Member
 
Posts: 251
Joined: Tue Jan 10, 2012 12:59 am

Re: smgsucks.py - Forbids SMG from being selected on a serve

Postby kmaj » Tue Jul 17, 2012 11:44 am

Thank you very much!
Now somebody could host a real trench warfare server.
User avatar
kmaj
[FF] Leader
 
Posts: 1786
Joined: Tue Feb 21, 2012 12:37 pm
Location: supprising

Re: smgsucks.py - Forbids SMG from being selected on a serve

Postby GreaseMonkey » Tue Jul 17, 2012 12:16 pm

DUHsoALEX wrote:Would people be allowed to use the shotgun?


Yes. But if you'd prefer to ban that too, um, learn some Python (the "in" operator would be useful here).
GreaseMonkey
Bastion Member
 
Posts: 84
Joined: Tue Dec 13, 2011 10:14 pm
Location: ←        

Re: smgsucks.py - Forbids SMG from being selected on a serve

Postby ReubenMcHawk » Tue Jul 17, 2012 10:21 pm

I love you, Grease.
User avatar
ReubenMcHawk
Member
 
Posts: 541
Joined: Sat Dec 10, 2011 8:15 pm
Location: Ethiopia

Re: smgsucks.py - Forbids SMG from being selected on a serve

Postby xNyan » Sat Jul 21, 2012 9:48 pm

Because they will make this update from 0.76? The SMG was perfect, now at 0.76 this sucks
User avatar
xNyan
Member
 
Posts: 82
Joined: Mon Mar 26, 2012 7:32 pm

Re: smgsucks.py - Forbids SMG from being selected on a serve

Postby kmaj » Sat Jul 21, 2012 9:51 pm

xNyan wrote:Because they will make this update from 0.76? The SMG was perfect, now at 0.76 this sucks

It's just a script...
User avatar
kmaj
[FF] Leader
 
Posts: 1786
Joined: Tue Feb 21, 2012 12:37 pm
Location: supprising

Re: smgsucks.py - Forbids SMG from being selected on a serve

Postby Aeroclaw » Sat Jul 21, 2012 9:54 pm

I LOVE YOU GREASE.
too bad I don't run a server because I don't know how to.
User avatar
Aeroclaw
Member
 
Posts: 841
Joined: Mon Jun 04, 2012 2:39 am
Location: I live 20 miles away from NIASKA and Scum in Zing Zong Ming Mong Ling Long...

Re: smgsucks.py - Forbids SMG from being selected on a serve

Postby LinktersHD » Mon Jul 23, 2012 5:14 pm

Ha ha nice script Grease will be using this script on a server i am playing to do called "Sniper Wars".
Nuketown map is out!:
viewtopic.php?f=67&t=11021]

Image
Image
User avatar
LinktersHD
Member
 
Posts: 1356
Joined: Fri Mar 30, 2012 2:41 pm
Location: Reigate, England

Re: smgsucks.py - Forbids SMG from being selected on a serve

Postby LinktersHD » Mon Jul 23, 2012 5:15 pm

Also another thing.
What is the other code for the other weapons like this one:
Code: Select all
weapon = RIFLE_WEAPON
Nuketown map is out!:
viewtopic.php?f=67&t=11021]

Image
Image
User avatar
LinktersHD
Member
 
Posts: 1356
Joined: Fri Mar 30, 2012 2:41 pm
Location: Reigate, England

Re: smgsucks.py - Forbids SMG from being selected on a serve

Postby LinktersHD » Mon Jul 23, 2012 7:00 pm

GreaseMonkey the only problem with the script that it spams the chat.
I made it so it sends it to the player who is trying to use that weapon.
Here is the code:
Code: Select all
"""
Disables the SMG

Author: GreaseMonkey, LinktersHD

Public Domain
"""

from pyspades.constants import *

def apply_script(protocol, connection, config):
    class SMGSucksConnection(connection):
        def on_weapon_set(self, wpnid):
            if wpnid == SMG_WEAPON:
                self.send_chat("SMG forbidden on this server because it sucks")
                return False
            return connection.on_weapon_set(self, wpnid)
        def set_weapon(self, weapon, local = False, no_kill = False, *args, **kwargs):
            if weapon == SMG_WEAPON:
                self.send_chat("You've been given a real gun (Rifle)")
                self.send_chat("SMG forbidden on this server because it sucks")
                weapon = RIFLE_WEAPON
                if local:
                   no_kill = True
                   local = False
            return connection.set_weapon(self, weapon, local, no_kill, *args, **kwargs)
   
    return protocol, SMGSucksConnection
Nuketown map is out!:
viewtopic.php?f=67&t=11021]

Image
Image
User avatar
LinktersHD
Member
 
Posts: 1356
Joined: Fri Mar 30, 2012 2:41 pm
Location: Reigate, England

Re: smgsucks.py - Forbids SMG from being selected on a serve

Postby PXYC » Mon Jul 23, 2012 7:11 pm

Instead of self.protocol.send_chat()
self.send_chat()
Image

<+laserlamp> lil b is my fav
User avatar
PXYC
Local Mod
 
Posts: 1068
Joined: Wed Dec 14, 2011 2:52 am
Location: Near Philadelphia, PA

Re: smgsucks.py - Forbids SMG from being selected on a serve

Postby LinktersHD » Mon Jul 23, 2012 7:25 pm

Is there a slight difference on what you use?
Nuketown map is out!:
viewtopic.php?f=67&t=11021]

Image
Image
User avatar
LinktersHD
Member
 
Posts: 1356
Joined: Fri Mar 30, 2012 2:41 pm
Location: Reigate, England

Re: smgsucks.py - Forbids SMG from being selected on a serve

Postby Danke » Tue Jul 24, 2012 6:42 am

LinktersHD wrote:Is there a slight difference on what you use?

major difference
self.send_chat() sends a message to the player
self.protocol.send_chat() sends a message to the whole server
User avatar
Danke
Member
 
Posts: 73
Joined: Thu Jan 12, 2012 3:27 am

Re: smgsucks.py - Forbids SMG from being selected on a serve

Postby LinktersHD » Tue Jul 24, 2012 6:50 am

Danke wrote:
LinktersHD wrote:Is there a slight difference on what you use?

major difference
self.send_chat() sends a message to the player
self.protocol.send_chat() sends a message to the whole server

And what might that be?
Nuketown map is out!:
viewtopic.php?f=67&t=11021]

Image
Image
User avatar
LinktersHD
Member
 
Posts: 1356
Joined: Fri Mar 30, 2012 2:41 pm
Location: Reigate, England

Next

Return to Script releases



Who is online

Users browsing this forum: No registered users and 4 guests

cron