Page 1 of 1
CmdManager and say commands
Posted: Fri Aug 30, 2013 8:22 pm
by arawra
Code: Select all
Caught an Exception:
TypeError: stats() takes 2 positional arguments but 3 were given
Code: Select all
from command_c import get_say_command
def load():
global cmdmanager
cmdmanager = get_say_command('!stats')
cmdmanager.add_callback(stats)
def stats(player, CICommand):
global player_database
Posted: Fri Aug 30, 2013 9:26 pm
by satoon101
Posted: Sat Aug 31, 2013 2:12 am
by arawra
Code: Select all
@SayCommand(['!stats', '!stat'])
def sayStats(playerinfo, teamonly, ccommand):
# some stuff for getting strings etc.
tell(playerinfo, 'String %s %s %s'%(string1, string2, string3))
def tell(player, msg=[]):
msg = '\x04[D&D] \x01%s'%msg
i = index_from_playerinfo(player)
m = messages.SayText2(index=i, chat=1, message=msg)
m.send(i)
From _libs\players\helpers.py Line 47
Code: Select all
return playerinfo.get_edict()
RuntimeError: Access violation - no RITI data!
Posted: Sat Aug 31, 2013 7:45 pm
by Omega_K2
This an odd error I've been getting too. Try replaceing
index_from_playerinfo
with
player.get_edict().get_index()
Posted: Sun Sep 01, 2013 1:26 am
by satoon101
That is very odd... That is exactly what index_from_playerinfo does. I will look into this issue when I have the time.
Satoon
Posted: Sun Sep 01, 2013 10:53 am
by satoon101
I cannot seem to reproduce this. Does this error always occur or just sometimes? Is the server Linux or Windows?
Satoon
Posted: Sun Sep 01, 2013 10:55 pm
by arawra
I'll try firing up the server again. This is on Windows 7.
A note, I did not register the previous command. I'll do that and see if thats what is causing the issue.
E: Looks like you dont need to register when using @SayCommand
Posted: Sun Sep 01, 2013 11:42 pm
by satoon101
Using the decorator class SayCommand automatically registers the command for you. In fact, all of the decorator classes in Source.Python automatically register and unregister the function that follows to the specific functionality. That is exactly what they are designed to do.
Satoon
Posted: Mon Sep 02, 2013 1:37 am
by Omega_K2
satoon101 wrote:I cannot seem to reproduce this. Does this error always occur or just sometimes? Is the server Linux or Windows?
Satoon
It's random. Though it might be more likely to happen if you pass it to other functions a bunch of timesm.
I read on the web it has something with variable going out of scope in python (getting garbage collected), and as such the C side then has some problems with accessing it.