OnPlayerConnect in timer BUG? +rep!!
#1

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

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;
}
Reply
#2

Are you sure that you gotta use an integer ( "i" ) here? Also, how does it come that it's workin' for some players, and neither for other?

EDIT: Gotta leave soon, think more about the timer again, and give it a try in this way:

pawn Код:
SetTimerEx("OnPlayerConnectEx",6000,false,"d",playerid);
Reply
#3

any other ideas?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)