05.03.2012, 17:06
hi,
i use a timer to delay the class selection.
But for some players it seems that the timer doesnt work or get running.
Also some players still get a random colour when the connect but as you can see in the code i set the colour
of the player to grey when he connects.
So if the SetPlayerColour function gets not called for certain players when they connect the timer that delays
the class selection also might not be.
But that would lead to bugs so what could be made better in the folowing code to prevent this bug?
Im happy about any suggestion or good idea.
+REP for everyone who helps, thx
i use a timer to delay the class selection.
But for some players it seems that the timer doesnt work or get running.
Also some players still get a random colour when the connect but as you can see in the code i set the colour
of the player to grey when he connects.
So if the SetPlayerColour function gets not called for certain players when they connect the timer that delays
the class selection also might not be.
But that would lead to bugs so what could be made better in the folowing code to prevent this bug?
Im happy about any suggestion or good idea.
+REP for everyone who helps, thx
pawn Код:
public OnPlayerConnect(playerid)
{
mysql_ping();//ping mysql database so you know if its alive
TogglePlayerSpectating(playerid, true);//to prevent/delay class selection
SetPlayerColor(playerid,0x818181FF);//grey colour when a player joins and is not logged in yet
//reset some player variables:
var1[playerid]=0;
var2[playerid]=0;
//etc...
SetTimerEx("OnPlayerConnectEx",6000,false,"i",playerid);//My timer for the delayed class selection
//so the class selection is delayed 6 seconds.
return 1;
}
forward OnPlayerConnectEx(playerid);
public OnPlayerConnectEx(playerid)
{
TogglePlayerSpectating(playerid, false);//so the player gets to the class selection
SendClientMessage(playerid,0xFFFF00FF, "Welcome to the server!");//welcome message
//some more stuff like mysql login code etc...
return 1;
}