QUESTION: Transfer sscanf value to timerEx
#1

im making an /arrest cmd, but i dont know how to pass the time value to the timer, soo heres my code:

pawn Код:
CMD:arrest(playerid, params[])
{
 new id, time[120], reason[128];
 if(sscanf(params,"uds[128]", id, time, reason)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "Use: /arrest [ID] [Time] [Reason]");
 {
  if(pInfo[playerid][FactionID] == 1)
  {
    if(IsPlayerInRangeOfPoint(id, 5, 264.0432,86.6674,1001.0391)) // cela 1
    {
      new name[MAX_PLAYER_NAME], str[256], str2[256];
      GetPlayerName(id, name, sizeof(name));
      format(str, sizeof(str), "you have been arrested for %d minutes, by the reason: %s", time, reason);
      SendClientMessage(id, COLOR_RED, str);
      format(str2, sizeof(str2), "You have arrested the player: %s for %d minutes, by the reason: %s", name, time, reason);
      SendClientMessage(id, COLOR_RED, str2);
      pInfo[id][Njailed] = 1;
      LSPDTIMERJAIL[playerid] = SetTimerEx("LSPDTIMERCELL", 1000, false, "d", playerid);
    }
    else if(IsPlayerInRangeOfPoint(id, 5, 263.9735,82.0618,1001.0391)) // cela 2
    {
      new name[MAX_PLAYER_NAME], str[256], str2[256];
      GetPlayerName(id, name, sizeof(name));
      format(str, sizeof(str), "you have been arrested for %d minutes, by the reason: %s", time, reason);
      SendClientMessage(id, COLOR_RED, str);
      format(str2, sizeof(str2), "You have arrested the player: %s for %d minutes, by the reason: %s", name, time, reason);
      SendClientMessage(playerid, COLOR_RED, str2);
      pInfo[id][Njailed] = 1;
      LSPDTIMERJAIL[playerid] = SetTimerEx("LSPDTIMERCELL2", 1000, false, "d", playerid);
    }
  }
 }
 return 1;
}

forward LSPDTIMERCELL(playerid);
forward LSPDTIMERCELL2(playerid);

public LSPDTIMERCELL(playerid)
{
  new lspdtimeval = time
  lspdtimeval--;
}
Reply
#2

Time is not an array but integer.

Replace
pawn Код:
time[120]
with
pawn Код:
time
and
pawn Код:
SetTimerEx("LSPDTIMERCELL", 1000, false, "d", playerid);
SetTimerEx("LSPDTIMERCELL", 1000, false, "d", playerid);
with
pawn Код:
SetTimerEx("LSPDTIMERCELL", time, false, "d", playerid);
SetTimerEx("LSPDTIMERCELL", time, false, "d", playerid);
Reply
#3

Oh i didnt know that i could use time on milliseconds, thank you
Reply
#4

and how can i define 60000 milliseconds as 1 minute, since players will use minutes and not miliseconds?
Reply
#5

Quote:
Originally Posted by ttloko2
Посмотреть сообщение
and how can i define 60000 milliseconds as 1 minute, since players will use minutes and not miliseconds?
Ever heard of arithmetic? That's how you will do it.
Reply
#6

Well 1 minute is 60000.

So just create a function of some sort to convert all miliseconds into seconds then from seconds into minutes. or just straight from miliseconds into minutes.
Reply
#7

EDIT: nvm
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)