SA-MP Forums Archive
Syntax error with timers? - 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: Syntax error with timers? (/showthread.php?tid=465915)



Syntax error with timers? - xXitsgodzillaXx - 24.09.2013

Okay for some reason I'm getting this error:

Quote:

C:\Documents and Settings\Owner\Desktop\DDPUSI TDM\gamemodes\DDPTDM.pwn(557 : error 076: syntax error in the expression, or invalid function call

With this line, and I don't know how to fix it! Help is appreciated!

pawn Код:
timer[playerid][CityHallTimer] = SetTimerEx("CityHallTimer", 30000, false,"i",playerid);
Here is the entire function.

pawn Код:
stock ActiveCityHall(playerid)
{
    if(Spectating[playerid] == 0 || SInfo[playerid][pOnDuty] == 0)
    {
        if(UnderAttack[CityHall] == 0)
        {
            if(!IsPlayerInAnyVehicle(playerid))
            {
                UnderAttack[CityHall] = 1;
                timer[playerid][CityHallTimer] = SetTimerEx("CityHallTimer", 30000, false,"i",playerid);
                AnnounceTimer[playerid] = SetTimerEx("tensecs", 20000, false,"i",playerid);
                Captured[playerid][CityHall] = 0;
                SendClientMessage(playerid, 0xFFFFFFFF,"| - Stay in this checkpoint for 30 seconds to capture! - |");
                PlayAudioStreamForPlayer(playerid, "http://nikon.bungie.org/misc/h2dialogue/multiplayer/thirty_seconds_remaining.mp3");
                if(gTeam[playerid] == TEAM_CHINA)
                {
                  GangZoneFlashForAll(Zone[CityHall], TEAM_ZONE_COLOR_CHINA);
                }
                else if(gTeam[playerid] == TEAM_RUSSIA)
                {
                  GangZoneFlashForAll(Zone[CityHall], TEAM_ZONE_COLOR_RUSSIA);
                }
                else if(gTeam[playerid] == TEAM_USA)
                {
                  GangZoneFlashForAll(Zone[CityHall], TEAM_ZONE_COLOR_USA);
                }
                //------Message-----
                if(tCP[CityHall] == TEAM_CHINA)
                {
                  SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team CHINA");
                  SendTeamMessage(TEAM_CHINA, COLOR_GREEN,"*City Hall is under attack!");
                }
                else if(tCP[CityHall] == TEAM_RUSSIA)
                {
                  SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team RUSSIA");
                  SendTeamMessage(TEAM_RUSSIA, COLOR_GREEN,"*City Hall is under attack!");
                }
                else if(tCP[CityHall] == TEAM_USA)
                {
                  SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team USA");
                  SendTeamMessage(TEAM_USA, COLOR_GREEN,"*City Hall is under attack!");
                }
                else if(tCP[CityHall] == TEAM_NONE)
                {
                  SendClientMessage(playerid, COLOR_WHITE,"This flag is not controlled by any team");
                }
                //---------loop-------//
                for(new i = 0; i < MAX_PLAYERS; i ++)
                {
                   IsPlayerCapturing[i][CityHall] = 1;
                }
            }
            else return CaptureZoneMessage(playerid, 1);
        }
        else return CaptureZoneMessage(playerid, 2);
    }
    else return CaptureZoneMessage(playerid, 3);
    return 1;
}



Re: Syntax error with timers? - EiresJason - 24.09.2013

Try this.
pawn Код:
new cityhalltimer_[MAX_PLAYERS]; //use this if you're using it elsewhere; like in a KillTimer function.

stock ActiveCityHall(playerid)
{
    if(Spectating[playerid] == 0 || SInfo[playerid][pOnDuty] == 0)
    {
        if(UnderAttack[CityHall] == 0)
        {
            if(!IsPlayerInAnyVehicle(playerid))
            {
                UnderAttack[CityHall] = 1;
                cityhalltimer_[playerid] = SetTimerEx("CityHallTimer", 30000, false,"i",playerid);
                AnnounceTimer[playerid] = SetTimerEx("tensecs", 20000, false,"i",playerid);
                Captured[playerid][CityHall] = 0;
                SendClientMessage(playerid, 0xFFFFFFFF,"| - Stay in this checkpoint for 30 seconds to capture! - |");
                PlayAudioStreamForPlayer(playerid, "http://nikon.bungie.org/misc/h2dialogue/multiplayer/thirty_seconds_remaining.mp3");
                if(gTeam[playerid] == TEAM_CHINA)
                {
                  GangZoneFlashForAll(Zone[CityHall], TEAM_ZONE_COLOR_CHINA);
                }
                else if(gTeam[playerid] == TEAM_RUSSIA)
                {
                  GangZoneFlashForAll(Zone[CityHall], TEAM_ZONE_COLOR_RUSSIA);
                }
                else if(gTeam[playerid] == TEAM_USA)
                {
                  GangZoneFlashForAll(Zone[CityHall], TEAM_ZONE_COLOR_USA);
                }
                //------Message-----
                if(tCP[CityHall] == TEAM_CHINA)
                {
                  SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team CHINA");
                  SendTeamMessage(TEAM_CHINA, COLOR_GREEN,"*City Hall is under attack!");
                }
                else if(tCP[CityHall] == TEAM_RUSSIA)
                {
                  SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team RUSSIA");
                  SendTeamMessage(TEAM_RUSSIA, COLOR_GREEN,"*City Hall is under attack!");
                }
                else if(tCP[CityHall] == TEAM_USA)
                {
                  SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team USA");
                  SendTeamMessage(TEAM_USA, COLOR_GREEN,"*City Hall is under attack!");
                }
                else if(tCP[CityHall] == TEAM_NONE)
                {
                  SendClientMessage(playerid, COLOR_WHITE,"This flag is not controlled by any team");
                }
                //---------loop-------//
                for(new i = 0; i < MAX_PLAYERS; i ++)
                {
                   IsPlayerCapturing[i][CityHall] = 1;
                }
            }
            else return CaptureZoneMessage(playerid, 1);
        }
        else return CaptureZoneMessage(playerid, 2);
    }
    else return CaptureZoneMessage(playerid, 3);
    return 1;
}



Re: Syntax error with timers? - xXitsgodzillaXx - 24.09.2013

This why I have this.

pawn Код:
new timer[MAX_PLAYERS][50];



Re: Syntax error with timers? - JamesH - 25.09.2013

Did you try to remove timer[playerid][CityHallTimer] ?

Give it a try and use only SetTimerEx("CityHallTimer", 30000, false,"i",playerid);

PM me if you need more help into it.


Re: Syntax error with timers? - Konstantinos - 25.09.2013

CityHallTimer is used to both - for storing the timer ID and inside the enum. Just change the name to another.


Re: Syntax error with timers? - xXitsgodzillaXx - 25.09.2013

This is what im getting when I change the name.

pawn Код:
error 017: undefined symbol "CityHallTimer"



Re: Syntax error with timers? - Konstantinos - 26.09.2013

pawn Код:
timer[playerid][CityHallTimer] = SetTimerEx("OnCityHallUpdate", 30000, false,"i",playerid);

// Also replace to:
forward OnCityHallUpdate(playerid);
public OnCityHallUpdate(playerid)
And you're done!


Re: Syntax error with timers? - xXitsgodzillaXx - 27.09.2013

Quote:

error 017: undefined symbol "CityHallTimer"

So yeah, this happens lol.


Re: Syntax error with timers? - EiresJason - 27.09.2013

Put this above the command/function.
pawn Код:
new CityHallTimer;