09.06.2015, 23:25
What's wrong with this script. It makes me laggy and this as you can see in pic.
PHP код:
#define CHANCES 50
new LOTTO_AMOUNT;
#define LOTTO_TIME_IN_MINUTES 10// Ten minutes
#define LOTTO_MIN_RAND 20000
#define LOTTO_MAX_RAND 70000
#define COLOR_INDIGO 0x33CCFFAA
#include <a_samp>
new tplayers=0;
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
SetTimer("Lotto",LOTTO_TIME_IN_MINUTES/6000,1);
LOTTO_AMOUNT = randomnumber(100000,200000);
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
tplayers++;
}
}
new st[128];
format(st, 128, "There are currently %d players connected.",tplayers);
SendClientMessageToAll(COLOR_INDIGO, st);
return 1;
}
forward Lotto();
public Lotto()
{
new randoms[CHANCES];
#pragma unused randoms
new rand = random(sizeof(randoms));
if(!IsPlayerConnected(rand))
{
SendClientMessageToAll(COLOR_C, "Alas! There was no winner for the lotto today.");
new st[128];
format(st,128,"The current lotto: $%d. The random player this time was: %d. Better luck next time!",LOTTO_AMOUNT,rand);
SendClientMessageToAll(COLOR_INDIGO, st);
new d = randomnumber(LOTTO_MIN_RAND,LOTTO_MAX_RAND);
new newamount = LOTTO_AMOUNT +d;
LOTTO_AMOUNT = newamount;
}
else
{
new name[24],
st[128];
GetPlayerName(rand, name, 24);
GivePlayerMoney(rand, LOTTO_AMOUNT);
SendClientMessage(rand, COLOR_INDIGO, "You have won the lotto!");
format(st,128,"%s (%d) has won the lotto! Congratulations to him! Lotto amount: $%d. Go rob him!",name, rand, LOTTO_AMOUNT);
SendClientMessageToAll(COLOR_INDIGO,st);
format(st,128,"You have won ~g~$ %d~n~~r~Congrats!",LOTTO_AMOUNT);
GameTextForPlayer(rand, st, 6000, 5);
LOTTO_AMOUNT=50000;
}
return 1;
}
stock randomnumber(min, max) // ******
{
new rand = random(max-min)+min;
return rand;
}
public OnPlayerConnect(playerid)
{
tplayers++;
return 1;
}
public OnPlayerDisconnect(playerid)
{
tplayers--;
return 1;
}
public OnFilterScriptExit()
{
return 1;
}