CMD:spec(playerid, params[]) { new giveplayerid, Float:x, Float:y, Float:z; if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command."); if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, -1, "USAGE: /spec [playerid/partofname/off]"); if(strcmp(params, "off", true) == 0) { SetPVarInt(playerid, "SpecOff", 1); TogglePlayerSpectating(playerid, false); SetCameraBehindPlayer(playerid); SetPlayerPos(playerid, x, y, z); spec[playerid] = -1; return 1; } if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player specified."); if(IsPlayerInAnyVehicle(giveplayerid)) { GetPlayerPos(playerid, x, y, z); TogglePlayerSpectating(playerid, true); new carid = GetPlayerVehicleID(giveplayerid); PlayerSpectateVehicle(playerid, carid); SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid)); SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(giveplayerid)); spec[playerid] = giveplayerid; } else { GetPlayerPos(playerid, x, y, z); TogglePlayerSpectating(playerid, true); PlayerSpectatePlayer(playerid, giveplayerid); SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid)); SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(giveplayerid)); spec[playerid] = giveplayerid; } return 1; }
Yeah, you have to save the old position of playerid in a global variable. If you type '/spec off', it'll re-create giveplayerid, x, y, z. So x, y, and z will be 0 and that's why you spawn in Blueberry.
|
GetPlayerPos(playerid, x, y, z); TogglePlayerSpectating(playerid, true); PlayerSpectatePlayer(playerid, giveplayerid); SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid)); SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(giveplayerid)); spec[playerid] = giveplayerid;
Thats what this is xD
Код:
GetPlayerPos(playerid, x, y, z); TogglePlayerSpectating(playerid, true); PlayerSpectatePlayer(playerid, giveplayerid); SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid)); SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(giveplayerid)); spec[playerid] = giveplayerid; |
CMD:spec(playerid, params[]) { new giveplayerid, Float:x, Float:y, Float:z;
new Float:specPos[MAX_PLAYERS][3], specInt[MAX_PLAYERS], specVW[MAX_PLAYERS]; //Old position, int and vw of the admin. GetPlayerPos(playerid, SpecPos[playerid][0], SpecPos[playerid][1], SpecPos[playerid][2]); specInt[playerid] = GetPlayerInterior(playerid); specVW[playerid] = GetPlayerVirtualWorld(playerid);