SPEC Command - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: SPEC Command (
/showthread.php?tid=396294)
SPEC Command -
UnknownGamer - 30.11.2012
pawn Код:
dcmd_spec(playerid, params[])
{
new id;
if (sscanf(params, "u", id)) SendClientMessage(playerid, COLOR_WHITE, "USAGE: /spec [ID]");
else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_GREY, "* Player[ID] is not found!");
else
if(PlayerInfo[playerid][pAdmin] >= 4)
{
GetPlayerPos(playerid, TeleportDest[playerid][0],TeleportDest[playerid][1],TeleportDest[playerid][2]);
if(IsPlayerInAnyVehicle(id))
{
new int = GetPlayerInterior(id);
SetPlayerInterior(playerid, int);
TogglePlayerSpectating(playerid, 1);
PlayerSpectateVehicle(playerid, GetPlayerVehicleID(id));
}
else
{
new int = GetPlayerInterior(id);
SetPlayerInterior(playerid, int);
TogglePlayerSpectating(playerid, 1);
PlayerSpectatePlayer(playerid, id);
}
}
return 1;
}
pawn Код:
dcmd_specoff(playerid, params[])
{
#pragma unused params
TogglePlayerSpectating(playerid, 0);
Specing[playerid] = 0;
return 1;
}
Could anyone tell me, Why does it not spawn you back we're you did /spec [ID]?
When you do /specoff, I need it to return you, to your last position before /spec [ID].
Re: SPEC Command -
Infinity90 - 30.11.2012
pawn Код:
//Top of your script:
new Float:Posxx, Float:Posyy, Float:Poszz;
dcmd_spec(playerid, params[])
{
new id;
if (sscanf(params, "u", id)) SendClientMessage(playerid, COLOR_WHITE, "USAGE: /spec [ID]");
else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_GREY, "* Player[ID] is not found!");
else
if(PlayerInfo[playerid][pAdmin] >= 4)
{
GetPlayerPos(playerid, TeleportDest[playerid][0],TeleportDest[playerid][1],TeleportDest[playerid][2]);
GetPlayerPos(playerid,Posxx,Posyy,Poszz);
if(IsPlayerInAnyVehicle(id))
{
new int = GetPlayerInterior(id);
SetPlayerInterior(playerid, int);
TogglePlayerSpectating(playerid, 1);
PlayerSpectateVehicle(playerid, GetPlayerVehicleID(id));
}
else
{
new int = GetPlayerInterior(id);
SetPlayerInterior(playerid, int);
TogglePlayerSpectating(playerid, 1);
PlayerSpectatePlayer(playerid, id);
}
}
return 1;
}
dcmd_specoff(playerid, params[])
{
#pragma unused params
TogglePlayerSpectating(playerid, 0);
Specing[playerid] = 0;
SetPlayerPos(playerid,Posxx,Posyy,Poszz);
return 1;
}
Untested but should work.
Re: SPEC Command -
JaKe Elite - 30.11.2012
You've to store them in variable.
And load them (use it in SetPlayerPos) to go back to the position where you spectate.
Don't also forget to store the interior and virtual world in the variable.