Question and help ,i give rep + 1 thanks. -
buburuzu19 - 04.11.2014
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.
Re: Question and help ,i give rep + 1 thanks. -
iSkate - 04.11.2014
If you could explain more, it would be more easy to help.
Re: Question and help ,i give rep + 1 thanks. -
HY - 04.11.2014
Setting a Timer, first:
pawn Код:
SetTimer("WantedLevel", 100000, false);
- I setted it at 100 seconds, change it, with your time wich you want to decrease level !
- Then we need to make a new public, from WantedLevel Timer;
pawn Код:
forward WantedLevel();
public WantedLevel()
{
new playerid;
SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid)-1);
}
Re: Question and help ,i give rep + 1 thanks. -
buburuzu19 - 04.11.2014
You didn't understand.
I made a timer. That timer is decreasing every 30 minutes 1 wanted star.I want to make a command who can show me the time left before loosing another wanted star.
Ex:/timestar You have to wait 14:36 minutes to loose another wanted star.
Re: Question and help ,i give rep + 1 thanks. -
Madzior_ - 04.11.2014
IMO you can do something like this:
pawn Код:
// 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)
Re: Question and help ,i give rep + 1 thanks. -
M4D - 04.11.2014
Quote:
Originally Posted by HY
Setting a Timer, first:
pawn Код:
SetTimer("WantedLevel", 100000, false);
- I setted it at 100 seconds, change it, with your time wich you want to decrease level !
- Then we need to make a new public, from WantedLevel Timer;
pawn Код:
forward WantedLevel();
public WantedLevel() { new playerid; SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid)-1); }
|
1. WTF !!! you define new variable "playerid" ! and set his wanted ? and i ask you... who is playerid ?!!!
you have to make a loop between players !!!!!
2.and pay attention that if someone has 0 wanted and you use : SetPlayerWantedLevel(playerid,GetPlayerWantedLevel (playerid)-1);
it will be set his wanted to 255 !
and help
you can use PVars and GetTickCount!
To give you an example (using zcmd and foreach, you can use other command processors and other loops):
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;
}
i writed it to fast so don't copy and paste it ! if you got errors tell me !
Good Luck.
Re: Question and help ,i give rep + 1 thanks. -
buburuzu19 - 04.11.2014
@madizor Ok. I didn't tested it yet but seems to be working. Can you make a e.g. command and put your line with x = 180000 in it?i can't figure out how to use this.
Re: Question and help ,i give rep + 1 thanks. -
buburuzu19 - 04.11.2014
@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.
Re: Question and help ,i give rep + 1 thanks. -
Madzior_ - 04.11.2014
This command should work. You can try configure it to adapt it to your gamemode.
pawn Код:
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;
}
Also read about
GetTickCount.
Re: Question and help ,i give rep + 1 thanks. -
buburuzu19 - 04.11.2014
@Madizor thx,
@M4D read this
Quote:
Originally Posted by buburuzu19
@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.
|