Page 1 of 1
ServerExecute() question?
Posted: Wed Dec 19, 2012 9:35 pm
by Tuck
im trying to execute kickid <userid> [reason] and basicly my problem is that it wont allow a command string
how would i do this >_>
Posted: Wed Dec 19, 2012 10:40 pm
by Ayuto
I'm not sure if I understood you correctly. This doesn't work?
Syntax: Select all
from core import GameEngine
def kickid(userid, reason=''):
GameEngine.ServerCommand('kickid %s %s\n'% (userid, reason))
Posted: Thu Dec 20, 2012 3:50 am
by Tuck
Ayuto wrote:I'm not sure if I understood you correctly. This doesn't work?
Syntax: Select all
from core import GameEngine
def kickid(userid, reason=''):
GameEngine.ServerCommand('kickid %s %s\n'% (userid, reason))
nope that doesnt work :/
Posted: Thu Dec 20, 2012 4:09 am
by satoon101
It works fine for me... Not sure what your issue even "could" be if it truly doesn't work.
*Edit: this is the code I used to test:
Syntax: Select all
from core import GameEngine
from events import Event
@Event
def player_say(GameEvent):
userid = GameEvent.GetInt('userid')
reason = 'because i said so, ok?'
GameEngine.ServerCommand('kickid %s %s\n' % (userid, reason))
And note that the "\n" is very important, as without ending the line in
\n or
; the command will not execute. That is the only thing I think you could be doing wrong for it not to work. I guess the only other thing that I think could cause it is if you are using ServerExecute instead of ServerCommand.
Satoon
Posted: Thu Dec 20, 2012 4:13 am
by Tuck
thanks satoon actually i noticed the \n yesterday when you replied but i just forgot everything about the newline -.-, i feel stupid
Thanks
Posted: Wed Jan 30, 2013 1:12 am
by Logifl3x
Could someone please explain to me why the ending /n or ; is important?
Posted: Wed Jan 30, 2013 1:16 am
by satoon101
Well, first it is \n not /n. But, the command will not execute if it doesn't "end". You can also use other commands after \n or ; to execute multiple commands at once. I am not fully certain "why" that is, but it is.
Satoon
Posted: Wed Jan 30, 2013 6:17 am
by Logifl3x
Oh ok. Thank you for helping and fixing my mistake :P