Spectate, interrior worlds etc.
#1

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
Reply
#2

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.
Reply
#3

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...
Reply
#4

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

Thresholds code should work btw.
Reply
#5

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.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)