Jump to content
  • 0

Problema spawn spectator


bogdean_collin

Question

Am o problema cu gamemodul, atunci cand dau /specoff as vrea sa ma respawneze in locul de unde am dat /spec, insa ma respawneaza la locul normal de spawn.

Codul este urmatorul :

[pawn]public Spectator()

{

new string[256];

for(new i = 0; i < MAX_PLAYERS; i++)

{

if(Spectate < 500)

{

SetPlayerColor(i,COLOR_SPEC);

new targetid = Spectate;

if(IsPlayerConnected(targetid))

{

    //TogglePlayerSpectating(i, 1);

    if(PlayerData[pAdmin] >= 1)

    {

        new Float:health;

    new name[MAX_PLAYER_NAME];

    GetPlayerName(targetid, name, sizeof(name));

    GetPlayerHealth(targetid, health);

    //if(IsPlayerInAnyVehicle(targetid))

  if(GetPlayerState(targetid) == PLAYER_STATE_DRIVER)

{

        new Float:Valoarea;

        new carid = GetPlayerVehicleID(targetid);

GetVehicleHealth(carid,Valoarea);

new speed = floatround(GetVehicleSpeed_P(targetid), floatround_ceil);

        //format(string, sizeof(string), "~n~~n~~n~~n~~y~%s[iD:%d]~n~~w~Health:~r~%.1f~n~~w~Vehicle HP: ~r~%.1f~n~~w~ Speed: ~r~%d km/h",name,targetid,health,Valoarea, speed);

                        TextDrawHideForPlayer(i, TextDrawSpec[1]);

    TextDrawHideForPlayer(i, TextDrawSpec[2]);

    TextDrawHideForPlayer(i, TextDrawSpec[3]);

    TextDrawHideForPlayer(i, TextDrawSpec[4]);

    TextDrawHideForPlayer(i, TextDrawSpec[5]);

    format(string, sizeof(string), "~y~%s (%d)", name, targetid);

    TextDrawSetString(TextDrawSpec[1], string);

    format(string, sizeof(string), "Health:~r~ %.1f", health);

    TextDrawSetString(TextDrawSpec[2], string);

    format(string, sizeof(string), "Vehicle ID:~r~ %d", carid);

TextDrawSetString(TextDrawSpec[3], string);

format(string, sizeof(string), "Vehicle Health:~r~ %.1f", Valoarea);

TextDrawSetString(TextDrawSpec[4], string);

format(string, sizeof(string), "Vehicle Speed:~r~ %d KM/H", speed);

TextDrawSetString(TextDrawSpec[5], string);

    TextDrawShowForPlayer(i, TextDrawSpec[1]);

TextDrawShowForPlayer(i, TextDrawSpec[2]);

TextDrawShowForPlayer(i, TextDrawSpec[3]);

TextDrawShowForPlayer(i, TextDrawSpec[4]);

TextDrawShowForPlayer(i, TextDrawSpec[5]);

}

    else

    {

    //format(string, sizeof(string), "~n~~n~~n~~n~~n~~n~~y~%s[iD:%d]~n~~w~Health:~r~%.1f",name,targetid,health);

    TextDrawHideForPlayer(i, TextDrawSpec[1]);

    TextDrawHideForPlayer(i, TextDrawSpec[2]);

    TextDrawHideForPlayer(i, TextDrawSpec[3]);

    TextDrawHideForPlayer(i, TextDrawSpec[4]);

    TextDrawHideForPlayer(i, TextDrawSpec[5]);

    format(string, sizeof(string), "~y~%s (%d)", name, targetid);

    TextDrawSetString(TextDrawSpec[1], string);

    format(string, sizeof(string), "Health:~r~ %.1f", health);

    TextDrawSetString(TextDrawSpec[2], string);

    TextDrawShowForPlayer(i, TextDrawSpec[1]);

        TextDrawShowForPlayer(i, TextDrawSpec[2]);

}

//GameTextForPlayer(i, string, 2500, 4);

    }

}//Targetid connected

else

{

    TextDrawHideForPlayer(i, TextDrawSpec[1]);

    TextDrawHideForPlayer(i, TextDrawSpec[2]);

    TextDrawHideForPlayer(i, TextDrawSpec[3]);

    TextDrawHideForPlayer(i, TextDrawSpec[4]);

    TextDrawHideForPlayer(i, TextDrawSpec[5]);

}

}

if(Spectate == 997)

{

TogglePlayerControllable(i, 1);

TogglePlayerSpectating(i, 0);

SetPlayerInterior(i,Unspec[sPint]);

PlayerData[pInt] = Unspec[sPint];

PlayerData[pLocal] = Unspec[sLocal];

Unspec[sLocal] = 255;

SetSpawnInfo(i, PlayerData[pTeam], PlayerData[pModel], Unspec[sPx],  Unspec[sPy], Unspec[sPz]-1.0, 1.0, -1, -1, -1, -1, -1, -1);

gTeam = PlayerData[pTeam];

SetPlayerToTeamColor(i);

MedicBill = 0;

TextDrawHideForPlayer(i, TextDrawSpec[1]);

    TextDrawHideForPlayer(i, TextDrawSpec[2]);

    TextDrawHideForPlayer(i, TextDrawSpec[3]);

    TextDrawHideForPlayer(i, TextDrawSpec[4]);

    TextDrawHideForPlayer(i, TextDrawSpec[5]);

            SetSpawnInfo(i, PlayerData[pTeam], PlayerData[pModel], Unspec[Coords][0], Unspec[Coords][1], Unspec[Coords][2], 10.0, -1, -1, -1, -1, -1, -1);

SpawnPlayer(i);

SetCameraBehindPlayer(i);

Spectate = 998;

TextDrawHideForPlayer(i, TextDrawSpec[1]);

    TextDrawHideForPlayer(i, TextDrawSpec[2]);

    TextDrawHideForPlayer(i, TextDrawSpec[3]);

    TextDrawHideForPlayer(i, TextDrawSpec[4]);

    TextDrawHideForPlayer(i, TextDrawSpec[5]);

}

if(Spectate == 998)

{

TogglePlayerControllable(i, 1);

SetPlayerInterior(i,Unspec[sPint]);

PlayerData[pInt] = Unspec[sPint];

PlayerData[pLocal] = Unspec[sLocal];

SetPlayerPos(i, Unspec[sPx],  Unspec[sPy], Unspec[sPz]);

Spectate = 255;

}

if(Spectate == 256)

{

SetPlayerToTeamColor(i);

Spectate = 255;

}

if(Spectate == 257)

{

Spectate = 254;

}

}

}

