Syntax: Select all
# sp core module
import sp_C # just a name for the C++ core, don't know what the name is, so let's assume it's sp_C
class Server(sp_C.Server):
def __call__(self, *args, **kwargs):
# assuming args[0] is a command-string, like 'say "Hello, World"', server-side
cmd = args[0]
if cmd:
sp_C.ServerCommand(cmd) # or ForceServerCommand or whatever
server = Server() # since this would make much sense
class Player(sp_C.Player):
def __call__(self, *args, **kwargs):
# assuming args[0] is a command-string, like 'say "Hello, World"', client-side
cmd = args[0]
if cmd:
ExecuteCommand(cmd) # assuming ExecuteCommand executes a command on the client's console, don't know what that one is named, sorry.
# [addon_load and stuff ....]
Now an example:
Syntax: Select all
import sp
from events.decorator import event
@event
def map_start(game_event):
sp.server('say "The server changed the map to %s"' % game_event.GetString("mapname"))
@event
def player_hurt(game_event):
player = sp.Player(game_event.GetInt("userid"))
player.AddHealth(140) # assuming that works :D
player("echo Added 140 health !!!")
Let me know what you think :)
EDIT: We can use a second argument for forcing the server-command, btw.