SA-MP Forums Archive
one of server timers sometimes can stop suddenly - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: one of server timers sometimes can stop suddenly (/showthread.php?tid=357730)



one of server timers sometimes can stop suddenly - pasha97 - 08.07.2012

I have a timer which checks if a player is in current place for current mode of game, but sometimes this timer stops working. What can it be?

pawn Код:
forward dmcheck();
forward dmcheck2(playerid);

#define SetPlayerTimerI(%0,%1,%2) SetTimerEx(%0,%1,%2,"i",i)

public OnGameModeInit()
{
SetTimer("dmcheck",1000,true);
}

public dmcheck()
{
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
                if(mission[i]> 0)
                {
                if(!IsPlayerInRangeOfPoint(i, 500.0, -1339.1575,1302.2576,1.6600))
                {
                SetPlayerTimerI("dmcheck2",3000,false);
                }
                }
                if(dm[i] == 1)
                {
                if(!IsPlayerInRangeOfPoint(i, 100.0, 1129.0205,-1454.4484,15.7969))
                {
                SetPlayerTimerI("dmcheck2",3000,false);
                }
                }
                if(dm[i] == 2)
                {
                if(!IsPlayerInRangeOfPoint(i, 300.0, 2508.3787,2786.6370,10.8203))
                {
                SetPlayerTimerI("dmcheck2",3000,false);
                }
                }
                if(dm[i] == 3)
                {
                if(!IsPlayerInRangeOfPoint(i, 100.0, -926.4914,-498.8946,25.9609))
                {
                SetPlayerTimerI("dmcheck2",3000,false);
                }
                }
                if(dm[i] == 4)
                {
                if(!IsPlayerInRangeOfPoint(i, 350.0, -2129.3096,-444.2732,35.5344))
                {
                SetPlayerTimerI("dmcheck2",3000,false);
                }
                }
                if(dm[i] == 5)
                {
                if(!IsPlayerInRangeOfPoint(i, 300.0, 214.5838,1875.3218,17.6406))
                {
                SetPlayerTimerI("dmcheck2",3000,false);
                }
                }
                if(dm[i] == 6)
                {
                if(!IsPlayerInRangeOfPoint(i, 100.0, 2275.7498,1072.6093,10.8203))
                {
                SetPlayerTimerI("dmcheck2",3000,false);
                }
                }
                if(dm[i] == 7)
                {
                if(!IsPlayerInRangeOfPoint(i, 100.0, 2257.3013,1086.0162,33.5284))
                {
                SetPlayerTimerI("dmcheck2",3000,false);
                }
                }
                if(dm[i] == 8)
                {
                if(!IsPlayerInRangeOfPoint(i, 200.0, -1465.3469,385.0039,30.0859))
                {
                SetPlayerTimerI("dmcheck2",3000,false);
                }
                }
                if(dm[i] == 9)
                {
                if(!IsPlayerInRangeOfPoint(i, 300.0, -1600.6583,146.1976,-11.1581))
                {
                SetPlayerTimerI("dmcheck2",3000,false);
                }
                }
                if(dm[i] == 10)
                {
                if(!IsPlayerInRangeOfPoint(i, 100.0, 264.6115,2901.8877,8.0913))
                {
                SetPlayerTimerI("dmcheck2",3000,false);
                }
                }
                if(dm[i] == 11)
                {
                if(!IsPlayerInRangeOfPoint(i, 100.0, -919.1942,2680.9565,42.3703))
                {
                SetPlayerTimerI("dmcheck2",3000,false);
                }
                }
                if(dm[i] == 12)
                {
                if(!IsPlayerInRangeOfPoint(i, 100.0, -1291.3860,2505.5720,87.0033))
                {
                SetPlayerTimerI("dmcheck2",3000,false);
                }
                }
                if(dm[i] == 13)
                {
                if(!IsPlayerInRangeOfPoint(i, 100.0, 246.3545,1830.1222,7.5547))
                {
                SetPlayerTimerI("dmcheck2",3000,false);
                }
                }
                if(dm[i] == 14)
                {
                if(!IsPlayerInRangeOfPoint(i, 100.0, -2431.8721,1549.3807,34.4020))
                {
                SetPlayerTimerI("dmcheck2",3000,false);
                }
                }
                if(dm[i] == 15)
                {
                if(!IsPlayerInRangeOfPoint(i, 100.0, -824.7352,2758.3174,45.8516))
                {
                SetPlayerTimerI("dmcheck2",3000,false);
                }
                }
                if(dm[i] == 16)
                {
                if(!IsPlayerInRangeOfPoint(i, 100.0, -537.3676,2627.1506,53.4141))
                {
                SetPlayerTimerI("dmcheck2",3000,false);
                }
                }
                if(dm[i] == 17)
                {
                if(!IsPlayerInRangeOfPoint(i, 100.0, 763.0002,10.5178,1001.1639))
                {
                SetPlayerTimerI("dmcheck2",3000,false);
                }
                }
                if(dm[i] == 18)
                {
                if(!IsPlayerInRangeOfPoint(i, 300.0, -1129.2668,1036.4310,1345.7198))
                {
                SetPlayerTimerI("dmcheck2",3000,false);
                }
                }
                if(dm[i] == 19)
                {
                if(!IsPlayerInRangeOfPoint(i, 300.0, 761.4807,1062.5439,30.4844))
                {
                SetPlayerTimerI("dmcheck2",3000,false);
                }
                }
                if (CallRemoteFunction("GetPlayerRaceStatus", "d", i) == 1||CallRemoteFunction("GetPlayerRaceStatus", "d", i) == 2||CallRemoteFunction("GetPlayerRaceStatus", "d", i) == 3)
                {
                if(!IsPlayerInRangeOfPoint(i, 100.0, 1319.0,-2450.0,23.0))
                {
                SetPlayerTimerI("dmcheck2",3000,false);
                }
                }
                if(isafk[i] == 1)
                {
                if(!IsPlayerInRangeOfPoint(i, 50.0, xafk[i],yafk[i],zafk[i]))
                {
                SetPlayerTimerI("dmcheck2",3000,false);
                }
                }
        }
}
public dmcheck2(playerid)
{
                if(mission[playerid]> 0)
                {
                if(!IsPlayerInRangeOfPoint(playerid, 500.0, -1339.1575,1302.2576,1.6600))
                {
                SetPlayerToFreeroam(playerid);
                }
                }
                if(dm[playerid] == 1)
                {
                if(!IsPlayerInRangeOfPoint(playerid, 100.0, 1129.0205,-1454.4484,15.7969))
                {
                SetPlayerToFreeroam(playerid);
                }
                }
                if(dm[playerid] == 2)
                {
                if(!IsPlayerInRangeOfPoint(playerid, 300.0, 2508.3787,2786.6370,10.8203))
                {
                SetPlayerToFreeroam(playerid);
                }
                }
                if(dm[playerid] == 3)
                {
                if(!IsPlayerInRangeOfPoint(playerid, 100.0, -926.4914,-498.8946,25.9609))
                {
                SetPlayerToFreeroam(playerid);
                }
                }
                if(dm[playerid] == 4)
                {
                if(!IsPlayerInRangeOfPoint(playerid, 350.0, -2129.3096,-444.2732,35.5344))
                {
                SetPlayerToFreeroam(playerid);
                }
                }
                if(dm[playerid] == 5)
                {
                if(!IsPlayerInRangeOfPoint(playerid, 300.0, 214.5838,1875.3218,17.6406))
                {
                SetPlayerToFreeroam(playerid);
                }
                }
                if(dm[playerid] == 6)
                {
                if(!IsPlayerInRangeOfPoint(playerid, 100.0, 2275.7498,1072.6093,10.8203))
                {
                SetPlayerToFreeroam(playerid);
                }
                }
                if(dm[playerid] == 7)
                {
                if(!IsPlayerInRangeOfPoint(playerid, 100.0, 2257.3013,1086.0162,33.5284))
                {
                SetPlayerToFreeroam(playerid);
                }
                }
                if(dm[playerid] == 8)
                {
                if(!IsPlayerInRangeOfPoint(playerid, 200.0, -1465.3469,385.0039,30.0859))
                {
                SetPlayerToFreeroam(playerid);
                }
                }
                if(dm[playerid] == 9)
                {
                if(!IsPlayerInRangeOfPoint(playerid, 300.0, -1600.6583,146.1976,-11.1581))
                {
                SetPlayerToFreeroam(playerid);
                }
                }
                if(dm[playerid] == 10)
                {
                if(!IsPlayerInRangeOfPoint(playerid, 100.0, 264.6115,2901.8877,8.0913))
                {
                SetPlayerToFreeroam(playerid);
                }
                }
                if(dm[playerid] == 11)
                {
                if(!IsPlayerInRangeOfPoint(playerid, 100.0, -919.1942,2680.9565,42.3703))
                {
                SetPlayerToFreeroam(playerid);
                }
                }
                if(dm[playerid] == 12)
                {
                if(!IsPlayerInRangeOfPoint(playerid, 100.0, -1291.3860,2505.5720,87.0033))
                {
                SetPlayerToFreeroam(playerid);
                }
                }
                if(dm[playerid] == 13)
                {
                if(!IsPlayerInRangeOfPoint(playerid, 100.0, 246.3545,1830.1222,7.5547))
                {
                SetPlayerToFreeroam(playerid);
                }
                }
                if(dm[playerid] == 14)
                {
                if(!IsPlayerInRangeOfPoint(playerid, 100.0, -2431.8721,1549.3807,34.4020))
                {
                SetPlayerToFreeroam(playerid);
                }
                }
                if(dm[playerid] == 15)
                {
                if(!IsPlayerInRangeOfPoint(playerid, 100.0, -824.7352,2758.3174,45.8516))
                {
                SetPlayerToFreeroam(playerid);
                }
                }
                if(dm[playerid] == 16)
                {
                if(!IsPlayerInRangeOfPoint(playerid, 100.0, -537.3676,2627.1506,53.4141))
                {
                SetPlayerToFreeroam(playerid);
                }
                }
                if(dm[playerid] == 17)
                {
                if(!IsPlayerInRangeOfPoint(playerid, 100.0, 763.0002,10.5178,1001.1639))
                {
                SetPlayerToFreeroam(playerid);
                }
                }
                if(dm[playerid] == 18)
                {
                if(!IsPlayerInRangeOfPoint(playerid, 300.0, -1129.2668,1036.4310,1345.7198))
                {
                SetPlayerToFreeroam(playerid);
                }
                }
                if(dm[playerid] == 19)
                {
                if(!IsPlayerInRangeOfPoint(playerid, 300.0, 761.4807,1062.5439,30.4844))
                {
                SetPlayerToFreeroam(playerid);
                }
                }
                if (CallRemoteFunction("GetPlayerRaceStatus", "d", playerid) == 1||CallRemoteFunction("GetPlayerRaceStatus", "d", playerid) == 2||CallRemoteFunction("GetPlayerRaceStatus", "d", playerid) == 3)
                {
                if(!IsPlayerInRangeOfPoint(playerid, 100.0, 1319.0,-2450.0,23.0))
                {
                SetPlayerToFreeroam(playerid);
                }
                }
                if(isafk[playerid] == 1)
                {
                if(!IsPlayerInRangeOfPoint(playerid, 50.0, xafk[playerid],yafk[playerid],zafk[playerid]))
                {
                CallLocalFunction( "OnPlayerCommandText", "ds", playerid,"/safk");
                }
                }
}



