[Ajuda] Valores random.. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: Non-English (
https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (
https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (
https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Valores random.. (
/showthread.php?tid=400668)
Valores random.. -
Duduloch - 19.12.2012
Assim, vou ser direto: Queria que qd o player digitasse um cmd, um valor de tempo RANDOM fosse ativado, e ao fim desse tempo random, mandasse um SendClientMessage.. Att. rep + pra quem ajudar
pawn Code:
if(strcmp("/comecartempo", cmdtext, true, 15) == 0)
{
//Comecar tempo agora
SendClientMessage(playerid, -1, "Acabou o tempo"); // No fim dele mandar isso
}
return 1;
att
Re: Valores random.. -
Duduloch - 19.12.2012
Up! Ajuda please.
Re: Valores random.. -
EditPawn - 19.12.2012
pawn Code:
CMD:rand(playerid)
{
SetTimerEx("Funcao", random(60), false, "i", playerid);
return true;
}
forward Funcao(playerid); public Funcao(playerid)
{
SendClientMessage(playerid, -1, "Acabou o tempo");
}
Simples
Re: Valores random.. -
leonardo1434 - 19.12.2012
Sу usar isto,
PHP Code:
CMD:rand(playerid)
{
SetTimerEx("Lol", TRandom(random(60),random(59)), false, "i", playerid);
return true;
}
TRandom(minuto,segundo)
{
segundo *= 1000;
minuto *= 60 * 1000;
return minuto + segundo;
}
forward Lol(playerid);
public Lol(playerid)
{
//stuff
}
Tempo pode variar de 0 atй 1h e 59 minutos.
Re: Valores random.. -
Duduloch - 19.12.2012
qero que varie de 15 segs atй 2mins.. esqueci de especificar kk
Re: Valores random.. -
leonardo1434 - 19.12.2012
PHP Code:
new tempo;
SetTimerEx("Lol", (tempo = TRandom(random(2),random(15)), tempo > 120000 ? 120000 : tempo) , false, "i", playerid);
Apenas substituir por este.
Re: Valores random.. -
Duduloch - 19.12.2012
Quote:
Originally Posted by leonardo1434
PHP Code:
new tempo;
SetTimerEx("Lol", (tempo = TRandom(random(2),random(15)), tempo > 120000 ? 120000 : tempo) , false, "i", playerid);
Apenas substituir por este.
|
Ok, muito obrigado funcionou, agora.. Se nгo й de mais pedir, poderia me explicar como funciona a conta para mudar o tempo? Att.