Scripting/Server/Events/onPlayerCommand
The player typed /cmd params. cmd has no slash and is passed as typed; params is the rest of the line (empty string if none). Split it with GetTok/NumTok.
Syntax
onPlayerCommand(player, cmd, params)Arguments
- Player player
- string cmd –
cmdhas no slash and is passed as typed;paramsis the rest of the line (empty string if none). - int params –
cmdhas no slash and is passed as typed;paramsis the rest of the line (empty string if none).
Example
function onPlayerCommand( player, cmd, params )
{
if ( cmd == "hp" )
{
player.Health = 100.0;
MessagePlayer( "Health restored.", player );
}
else if ( cmd == "car" && params.len() > 0 )
{
local veh = CreateVehicle( params.tointeger(), player.Pos, player.Angle );
if ( veh ) player.Vehicle = veh; // put the player in the driver seat
}
}Related pages
Section: Chat and commands
Categories: Server events | Chat and commands