Re: one of server timers sometimes can stop suddenly - Glint - 08.07.2012

Can you tell me why do you use a timer for checking if a player is inside a location or not you can use other method's


Re: one of server timers sometimes can stop suddenly - pasha97 - 08.07.2012

Quote:
Originally Posted by Lexi'
Посмотреть сообщение
Can you tell me why do you use a timer for checking if a player is inside a location or not you can use other method's
So, what other methods can you suggest? If player is in dm, he must always be in dm place, if player is in mission, he must always be in mission place, and if he leaves this place he automatically returns to freeroam


Re: one of server timers sometimes can stop suddenly - Roko_foko - 08.07.2012

Try to add in your for loop on beginning if(!IsPlayerConnected(playerid))continue;

Also, I would SetTimer("dmcheck",1000,true); from gamemodeinit change to SetTimer("dmcheck",4000(or more),true); ==> because dmcheck2 timer will be called 3 times in 3 seconds( before it is finished it will be called two times more)


Re: one of server timers sometimes can stop suddenly - pasha97 - 08.07.2012

Quote:
Originally Posted by Roko_foko
Посмотреть сообщение
Try to add in your for loop on beginning if(!IsPlayerConnected(playerid))continue;
didnt understand u
Quote:

Also, I would SetTimer("dmcheck",1000,true); from gamemodeinit change to SetTimer("dmcheck",4000(or more),true); ==> because dmcheck2 timer will be called 3 times in 3 seconds( before it is finished it will be called two times more)

