y_timers help !
#1

Hi! I'm using y_timers to make speedcameras ingame keep updated.

so here is some code i added to the script:

Код:
Timer:ServerHeartbeat[1000]()
{
	foreach(Player, i)
	{
		if(SpeedCamera[i] > 0)
		{
			if(SpeedCamera[i] <= 0)
			{
				SpeedCamera[i] = 0;
			}
			else
			{
				SpeedCamera[i] -= 1;
			}
		}
	}
}
And got those errors:
Код:
(41590) : error 010: invalid function or declaration
(41592) : error 010: invalid function or declaration
(41594) : error 010: invalid function or declaration
(41596) : error 010: invalid function or declaration
(41600) : error 010: invalid function or declaration
the error lines are related to the script i showed you above.

Should there be a return value? I don't understand those errors, please help me! thanks.
Reply
#2

You've done it wrong, I suggest you re-reading the YSI Wikipeadia again, try this code

pawn Код:
timer ServerHeartbeat[1000]()
{
    foreach(Player, i)
    {
        If(!IsPlayerConnected(playerid)) continue;
       
        if(SpeedCamera[i] > 0) {
        if(SpeedCamera[i] <= 0) {
            SpeedCamera[i] = 0;
        }
        else {
        SpeedCamera[i] -= 1;
        }
    }
}
Reply
#3

Quote:
Originally Posted by pds2k12
Посмотреть сообщение
You've done it wrong, I suggest you re-reading the YSI Wikipeadia again, try this code

pawn Код:
timer ServerHeartbeat[1000]()
{
    foreach(Player, i)
    {
        If(!IsPlayerConnected(playerid)) continue;
       
        if(SpeedCamera[i] > 0) {
        if(SpeedCamera[i] <= 0) {
            SpeedCamera[i] = 0;
        }
        else {
        SpeedCamera[i] -= 1;
        }
    }
}
Thanks. There was missing bracket and playerid is undefined so i deleted line "If(!IsPlayerConnected(playerid)) continue;"

now it works. thanks alot!
Reply
#4

Quote:
Originally Posted by maximthepain
Посмотреть сообщение
Thanks. There was missing bracket and playerid is undefined so i deleted line "If(!IsPlayerConnected(playerid)) continue;"

now it works. thanks alot!
No, don't delete this code If(!IsPlayerConnected(playerid)) continue; just change the playerid to i I forgot to change it , sorry
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)