05.01.2012, 11:24
Hello.
Yesterday I was coding a tutorial system for my server, and at some point I got my server crashing due to "index array out of bounds". After digging a bit, I noticed that a PVar in "OnPlayerSpawn" wasn't existing/detected (while it should). After digging more and more, I ended up on that conclusion:
Using the "SpawnPlayer" function while the player is on class selection:
1) Kicks the player from the server in a first time
2) Calls the "OnPlayerSpawn" callback in a second time. And because the player is already disconnected due to the kick (that happens for no apparent reason), any PVar that was set while he was still connected, doesn't exist anymore
To prove that this bug is not related to my server, here is a very simple gamemode:
If you spawn normally by using the "spawn" button of the class selection screen: "Value of PVar blah: 1337"
If you use the /spawn command while playing normally: "Value of PVar blah: 1337"
If you use the /spawn command while on the class selection screen: ""Value of PVar blah: 0", and you get "Server closed the connection" in your client.
This bug needs to be fixed please: sometimes we need to force the player to spawn while he's on the class selection screen.
Yesterday I was coding a tutorial system for my server, and at some point I got my server crashing due to "index array out of bounds". After digging a bit, I noticed that a PVar in "OnPlayerSpawn" wasn't existing/detected (while it should). After digging more and more, I ended up on that conclusion:
Using the "SpawnPlayer" function while the player is on class selection:
1) Kicks the player from the server in a first time
2) Calls the "OnPlayerSpawn" callback in a second time. And because the player is already disconnected due to the kick (that happens for no apparent reason), any PVar that was set while he was still connected, doesn't exist anymore
To prove that this bug is not related to my server, here is a very simple gamemode:
pawn Код:
#include <a_samp>
#include <zcmd>
main()
{
print("\n----------------------------------");
print(" Training server by decondelite");
print("----------------------------------\n");
}
public OnGameModeInit()
{
AddPlayerClass(285,1958.3783,1343.1572,15.3746,269.1425,24,100,28,500,31,500);
return 1;
}
public OnPlayerConnect(playerid)
{
SetPVarInt(playerid,"Blah",1337);
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid,237.9566,1714.1926,25.5391);
SetPlayerCameraPos(playerid,230.2138,1861.3087,30.6406);
SetPlayerCameraLookAt(playerid,207.5057,1918.9917,17.6406);
return 1;
}
public OnPlayerSpawn(playerid)
{
printf("Value of PVar blah: %i",GetPVarInt(playerid,"Blah"));
// We give extra guns
GivePlayerWeapon(playerid,5,1); // Bat
GivePlayerWeapon(playerid,27,200); // Combat shotgun
GivePlayerWeapon(playerid,34,100); // Sniper
GivePlayerWeapon(playerid,16,10); // Grenade
GivePlayerWeapon(playerid,42,200); // Extinguisher
GivePlayerWeapon(playerid,24,0); // To scroll back to desert eagle
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(killerid,playerid,reason);
return 1;
}
CMD:spawn(playerid,params[])
{
SpawnPlayer(playerid);
return 1;
}
If you use the /spawn command while playing normally: "Value of PVar blah: 1337"
If you use the /spawn command while on the class selection screen: ""Value of PVar blah: 0", and you get "Server closed the connection" in your client.
This bug needs to be fixed please: sometimes we need to force the player to spawn while he's on the class selection screen.