Message sent twice. Caused by timer?
#1

We've been trying to solve this issue for a few days now but we cannot seem to get rid of it. Basically, every messages are sent successfully, but at some point (case 3 & case 4, case 5 & case 6).

There should be a five second wait between each message (each case), though, the messages in case 2 and case 3 and sent together (at the same time), then there's the five second wait, and then case 4, case 5 and case 6 messages are sent together. case 7 is used to kill the timer.

The chatlog event can be found below, aswell as the code of function, PlayerTutorial(playerid);.

pawn Код:
//case 0
[14:37:28] ==================================================================================================================
[14:37:28]
[14:37:28]            Hello there. Welcome to San Andreas Online. This server is set in San Fierro, San Andreas.  
[14:37:28]           San Andreas Online consists of open world gaming sessions using the same map as GTA San Andreas.
[14:37:28]          Players may travel and interact with the map at will with many gameplay options. That includes a many activities!
[14:37:28]
[14:37:28] ==================================================================================================================

//5 second wait

//case 1
[14:37:34] Hello, welcome to SAOnline

//5 second wait

//case 2 and case 3, sent at the same time
[14:37:39] Hello, welcome to SAOnline
[14:37:39] Hello, welcome to SAOnline

// 5 second wait

//case 4, case 5 and case 6 sent at the same time
[14:37:45] Hello, welcome to SAOnline
[14:37:45] Hello, welcome to SAOnline
[14:37:45] The end
pawn Код:
new Tutorial[ MAX_PLAYERS ][ 2 ]; //Should be global, so we can use it.

forward PlayerTutorial(playerid);
public PlayerTutorial(playerid)
{
    Tutorial[ playerid ][ 1 ] = SetTimerEx( "PlayerTutorial", 100*10*5, true, "i", playerid );
    switch(Tutorial[playerid][0])
    {
        case 0:
        {
            SendClientMessage(playerid, -1, "");
            SendClientMessage(playerid, -1, "");
            SendClientMessage(playerid, -1, "");
            SendClientMessage(playerid, -1, "");
            SendClientMessage(playerid, -1, "");
            SendClientMessage(playerid, -1, "");
            SendClientMessage(playerid, -1, "");
            SendClientMessage(playerid, -1, "");
            SendClientMessage(playerid, GREEN, "==================================================================================================================");
            SendClientMessage(playerid, -1, "");
            SendClientMessage(playerid, -1, "                                           Hello there. Welcome to San Andreas Online. This server is set in San Fierro, San Andreas.          ");
            SendClientMessage(playerid, -1, "                                       San Andreas Online consists of open world gaming sessions using the same map as GTA San Andreas. ");
            SendClientMessage(playerid, -1, "                                   Players may travel and interact with the map at will with many gameplay options. That includes a many activities!");
            SendClientMessage(playerid, -1, "");
            SendClientMessage(playerid, GREEN, "==================================================================================================================");
        }
        case 1:
        {
            SendClientMessage(playerid, -1, "Hello, welcome to SAOnline");
        }
        case 2:
        {
            SendClientMessage(playerid, -1, "Hello, welcome to SAOnline");
        }
        case 3:
        {
            SendClientMessage(playerid, -1, "Hello, welcome to SAOnline");
        }
        case 4:
        {
            SendClientMessage(playerid, -1, "Hello, welcome to SAOnline");
        }
        case 5:
        {
            SendClientMessage(playerid, -1, "Hello, welcome to SAOnline");
        }
        case 6:
        {
            SendClientMessage(playerid, -1, "The end");
        }
        case 7:
        {
            KillTimer(Tutorial[ playerid ][ 1 ]);
        }
       
    }
    Tutorial[ playerid ][ 0 ]++;
    return true;
}
Reply
#2

You set a repeated timer inside the timer's callback so it will be called multiply times.

pawn Код:
Tutorial[ playerid ][ 1 ] = SetTimerEx( "PlayerTutorial", 100*10*5, true, "i", playerid );
Reply
#3

Oh, yes. Thank you very much, Konstantinos. I've now fixed the error.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)