Question and help ,i give rep + 1 thanks.
#1

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.
Reply
#2

If you could explain more, it would be more easy to help.
Reply
#3

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);
}
Reply
#4

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.
Reply
#5

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)
Reply
#6

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.
Reply
#7

@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.
Reply
#8

@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.
Reply
#9

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.
Reply
#10

@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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)