SA-MP Forums Archive
Spectate, interrior worlds etc. - 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: Spectate, interrior worlds etc. (/showthread.php?tid=552143)



Spectate, interrior worlds etc. - GuitarMan - 22.12.2014

Hello.
So what im trying to do is, make a command that spectates the leader of a gang.
HEres the code:
PHP код:
 CMD:spectate3(playeridparams[])
 {
        for(new 
0GetMaxPlayers(); i++)
        {
                if(
PlayerInfo[i][pLeader] == F_BALLAS)
                {
                    
                       
TogglePlayerSpectating(playerid1);
            
SetPlayerInterior(playeridGetPlayerInterior(i));
            
SetPlayerVirtualWorld(playeridGetPlayerVirtualWorld(i));
                   
PlayerSpectatePlayer(playeridi);
            }
        }
 } 
all in all code works just fine. The problem is, if im inside a building(in a different interrior) it shows sky after using the command. If im outside, nearby the leader (in the same interrior with the leader) the command works just fine. I can't figure it out whats wrong with it o.o


Re: Spectate, interrior worlds etc. - Threshold - 23.12.2014

pawn Код:
CMD:spectate3(playerid, params[])
{
    for(new i = 0; i < GetMaxPlayers(); i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(PlayerInfo[i][pLeader] != F_BALLAS) continue;
        SetPlayerInterior(playerid, GetPlayerInterior(i));
        SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(i));
        TogglePlayerSpectating(playerid, 1);
        if(IsPlayerInAnyVehicle(playerid)) PlayerSpectateVehicle(playerid, GetPlayerVehicleID(i));
        else PlayerSpectatePlayer(playerid, i);
        break;
    }
    return 1;
}
You need to use TogglePlayerSpectate 'after' you use things like SetPlayerInterior and SetPlayerVirtualWorld.

With this code, you'll probably need code under OnPlayerStateChange to change the spectating type when the leader exits or enters a vehicle.


Re: Spectate, interrior worlds etc. - GuitarMan - 23.12.2014

The interriors and worls does not seem to be working, even with your solution.
I guess something else is wrong with that. I suppose with the "i" value. Altho spectate works just fine when in same world/interrior, so it cant be the i. It just does not seem to change the interrior and world for the playerid...


AW: Spectate, interrior worlds etc. - Flori - 23.12.2014

Hmm, use your code, use the toggleplayerspectating direct before playerspectateplayer and break the loop after you found 1leader.

Thresholds code should work btw.


Re: Spectate, interrior worlds etc. - GuitarMan - 23.12.2014

I dont really think breaking the for loop would help, as it takes effect only when the "i" is the ID of the ballas leader o.o
And toggleplayerspectating is activated b4 playerspectateplayer.