30 seconds radar ?
#1

Hi all, I'm making a "radar" command, but I don't know how to use my timer to stop it after 30 seconds : /

Here my code

Код:
OnPlayerConnect

SetPlayerColor(playerid, 0xFFFFFF00);
_________________

CMD:ks(playerid, params[])
{
    if (Killstreaks[playerid] == 3 || Killstreaks[playerid] == 4)
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
	{
            if(IsPlayerConnected(i))
            {
                if(!IsPlayerNPC(i))
                {
		    if(Coldblooded[i]==0)
		    {
                        SetPlayerMarkerForPlayer(playerid, i, 0xFFFFFFFF);
			Radar[playerid]=1;
         		SetTimer("RadarTimer", 30000, 0);
                        Killstreaks[playerid]=0;
                    }
                }
            }
        }
    }
    return 1;
}
_________________

forward RadarTimer(playerid);
public Radartimer(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            SetPlayerMarkerForPlayer(playerid, i, 0xFFFFFF00);
            Radar[playerid]=0;
	}
    }
    return 1;
}
I know, my timer is a big fail, but really don't know how to do it : /
Reply
#2

The RadarTimer asks for a playerid but you dont send one.
Replace
Код:
SetTimer("RadarTimer", 30000, 0);
with
Код:
SetTimerEx("RadarTimer", 30000, 0,"i", playerid);
Also, your timer will call the function only after 30 seconds and not run for 30 seconds.

Explain? - SetTimer will make a timer for 30000ms (ie) 30 seconds. When the timer reaches the determined time it will call the function you've provided.
Reply
#3

So there's no way to make it only 30sec ?

If I use SetTimerEx to call a "normal" timer ?

EDIT : Done with this :

Код:
forward RadarTimer(playerid);
public RadarTimer(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            SetTimerEx("RadarTimer2", 30000, 0,"i", playerid);
        }
    }
	return 1;
}
forward RadarTimer2(playerid);
public RadarTimer2(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            SetPlayerMarkerForPlayer(playerid, i, INVISIBLE);
            uavforplayer[playerid]=0;
		}
    }
	return 1;
}
Reply
#4

Make a RadarTimer2 and use RemovePlayerMarkerForPlayer (should be something like that).
Reply
#5

pawn Код:
// TOP of the script
new timercount[MAX_PLAYERS];

// Make the timer run every second
SetTimerEx("RadarTimer2", 1000, 0,"i", playerid);

//Put this inside your timer;
timercount[playerid]++;

//And this;
if(timercount[playerid]==29) // 29 because the timercount variable starts with 0.
{
    KillTimer("RadarTimer2")
// Add w/e you wanna do when the timer stops
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)