02.08.2012, 16:47
pawn Код:
YCMD:spec(playerid, params[], help)
{
#pragma unused help
if(P_Data[playerid][pAdmin] < 2) return SCM(playerid, COLOR_RED, "You need to be admin level 2 to use this!");
new
pplayerid,Float:Pos[3],string[128];
if(sscanf(params, "u", pplayerid)) return SCM(playerid, COLOR_RED, "Usage: /spec [Player ID/Player Name]");
if(pplayerid == IPI) return SCM(playerid, COLOR_RED, "Wrong playerid!");
foreach(Player, i) {
if(P_Data[i][pAdmin] > 0) {
format(string,sizeof(string),"%s is spectating: %s ",GetName(playerid),GetName(pplayerid));
SCM(i,-1,string);}}
GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
SetPVarFloat(playerid,"XPos",Pos[0]);
SetPVarFloat(playerid,"YPos",Pos[1]);
SetPVarFloat(playerid,"ZPos",Pos[2]);
SetPVarInt(playerid,"Interior",GetPlayerInterior(playerid));
SetPVarInt(playerid,"VW",GetPlayerVirtualWorld(playerid));
P_Data[playerid][pSpecating] = 1;
format(string,sizeof(string),"~g~Name: ~w~%s ~g~Score: ~w~%d ~g~Money: ~w~%d",GetName(pplayerid),GetPlayerScore(pplayerid),GetPlayerMoney(pplayerid));
TextDrawSetString(Spec1[playerid],string);
TextDrawShowForPlayer(playerid,Spec1[playerid]);
TextDrawShowForPlayer(playerid,Spec0[playerid]);
if ( !IsPlayerInAnyVehicle(pplayerid) ) {
TogglePlayerSpectating(playerid, 1);
PlayerSpectatePlayer(playerid, pplayerid);
SetPlayerInterior(playerid,GetPlayerInterior(pplayerid));
SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(pplayerid));
return 1; }
else {
TogglePlayerSpectating(playerid, 1);
SetPVarInt(playerid, "p_spectating", 1);
PlayerSpectateVehicle(playerid, GetPlayerVehicleID(pplayerid));
SetPlayerInterior(playerid,GetPlayerInterior(pplayerid));
SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(pplayerid)); }
return 1;
}
YCMD:specoff(playerid, params[], help)
{
#pragma unused help
#pragma unused params
if(P_Data[playerid][pAdmin] < 2) return SCM(playerid, COLOR_RED, "You need to be admin level 2 to use this!");
if(P_Data[playerid][pSpecating] == 0)return SCM(playerid, COLOR_RED, "You don't spectate nobody!");
SetPlayerInterior(playerid,GetPVarInt(playerid,"Interior"));
SetPlayerVirtualWorld(playerid, GetPVarInt(playerid,"VW"));
P_Data[playerid][pSpecating] = 0;
TextDrawHideForPlayer(playerid,Spec1[playerid]);
TextDrawHideForPlayer(playerid,Spec0[playerid]);
TogglePlayerSpectating(playerid, 0);
return 1;
}
public OnPlayerSpawn(playerid){
if(GetPVarInt(playerid, "p_spectating")){
SetPlayerPos(playerid,GetPVarFloat(playerid,"XPos"),GetPVarFloat(playerid,"YPos"),GetPVarFloat(playerid,"ZPos"));
SetPVarInt(playerid, "p_spectating", 0);
return 1;
}
return 1;
}