[/pawn]

[pawn] if(strcmp(cmd, "/specoff", true) == 0)

{

if(PlayerData[playerid][pAdmin] == 0 && PlayerData[playerid][pAgent] == 0)

{

    return 1;

}

    if(WatchingPLAYER[playerid] > 0)

    {

        WatchingPLAYER[playerid] = 0;

Spectate[playerid] = 997;

GameTextForPlayer(playerid, "~w~                TV~n~~r~                Off", 5000, 6);

// PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);

return 1;

}

else

{

    SendClientMessage(playerid, COLOR_LIGHTGREEN, "Nu esti pe spectator");

    return 1;

}

}

//-----------------------------------------Comanda-----------------------------------------//

if(strcmp(cmd, "/spec", true) == 0)

{

    if(IsPlayerConnected(playerid))

    {

if(PlayerData[playerid][pAdmin] == 0 && PlayerData[playerid][pAgent] == 0)

{

    return 1;

}

            if(WatchingPLAYER[playerid] < 1)

    {

        GetPlayerPos(playerid, Unspec[playerid][Coords][0],Unspec[playerid][Coords][1],Unspec[playerid][Coords][2]);

        }

   

if(Spectate[playerid] == 999 && PlayerData[playerid][pLocal] != 255 || Spectate[playerid] == 999 && PlayerData[playerid][pAdmin] > 0)

{

GetPlayerPos(playerid, Unspec[playerid][sPx], Unspec[playerid][sPy], Unspec[playerid][sPz]);

Unspec[playerid][sPint] = PlayerData[playerid][pInt];

Unspec[playerid][sLocal] = PlayerData[playerid][pLocal];

PlayerData[playerid][pLocal] = 255;

gTeam[playerid] = 0;

}

tmp = strtok(cmdtext, idx);

giveplayerid = ReturnUser(tmp);

if(IsPlayerConnected(giveplayerid))

{

    if(giveplayerid != INVALID_PLAYER_ID)

    {

        Spectate[playerid] = giveplayerid;

new Float:health;

GetPlayerHealth(Spectate[playerid], health);

GetPlayerName(Spectate[playerid], giveplayer, sizeof(giveplayer));

new cash =  GetPlayerCash(Spectate[playerid]);

if (PlayerData[playerid][pAdmin] >= 1)

{

format(string, sizeof(string), "Spec: %s[iD: %d] | $%s | H: %.0f |",giveplayer, Spectate[playerid],FormatNumber(cash, 0, '.'),health);

}

else

{

format(string, sizeof(string), "UAV: (%d) %s",Spectate[playerid],giveplayer);

}

SendClientMessage(playerid, COLOR_GREEN, string);

WatchingPLAYER[playerid] = 1;

TogglePlayerSpectating(playerid, 1);

if(IsPlayerInAnyVehicle(Spectate[playerid]))

{

    new carid = GetPlayerVehicleID(Spectate[playerid]);

    PlayerSpectateVehicle(playerid, carid);

}

else

{

    PlayerSpectatePlayer(playerid, Spectate[playerid]);

}

if(GetPlayerInterior(Spectate[playerid]) == 0)

{

SetPlayerInterior(playerid,0);

}

else if(GetPlayerInterior(Spectate[playerid]) > 0)

{

SetPlayerInterior(playerid,GetPlayerInterior(Spectate[playerid]));

}

}

}

else

{

SendClientMessage(playerid, COLOR_GREEN, "Jucatorul nu este conectat!");

return 1;

}

}

return 1;

}

[/pawn]

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.