ServerExecute() question?

Please post any questions about developing your plugin here. Please use the search function before posting!
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

ServerExecute() question?

Postby Tuck » Wed Dec 19, 2012 9:35 pm

im trying to execute kickid <userid> [reason] and basicly my problem is that it wont allow a command string

how would i do this >_>
-Tuck
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Wed Dec 19, 2012 10:40 pm

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))
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Thu Dec 20, 2012 3:50 am

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 :/
-Tuck
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Thu Dec 20, 2012 4:09 am

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
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Thu Dec 20, 2012 4:13 am

thanks satoon actually i noticed the \n yesterday when you replied but i just forgot everything about the newline -.-, i feel stupid

Thanks
-Tuck
Logifl3x
Junior Member
Posts: 17
Joined: Sat Jul 07, 2012 3:53 am

Postby Logifl3x » Wed Jan 30, 2013 1:12 am

Could someone please explain to me why the ending /n or ; is important?
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Wed Jan 30, 2013 1:16 am

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
Logifl3x
Junior Member
Posts: 17
Joined: Sat Jul 07, 2012 3:53 am

Postby Logifl3x » Wed Jan 30, 2013 6:17 am

Oh ok. Thank you for helping and fixing my mistake :P

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 31 guests