[FS] Sistema de bingo
Autor: [PP]KIZANO | Publicado: 2011-09-25T09:41:00-07:00

hoje venho postar mais um projeto.

ele é muito simples.



Info:

Você compra bilhete depois de um certo tempo ele calcula quem ganhou.

se houver mais de um ganhador o premio é automaticamente dividido.






Créditos:

- [O.z]Caroline

- [KoS]Shickcard




Download#include &lt;a_samp&gt;

#define Time &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 15 &nbsp; &nbsp;// defina aqui o tempo em minutos para ocorrer o sorteio '-'
#define DINHEIRO_GANHA &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1000 &nbsp;// dinheiro para quem acertar o número.

new Bilhete[MAX_PLAYERS], string[128];

forward Sortear();

public OnFilterScriptInit()
{
&nbsp; &nbsp; print("###################################");
&nbsp; &nbsp; print("#- Sistema de sorteio por:");
&nbsp; &nbsp; print("#- [O.z]Caroline &amp; [KoS]ShickCard");
&nbsp; &nbsp; print("###################################");
&nbsp; &nbsp; return 1;
}


public OnPlayerConnect(playerid)
{
&nbsp; &nbsp; Bilhete[playerid] = 0;
&nbsp; &nbsp; return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{

&nbsp; &nbsp; new cmd[128], idx;
&nbsp; &nbsp; cmd = strtok(cmdtext, idx);
&nbsp; &nbsp; 
&nbsp; &nbsp; if(!strcmp(cmd, "/ComprarBilhete", true))
&nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; if(Bilhete[playerid] != 0)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return SendClientMessage(playerid, -1,"Você já tem bilhete!");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; new tmp[128];
&nbsp; &nbsp; &nbsp; &nbsp; tmp = strtok(cmdtext, idx);
&nbsp; &nbsp; &nbsp; &nbsp; if(strlen(tmp) == 0)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /ComprarBilhete [número1]");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; if(1 &gt; strlen(tmp) || strlen(tmp) &gt; 60)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return SendClientMessage(playerid, 0xFF0000AA, "Números entre 1 e 60!");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; Bilhete[playerid] = strval(tmp);
&nbsp; &nbsp; &nbsp; &nbsp; format(string, sizeof(string),"Você comprou o nª bilhete %d", strval(tmp));
&nbsp; &nbsp; &nbsp; &nbsp; SendClientMessage(playerid, -1, string);
&nbsp; &nbsp; &nbsp; &nbsp; return 1;
&nbsp; &nbsp; }
&nbsp; &nbsp; return 0;
}

public Sortear()
{
&nbsp; &nbsp; new rand = random(60);
&nbsp; &nbsp; new ganhadores = 0;
&nbsp; &nbsp; for(new i; i &lt; MAX_PLAYERS; i++)
&nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; if(IsPlayerConnected(i))
&nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(Bilhete[i] == rand)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GivePlayerMoney(i, DINHEIRO_GANHA / ganhadores );
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ganhadores++;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; }
&nbsp; &nbsp; format(string, sizeof(string),"Teve %d Ganhadores, número sorteado: %d, cada um ganhou %d", ganhadores, rand, DINHEIRO_GANHA / ganhadores);
&nbsp; &nbsp; SendClientMessageToAll(-1, string);
&nbsp; &nbsp; return 1;
}


strtok(const strrr[], &amp;index)
{
&nbsp; &nbsp; new length = strlen(strrr);
&nbsp; &nbsp; while ((index &lt; length) &amp;&amp; (strrr[index] &lt;= ' '))
&nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; index++;
&nbsp; &nbsp; }

&nbsp; &nbsp; new offset = index;
&nbsp; &nbsp; new result[20];
&nbsp; &nbsp; while ((index &lt; length) &amp;&amp; (strrr[index] &gt; ' ') &amp;&amp; ((index - offset) &lt; (sizeof(result) - 1)))
&nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; result[index - offset] = strrr[index];
&nbsp; &nbsp; &nbsp; &nbsp; index++;
&nbsp; &nbsp; }
&nbsp; &nbsp; result[index - offset] = EOS;
&nbsp; &nbsp; return result;
}