SA-MP Forums Archive
PlayerSpectateVehicle unexpected stop spectating - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP (https://sampforum.blast.hk/forumdisplay.php?fid=3)
+--- Forum: Bug Reports (https://sampforum.blast.hk/forumdisplay.php?fid=20)
+--- Thread: PlayerSpectateVehicle unexpected stop spectating (/showthread.php?tid=613730)



PlayerSpectateVehicle unexpected stop spectating - Freaksken - 31.07.2016

OK, so hear me out. This post might seem long, but that's because I have provided 3 scenarios in which the bug occurs, so enough data is available.
I was able to reproduce the problem with a bare gamemode to eliminate as much variables as possible.
Bug tested with standard npcs (which is why I use gl_npcs.pwn), but I don't see why it should have any different result with real players. I can't test it with players, because I don't have enough people available. If some can reproduce this bug with real players, please comment below.

Server info: Complete test.pwn gamemode:
As you can see, we use just 6 vehicles in this gamemode (the amount of vehicles doesn't change the results, so 6 is enough).
Код:
#include <a_samp>

main() {
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if(!strcmp(cmdtext, "/specplayer", true)) {
                TogglePlayerSpectating(playerid, true);
		PlayerSpectatePlayer(playerid, 0);
    	        return 1;
	}
	if(!strcmp(cmdtext, "/specvehicle", true)) {
	        TogglePlayerSpectating(playerid, true);
		PlayerSpectateVehicle(playerid, 1);
    	        return 1;
	}
	return 0;
}

public OnGameModeInit()
{
	AddPlayerClass(265,1958.3783,1343.1572,15.3746,270.1425,0,0,0,0,-1,-1);

	AddStaticVehicleEx(445, 992.6539, 2277.8601, 10.9989, 180.0421, -1, -1, 0, 0);
	AddStaticVehicleEx(445, 992.4412, 1894.0457, 10.9630, 88.7566, -1, -1, 0, 0);
	AddStaticVehicleEx(445, 1316.0706, 1279.5754, 10.3912, 182.7809, -1, -1, 0, 0);
	AddStaticVehicleEx(445, 436.2841, 2537.2219, 15.8406, 88.0691, -1, -1, 0, 0);
	AddStaticVehicleEx(445, 1688.5614, 1316.5497, 10.3881, 9.2721, -1, -1, 0, 0);
	AddStaticVehicleEx(445, 2039.6250, 1066.2358, 10.2389, 2.7726, -1, -1, 0, 0);
	return 1;
}
gl_npcs.pwn filterscript:
The only thing I changed from the script delivered with the server download, is the vehicleIDs the npc's use. Keep in mind that vehicleIDs start at ID 1 not at ID 0 like everything else.
As you can see, only 6 NPC's will connect to the server and they are put in the first available vehicles.
If there are say 20 vehicles and the npc's are put in vehicleIDs with a few unoccupied vehicles in between, the results are the same.
Код:
//The original script had these lines in OnPlayerSpawn
PutPlayerInVehicle(playerid, 1, 0); //TrainDriverLV (trains consists of the engine + 3 trailers)
PutPlayerInVehicle(playerid, 5, 0); //TrainDriverSF (trains consists of the engine + 3 trailers)
PutPlayerInVehicle(playerid, 9, 0); //TrainDriverLS (trains consists of the engine + 3 trailers)
PutPlayerInVehicle(playerid, 13, 0); //PilotLV
PutPlayerInVehicle(playerid, 14, 0); //PilotSF
PutPlayerInVehicle(playerid, 15, 0); //PilotLS
//Which I changed to these (because I only use 6 vehicles in the testscript)
PutPlayerInVehicle(playerid, 1, 0); //TrainDriverLV (we use just a normal vehicle)
PutPlayerInVehicle(playerid, 2, 0); //TrainDriverSF (we use just a normal vehicle)
PutPlayerInVehicle(playerid, 3, 0); //TrainDriverLS (we use just a normal vehicle)
PutPlayerInVehicle(playerid, 4, 0); //PilotLV
PutPlayerInVehicle(playerid, 5, 0); //PilotSF
PutPlayerInVehicle(playerid, 6, 0); //PilotLS
The steps I took: Now ok, here is another similar scenario where the same bug occurs:
Changes to first scenario: The steps I took: Ok, so another scenario where the same bug occurs:
Changes to first scenario: The steps I took: Conclusion:
I have no explanation for this. I am spectating the vehicles, not the players. So why do I stop spectating when I kick a player that is not even in the vehicle I am spectating? Even though kicking the player that is in the vehicle I am spectating, doesn't stop me spectating. I have no clue what's going on .
How did I stumble upon this issue? I am creating a spectating script in which I use some bots to test the script.