30 seconds radar ? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: 30 seconds radar ? (
/showthread.php?tid=231780)
30 seconds radar ? -
Shoko Lacho - 26.02.2011
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 : /
Re: 30 seconds radar ? -
deather - 26.02.2011
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.
Re : 30 seconds radar ? -
Shoko Lacho - 26.02.2011
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;
}
Re: 30 seconds radar ? -
maramizo - 26.02.2011
Make a RadarTimer2 and use RemovePlayerMarkerForPlayer (should be something like that).
Re: 30 seconds radar ? -
Mike Garber - 26.02.2011
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
}