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

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
	}
}

Section: Chat and commands

Categories: Server events | Chat and commands