PlayerSpectateVehicle unexpected stop spectating
#1

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:
  • OS: Windows
  • SA-MP version: latest
  • Gamemode: test.amx (contains nearly nothing, see below)
  • Initial filterscripts: gl_npcs (changed next to nothing from initial script, see below)
  • Plugins: /
  • maxplayers: 50
  • maxnpc: 40
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:
  • Start the server
  • /rcon login (I have playerid 6)
  • /specvehicle (vehicleID is 1, as shown in test.pwn. Used by npcid 0, as shown in the code above.)
  • /rcon kick 5
  • /rcon kick 4
  • /rcon kick 3
  • /rcon kick 2
  • Everything works fine up to this moment.
  • /rcon kick 1 (this is the npcid just 1 ID higher than the npcid that was inside the vehicle I was spectating)
  • Spectator (me) respawns. Even though I was spectating the vehicle, not the player!
Now ok, here is another similar scenario where the same bug occurs:
Changes to first scenario:
  • 7 vehicles instead of 6.
  • Bots are put in vehicles starting from vehicleID 2.
  • So this makes that vehicleID 1 is not occupied by anyone.
  • /specvehicle spectates vehicleID 2, because vehicleID 1 is not occupied by anyone.
The steps I took:
  • Start the server
  • /rcon login (I have playerid 6)
  • /specvehicle (vehicleID is 2, as explained above. Used by npcid 0, as explained above.)
  • /rcon kick 5
  • /rcon kick 4
  • /rcon kick 3
  • Everything works fine up to this moment.
  • /rcon kick 2 (this is the npcid just 1 ID higher than the npcid that was inside the vehicle I was spectating)
  • Spectator (me) respawns. Even though I was spectating the vehicle, not the player!
Ok, so another scenario where the same bug occurs:
Changes to first scenario:
  • Still 7 vehicles instead of 6.
  • Bots are put in vehicles starting from ID 2.
  • So this makes that vehicleID 1 is not occupied by anyone.
  • /specvehicle spectates vehicleID 1, used by no one, where as in scenario 2, it was vehicleID 2, used by npcid 0.
The steps I took:
  • Start the server
  • /rcon login (I have playerid 6)
  • /specvehicle (vehicleID is 1, as explained above. Used by no one, as explained above.)
  • /rcon kick 5
  • /rcon kick 4
  • /rcon kick 3
  • /rcon kick 2
  • Everything works fine up to this moment.
  • /rcon kick 1
  • Spectator (me) respawns. Even though I was spectating the vehicle, not the player!
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.
Reply


Forum Jump:


Users browsing this thread: