kick player, send message

Please post any questions about developing your plugin here. Please use the search function before posting!
edcolmar
Junior Member
Posts: 21
Joined: Tue Oct 15, 2013 10:59 pm

kick player, send message

Postby edcolmar » Fri Dec 20, 2013 12:33 am

Hey Guys.

Thanks for all the help recently.

Could you give me code examples for:

how to kick a player from the server
how to send a text message to a player in the chat window

Thanks so much.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Fri Dec 20, 2013 1:51 am

For kicking:
http://www.sourcepython.com/showwiki.php?title=Wiki:CEngineServer#server_command

Syntax: Select all

from engine_c import CEngineServer

CEngineServer.server_command('kickid %s %s' % (userid, reason))


For SayText2 (chat area):
http://www.sourcepython.com/showwiki.php?title=Wiki:messages#SayText2

I'm not certain if that one works, though, as I never got around to testing the messaging system myself.

Satoon
Omega_K2
Senior Member
Posts: 227
Joined: Sat Jul 07, 2012 3:05 am
Location: Europe
Contact:

Postby Omega_K2 » Fri Dec 20, 2013 8:24 am

satoon101 wrote:For kicking:
http://www.sourcepython.com/showwiki.php?title=Wiki:CEngineServer#server_command

Syntax: Select all

from engine_c import CEngineServer

CEngineServer.server_command('kickid %s %s' % (userid, reason))


For SayText2 (chat area):
http://www.sourcepython.com/showwiki.php?title=Wiki:messages#SayText2

I'm not certain if that one works, though, as I never got around to testing the messaging system myself.

Satoon


server command needs to be terminated with a ; or \n as far as I renember, i.e.

Syntax: Select all

CEngineServer.server_command('kickid %s %s;' % (userid, reason))


Also SayText2 used to work on both engines, dunno whether any of the updates broke anything though. I posted a thread somewhere with the usermessages that don't.
Libraries: k2tools
Plugins (any): GSRPG (soon) | Pretty Status List | MySQLAds (soon)
Plugins (game-specific): None atm

If you happen to find a bug or need help, either post in the release threads or contact me in IRC gamesurge.net:6667 / #sourcepython
edcolmar
Junior Member
Posts: 21
Joined: Tue Oct 15, 2013 10:59 pm

Postby edcolmar » Fri Dec 20, 2013 6:34 pm

Working on kick...

both with and without the ";" I am seeing:

CEngineServer.server_command('kickid %s %s' % (userid, message))
Boost.Python.ArgumentError: Python argument types in
CEngineServer.server_command(str)
did not match C++ signature:
server_command(CEngineServer {lvalue}, char const* command)
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Fri Dec 20, 2013 6:56 pm

CEngineServer is the class object, but you need an instance of it.

Syntax: Select all

engine = engine_c.get_engine_interface()
engine.server_command('kickid %s %s;'% (userid, reason))
edcolmar
Junior Member
Posts: 21
Joined: Tue Oct 15, 2013 10:59 pm

Postby edcolmar » Fri Dec 20, 2013 7:30 pm

An error occurred importing SayText2. Is there a workaround for this?

[SP] Caught an Exception:
Traceback (most recent call last):
File '../addons/source-python/packages/source-python/addons/manager.py', line 48, in __missing__
instance = _LoadedAddon(addon_name)
File '../addons/source-python/packages/source-python/addons/manager.py', line 237, in __init__
self._addon = __import__(addon_name + '.' + addon_name)
File '../addons/source-python/plugins/leetcoin/leetcoin.py', line 44, in <module>
from messages import SayText2
File '../addons/source-python/packages/source-python/messages/__init__.py', line 9, in <module>
from paths import DATA_PATH


ImportError: cannot import name DATA_PATH
edcolmar
Junior Member
Posts: 21
Joined: Tue Oct 15, 2013 10:59 pm

Postby edcolmar » Fri Dec 20, 2013 7:38 pm

Thank you Ayuto. It is kicking now, but not displaying the reason, only giving a default reason.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Fri Dec 20, 2013 8:24 pm

Regarding the error: you have to change all DATA_PATH occurences to SP_DATA_PATH. Take a look at this revision. I'm currenctly not sure if it's included in the latest build.
edcolmar
Junior Member
Posts: 21
Joined: Tue Oct 15, 2013 10:59 pm

Postby edcolmar » Sat Dec 21, 2013 2:23 am

Thanks again Ayuto!

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 23 guests