04.11.2014, 18:15
I made a wanted level decreasing timer and i want to know how to count the time until i will loss 1 wanted star.Thanks.
SetTimer("WantedLevel", 100000, false);
forward WantedLevel();
public WantedLevel()
{
new playerid;
SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid)-1);
}
// on top
new DecreaseTime;
// in your public
DecreaseTime = GetTickCount(); // saving time of last decrease
// in your command
new x = 1800000 - (GetTickCount() - DecreaseTime); // 1800000 ms = 30 mins
// now "x" is your left time (in ms)
Setting a Timer, first:
pawn Код:
- Then we need to make a new public, from WantedLevel Timer; pawn Код:
|
SetTimer("Wanted",1800000,1);
forward Wanted();
public Wanted()
{
foreach(Player, i)
{
SetPVarInt(i, "WantedTime", GetTickCount());
if(GetPlayerWantedLevel(i) > 1) SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid)-1);
}
return 1;
}
CMD:wantedtime(playerid, params[])
{
new string[260];
new t = GetTickCount() - GetPVarInt(playerid, "WantedTime");
format(string,sizeof(string),"You have to wait %d seconds to loose another wanted star.",t/1000);
SendClientMessage(playerid,-1,string);
return 1;
}
CMD:timestar(playerid, cmd[])
{
if(GetPlayerWantedLevel(playerid) > 0) // check if player has any star
{
new x = 1800000 - (GetTickCount() - DecreaseTime);
new textstring[128];
format(textstring, sizeof(textstring), "You have to wait %d seconds to loose another wanted star.", floatround(x/1000)); // format text; floatround( ... ) is a rounded time in seconds
SendClientMessage(playerid, 0xFFFFFFFF, textstring);
}
else // if player doesn't have any star
{
SendClientMessage(playerid, 0xFFFFFFFF, "You don't have any star.");
}
return 1;
}
@M4D i will test it , btw i wanted too see how to make a thing like this cuz i am needing it for something else. I maked a dialog who shows wanted players with wanted level and name and playerid and the last thing i wanted to do was to add the time before he(the criminal) loose all his wanted stars, so , with this thing, cops would know how much time they have left to chase a wanted player.
Like you see in this photo : http://m.imgur.com/hOytkda, the last thing i need is to put the time like there , in the photo of that player. |