ok ill do


Re: one of server timers sometimes can stop suddenly - Roko_foko - 08.07.2012

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
        {
                if(!IsPlayerConnected(playerid))continue;//<-----
                if(mission[i]> 0)
                {
                if(!IsPlayerInRangeOfPoint(i, 500.0, -1339.1575,1302.2576,1.6600))
                {
                SetPlayerTimerI("dmche
//...



Re: one of server timers sometimes can stop suddenly - iggy1 - 08.07.2012

Try running crashdetect plugin if you cant find your answer.

Every single time i access an array out of bounds at runtime, my timers stop working. And even though this will not crash your server, crashdetect will pick up on it and print an error to your log.


Re: one of server timers sometimes can stop suddenly - pasha97 - 08.07.2012

Quote:
Originally Posted by Roko_foko
Посмотреть сообщение
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
        {
                if(!IsPlayerConnected(playerid))continue;//<-----
                if(mission[i]> 0)
                {
                if(!IsPlayerInRangeOfPoint(i, 500.0, -1339.1575,1302.2576,1.6600))
                {
                SetPlayerTimerI("dmche
//...
you mean if(!IsPlayerConnected(i))continue;//<----


Re: one of server timers sometimes can stop suddenly - Roko_foko - 08.07.2012

Quote:
Originally Posted by pasha97
Посмотреть сообщение
you mean if(!IsPlayerConnected(i))continue;//<----
yeah


Re: one of server timers sometimes can stop suddenly - pasha97 - 08.07.2012

Quote:
Originally Posted by iggy1
Посмотреть сообщение
Try running crashdetect plugin if you cant find your answer.

Every single time i access an array out of bounds at runtime, my timers stop working. And even though this will not crash your server, crashdetect will pick up on it and print an error to your log.
tnx ill try