is somebody able to help me out there?

Installation support, coding tips, and general tutorials.
4 posts Page 1 of 1 First unread post
Dr.Morphman
Scripter
Scripter
Posts: 73
Joined: Sun Feb 24, 2013 9:55 am


i have tried to write a script enabling to change ones name in-game
it actualy works without any complaints
however, if you change your name and join the server with a second client , the server suddenly crashes and i canot think of any reason why that happens therefore i would ask if someone knows a solution to this problem or means to avoid it from occuring

here is the script:
Code: Select all
from commands import name, get_player, add, admin, alias, add
from pyspades.server import *

@alias('nick')  
def ingamenamechange(self, *args):
    if self.hp == None and self.team.id != -1: return 'You canot change your name while being dead.'
    dat_name = ''
    old_name = self.name
    for kitten in range(len(args)):
        if kitten == len(args)-1: dat_name += str(args[kitten])
        else: dat_name += (str(args[kitten]) + ' ')
    if len(dat_name) > 15 : return 'Your name must contain less than 15 characters!'
    elif len(dat_name) <= 0: return 'Your name must consist of at least one character!'
    self.name = dat_name
    self.world_object.name = dat_name
    self.printable_name = dat_name
    player_left.player_id = self.player_id
    self.protocol.send_contained(player_left)
    create_player.player_id = self.player_id
    create_player.weapon = self.weapon
    create_player.team = self.team.id
    create_player.name = dat_name
    self.protocol.send_contained(create_player)
    self.kill()
    self.protocol.irc_say(old_name + " has been renamed to " + dat_name)
    return old_name + " has been renamed to " + dat_name
add(ingamenamechange)


def apply_script(protocol, connection, config):
    return protocol, connection
and the full error:
Code: Select all
Traceback (most recent call last):
   File "pyspades\protocol.pyo", line 165, in update
   File "run.py", line 885, in data_received
   File "pyspades\protocol.pyo", line 117, in data_received
   File "pyspades\server.pyo", line 249, in loader_received
   File "pyspades\types.pyo", line 110, in __setitem__
 KeyError: 'key Dr.Morphman already exists'
 Unhandled error in Deferred:
 Unhandled Error
	Traceback (most recent call last):
	  File "twisted\internet\base.pyo", line 1162, in run
	    
	  File "twisted\internet\base.pyo", line 1171, in mainLoop
	    
	  File "twisted\internet\base.pyo", line 793, in runUntilCurrent
	    
	  File "twisted\internet\task.pyo", line 194, in __call__
	    
	--- <exception caught here> ---
	  File "twisted\internet\defer.pyo", line 133, in maybeDeferred
	    
	  File "pyspades\server.pyo", line 1588, in update
	    
	  File "pyspades\server.pyo", line 1594, in update_network
	    
	exceptions.AttributeError: 'NoneType' object has no attribute 'dead'
anyone got an idea? (i know its not something of great use, im just asking out of curiosity)
Last edited by Dr.Morphman on Thu Feb 06, 2014 8:54 pm, edited 1 time in total.
learn_more
Coder
Coder
Posts: 891
Joined: Sun Mar 24, 2013 9:59 pm


you did not change the name everywhere :)

in some places the old name is still in use, but not in the places where it's checked when joining.
so it thinks the name is free, tries to use it in another place to store the user but fails because you are still using the old name there.
Dr.Morphman
Scripter
Scripter
Posts: 73
Joined: Sun Feb 24, 2013 9:55 am


aah i assume that was meant with 'key Dr.Morphman already exists'
alright thanks for the hint man, with that information i might be able to find a solution
(if not, i recommend everyone who wants to use that script to set their max ip connections to 1)
learn_more
Coder
Coder
Posts: 891
Joined: Sun Mar 24, 2013 9:59 pm


start at:
File "pyspades\protocol.pyo", line 165, in update
4 posts Page 1 of 1 First unread post
Return to “Help!”

Who is online

Users browsing this forum: No registered users and 8 guests