PlayerSpectatePlayer in Interiors/Virtual World [0.3 Bug?]
#1

Hi,
i tried the PlayerSpectatePlayer/PlayerSpectateVehicle Function. Basicly what i did is a command to start spectating any player.
Код:
// Get Parameters (other player)
TogglePlayerSpectating(playerid, 1);
if(IsPlayerInAnyVehicle(otherplayer)) PlayerSpectateVehicle(playerid, GetPlayerVehicleID(otherplayer));
else PlayerSpectatePlayer(playerid, otherplayer);
SetPlayerInterior(playerid, GetPlayerInterior(otherplayer));
SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(otherplayer));
pSpectating[playerid] = otherplayer;
Another Command to stop spectating
Код:
TogglePlayerSpectating(playerid, 0);
pSpectating[playerid] = MAX_PLAYERS;
Now there are some further checks in OnPlayerStateChange, to spectate Vehicle/Player of Player enters/exits a car. And there is another check to set the interior in OnPlayerInteriorChange. The spectating if a Player enters/exits a vehicle works well, so i think theres no need to change the code, but ill show the code of OnPlayerInteriorChange (see below)
Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
	if(!IsPlayerConnected(i)) continue;
	if(pSpectating[i] == playerid)
	{
		SetPlayerInterior(i, newinteriorid);
		SetPlayerVirtualWorld(i, GetPlayerVirtualWorld(playerid));
	}
}
So thats all, except the StateChangepart, which works. Basicly everything works fine, there are no problems. Im able to spectate the player or his vehicle unless he is in any Interior. If a start spectating (using the command) a player, who is inside an interior, i see just a blue screen (the sky or something like that) although i set the Interior (see code above). It happens once (i think it was the SFPD Jail), that it worked and i tried with a few interiors already. The same happens (blue sky) if the Player enters an interior while im spectating him, altough (again), im setting the interior. I used Debug messages in OnPlayerInteriorChange to see if its called and it is.
I dont know what it is, i also looked through the Code several times, but witout success. So maybe one of you know whats wrong or is this just a 0.3 Bug? I didnt tested in 0.2, so im not sure.
Hope you can help me
Reply
#2

Anybody? Sorry for Double post, but i didnt find any mistake in my code, although i looked through the whole code. Maybe some of you could rebuild and test it, if this works for you. If it doesnt then i know it has to be a samp Bug
Reply
#3

Well, I have a working spectate code in 0.2 Maybe you could try this:

pawn Код:
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    // IF ANYONE IS SPECTATING THIS PLAYER, WE'LL ALSO HAVE
    // TO CHANGE THEIR INTERIOR ID TO MATCH
    new x = 0;
    while(x!=MAX_SERVER_PLAYERS)
    {
      if( IsPlayerConnected(x) && GetPlayerState(x) == PLAYER_STATE_SPECTATING & pSpectating[x] == playerid && gSpectateType[x] == SPECTATE_TYPE_PLAYER )
        {
          SetPlayerInterior(x,newinteriorid);
        }
        x++;
    }
}
Obviously you need to also to have:
pawn Код:
new gSpectateType[MAX_SERVER_PLAYERS];
and set the variable:
pawn Код:
gSpectateType[playerid] = SPECTATE_TYPE_VEHICLE; // if they are spectating a vehicle or:
gSpectateType[playerid] = SPECTATE_TYPE_PLAYER; // if they are speccing a player
Note: MAX_SERVER_PLAYERS can be changed to MAX_PLAYERS
Reply
#4

Thanks for your reply, i was suprised its working without the VirtualWorld, but then i found a Post from BeksyBoy (sry, but i cant remember name excatly):
Quote:

If you are spectating a player and they change virtual world and you change to that virtual world too you don't see them, you have got to spectate them again. In 0.2 this works fine.

This seems to be my problem i have, BUT he said i have to spectate them again, so i tried changing my OnPlayerInteriorChange Code to this
Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
	if(!IsPlayerConnected(i)) continue;
	if(pSpectating[i] == playerid)
	{
        PlayerSpectatePlayer(i, playerid);
		SetPlayerInterior(i, newinteriorid);
		SetPlayerVirtualWorld(i, GetPlayerVirtualWorld(playerid));
	}
}
Maybe he could describe it a little more in detail, if he finds this post
Quote:

Obviously you need to also to have:

I dont see no point, why i should need something like that, maybe you can tell me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)