SA-MP Forums Archive
QUESTION: Transfer sscanf value to timerEx - 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)
+--- Thread: QUESTION: Transfer sscanf value to timerEx (/showthread.php?tid=316696)



QUESTION: Transfer sscanf value to timerEx - ttloko2 - 08.02.2012

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--;
}



Re: QUESTION: Transfer sscanf value to timerEx - T0pAz - 08.02.2012

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);



Re: QUESTION: Transfer sscanf value to timerEx - ttloko2 - 08.02.2012

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


Re: QUESTION: Transfer sscanf value to timerEx - ttloko2 - 08.02.2012

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


Re: QUESTION: Transfer sscanf value to timerEx - T0pAz - 08.02.2012

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.


Re: QUESTION: Transfer sscanf value to timerEx - Shadow_ - 08.02.2012

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.


Re: QUESTION: Transfer sscanf value to timerEx - ttloko2 - 08.02.2012

EDIT: nvm