25.06.2012, 18:25
If player type /go <id> the player teleports to another player, when he type /go again without <id> player can't be teleported or lets say he can disable and enable goes by typing /go again.
new bool:bIsGoEnabled[ MAX_PLAYERS ]; // top
CMD:go( playerid, params[ ] )
{
if( isnull( params ) )
{
if( bIsGoEnabled[ playerid ] )
{
bIsGoEnabled[ playerid ] = false;
SendClientMessage( playerid, -1, "GO: Disabled" );
}
else
{
bIsGoEnabled[ playerid ] = true;
SendClientMessage( playerid, -1, "GO: Enabled" );
}
}
else
{
new goid;
if( sscanf( params, "u", goid ) ) return SendClientMessage( playerid, -1, "Error: /go <id>" );
if( IsPlayerConnected( goid ) || goid == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "Error: Player not connected or invalid id" );
if( !bIsGoEnabled[ playerid ] ) return SendClientMessage( playerid, -1, "Error: GO is disabled." );
new Float:X, Float:Y, Float:Z;
GetPlayerPos( goid, X, Y, Z );
SetPlayerPos( playerid, X, Y, Z );
SendClientMessage( playerid, -1, "GO: You have been teleported." );
}
return 1;
}
pawn Код:
Hope this helps. Regards, FalconX |
new bool:bIsGoEnabled; // top
CMD:go( playerid, params[ ] )
{
if( !IsPlayerAdmin( playerid ) ) return SendClientMessage( playerid, -1, "You have to be an admin to enable/disable go" );
new goid;
if( sscanf( params, "u", goid ) )
{
if( bIsGoEnabled )
{
bIsGoEnabled = false;
SendClientMessage( playerid, -1, "GO: Disabled" );
}
else
{
bIsGoEnabled = true;
SendClientMessage( playerid, -1, "GO: Enabled" );
}
}
else
{
if( IsPlayerConnected( goid ) || goid == INVALID_PLAYER_ID ) return SendClientMessage( playerid, -1, "Error: Player not connected or invalid id" );
if( !bIsGoEnabled ) return SendClientMessage( playerid, -1, "Error: GO is disabled." );
new Float:X, Float:Y, Float:Z;
GetPlayerPos( goid, X, Y, Z );
SetPlayerPos( playerid, X, Y, Z );
SendClientMessage( playerid, -1, "GO: You have been teleported." );
}
return 1;
}