19.12.2010, 01:53
I have a problem when making a timer. Look at part of my script.
On the top of the script:
And then, I added these functions:
And, I added this in OnPlayerCommandText (Somewhere in it):
I used the command, I saw that 1 second elapsed message (which is the debug I wanted), but the take over doesn't. I've wait for 1 minute and still nothing happened (I count with the debug). Anyone can help please?
On the top of the script:
pawn Code:
forward takeover(playerid, gangzoneid);
forward counter(playerid, gangzoneid);
pawn Code:
//Gangzone Functions
public takeover(playerid, gangzoneid)
{
new string[256];
if(GetGangzoneOwner(gangzoneid) >= 0)
{
format(string, sizeof(string), "|- {FFFF00}%s {00FF00}has successfully taking 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 taking over a territory -|", PlayerName(playerid));
SendClientMessageToAll(0x00FF00AA, string);
}
GangzoneOwner[gangzoneid] = GetPlayerTeam(playerid);
GangzoneChangeOwner[gangzoneid] = -1;
GangZoneHideForAll(gangzoneid);
GangZoneShowForAll(gangzoneid, GetPlayerColor(playerid));
GangzoneColor[gangzoneid] = GetPlayerColor(playerid);
KillTimer(GetPVarInt(playerid, "gzcounter"));
}
public counter(playerid, gangzoneid)
{
new Float:junk, Float:y;
new string[256];
GetPlayerPos(playerid, junk, y, junk);
if(IsPlayerInRangeOfPoint(playerid, 30, GangzoneCheckpoint[gangzoneid][0], y, GangzoneCheckpoint[gangzoneid][2]))
{
if(!IsPlayerInRangeOfPoint(playerid, 20, 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, 2);
}
}
else
{
GameTextForPlayer(playerid, "~r~You failed on trying to ~y~takeover~r~ this territory", 4000, 2);
format(string, sizeof(string), "|- {FFFF00}%s {FF0000}has failed on trying to takeover the territory -|", PlayerName(playerid));
SendClientMessageToAll(0xFFFF00AA, string);
KillTimer(GetPVarInt(playerid, "gztimer"));
KillTimer(GetPVarInt(playerid, "gzcounter"));
}
SendClientMessage(playerid, 0xFFFF00AA, "1 second elapsed"); //This is the debug
}
pawn Code:
SetPVarInt(playerid, "gztimer", SetTimerEx("takeover", 60000, false, "ii", playerid, IsPlayerInGangzoneCheckpoint(playerid)));
SetPVarInt(playerid, "gzcounter", SetTimerEx("counter", 1000, true, "ii", playerid, IsPlayerInGangzoneCheckpoint(playerid)));