02.02.2011, 20:02
Hey guys, does anyone have a spectate command. For example /spectate [id] and /spectateoff. Thanks verymuch!
#include <a_samp>
#include <sscanf>
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(spectate, 8, cmdtext);
dcmd(spectateoff, 11, cmdtext);
return 0;
}
dcmd_spectate(playerid, params[])
{
new targetid;
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_USAGE, "USAGE: /spectate (id)");
else if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_ERROR, "Invalid ID");
{
TogglePlayerSpectating(playerid, 1);
if(IsPlayerInAnyVehicle(targetid))
{
PlayerSpectateVehicle(playerid, targetid);
return 1;
}
else
{
PlayerSpectatePlayer(playerid, targetid);
return 1;
}
}
}
dcmd_spectateoff(playerid, params[])
{
#pragma unused params
TogglePlayerSpectating(playerid, 0);
return 1;
}