SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 25/12/2010, 04:25 AM   #1
VirSpectorX
Big Clucker
 
Join Date: Nov 2009
Posts: 109
Reputation: 0
Default Timer Doesn't Run!

I have a problem. I have this script:

Code:
GangZoneFlashForAll(GangzoneRealID[IsPlayerInGangzoneCheckpoint(playerid)], GetPlayerColor(playerid));

new gztimer
gztimer = SetTimerEx("takeover", 1000, true, "ii", playerid, IsPlayerInGangzoneCheckpoint(playerid))

SetPVarInt(playerid, "gztimer", gztimer);

(Note: IsPlayerInGangzoneCheckpoint returns a gangzone ID, which isn't the "real" ID of it. The real ID of it is in GangzoneRealID array)

And, I also add a the function already (public and already forwarded):
Code:
public takeover(playerid, gangzoneid)
{
    new string[256];
    GangzoneChangeTimer[gangzoneid] += 1;
    if(GangzoneChangeTimer[gangzoneid] == 60)
    {
        if(GetGangzoneOwner(gangzoneid) >= 0)
        {
            format(string, sizeof(string), "|- {FFFF00}%s {00FF00}has successfully taken over the territory of {FFFF00}%s {00FF00} -|", PlayerName(playerid), GetTeamName(GetGangzoneOwner(gangzoneid)));
            SendClientMessageToAll(0x00FF00AA, string);
        }
        else
        {
            format(string, sizeof(string), "|- {FFFF00}%s {00FF00}has successfully taken over the territory -|", PlayerName(playerid));
            SendClientMessageToAll(0x00FF00AA, string);
        }

        new savefile[125];
        format(savefile, sizeof(savefile), "/territory/%i.ter", gangzoneid);
        dini_IntSet(savefile, "owner", GetPlayerTeam(playerid));

        GangzoneOwner[gangzoneid] = GetPlayerTeam(playerid);
        GangzoneChangeOwner[gangzoneid] = -1;

        GangZoneHideForAll(GangzoneRealID[gangzoneid]);
        GangZoneShowForAll(GangzoneRealID[gangzoneid], GetPlayerColor(playerid));
        GangzoneColor[gangzoneid] = GetPlayerColor(playerid);

        KillTimer(GetPVarInt(playerid, "gztimer"));
    }
    else
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        if(IsPlayerInRangeOfPoint(playerid, 30, GangzoneCheckpoint[gangzoneid][0], y, GangzoneCheckpoint[gangzoneid][2]))
        {
            if(!IsPlayerInRangeOfPoint(playerid, 15, GangzoneCheckpoint[gangzoneid][0], y, GangzoneCheckpoint[gangzoneid][2]))
            {
                GameTextForPlayer(playerid, "~w~Watch out! ~r~You're too far from the ~y~checkpoint!~n~~w~Go back to the checkpoint!", 2000, 3);
            }
        }
        else
        {
            GameTextForPlayer(playerid, "~r~You have failed on trying to ~y~takeover~r~ this territory", 4000, 3);

            format(string, sizeof(string), "|- {FFFF00}%s {FF0000}has failed to take over the territory -|", PlayerName(playerid));
            SendClientMessageToAll(0xFFFF00AA, string);

            KillTimer(GetPVarInt(playerid, "gztimer"));
        }

        new mes[10];
        format(mes, sizeof(mes), "~w~%i", 60 - GangzoneChangeTimer[gangzoneid]);
        GameTextForPlayer(playerid, mes, 1001, 3);
    }
    return print("Timer run"); //This is a debug.
}

But it doesn't run! I tried removing the "return" stuff from the function and it still doesn't work!
Can anyone help please?
VirSpectorX is offline  
Old 25/12/2010, 05:14 AM   #2
Krx17
Huge Clucker
 
Krx17's Avatar
 
Join Date: Jul 2010
Posts: 454
Reputation: 22
Default Re: Timer Doesn't Run!

Are you sure it isn't running. Do this, add a print("test") line to the timer, then run the gamemode. Then while gamemode is running, check the server console to see if "test" is being printed. If it is, timer is running.
Krx17 is offline  
Old 25/12/2010, 09:50 AM   #3
VirSpectorX
Big Clucker
 
Join Date: Nov 2009
Posts: 109
Reputation: 0
Default Re: Timer Doesn't Run!

I did, and it isn't running.

And anyway, I've solved it, somehow I used for the timer to repeat with 1 instead of 1000 and it works. I don't know, maybe it's changed in 0.3c, maybe?
VirSpectorX is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
timer bug Andy_McKinley Help Archive 2 07/07/2010 09:01 AM
set timer ex help [mad]MLK Help Archive 1 10/09/2009 03:15 PM
Timer JoeDaDude Help Archive 6 22/04/2009 07:27 PM
help, timer... user226 Help Archive 3 22/04/2009 01:25 PM
Timer? Snyper18 Help Archive 2 08/03/2009 02:34 PM


All times are GMT. The time now is 06:24 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.