lotto script
#1

i want set lotto clocl 20:00

PHP код:
#define FILTERSCRIPT
#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 
ii<MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            
tplayers++;
        }
    }
    new 
st[128];
    
format(st128"There are currently %d players connected.",tplayers);
    
SendClientMessageToAll(COLOR_INDIGOst);
    return 
1;
}
forward public Lotto();
public 
Lotto()
{
    new 
randoms[CHANCES];
    
#pragma unused randoms
    
new rand random(sizeof(randoms));
    if(!
IsPlayerConnected(rand))
    {
    
SendClientMessageToAll(COLOR_INDIGO"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_INDIGOst);
    new 
randomnumber(LOTTO_MIN_RAND,LOTTO_MAX_RAND);
    new 
newamount LOTTO_AMOUNT +d;
    
LOTTO_AMOUNT newamount;
    }
    else
    {
    new 
name[24],
         
st[128];
    
GetPlayerName(randname24);
    
GivePlayerMoney(randLOTTO_AMOUNT);
    
SendClientMessage(randCOLOR_INDIGO"You have won the lotto!");
    
format(st,128,"%s (%d) has won the lotto! Congratulations to him! Lotto amount: $%d. Go rob him!",namerandLOTTO_AMOUNT);
    
SendClientMessageToAll(COLOR_INDIGO,st);
    
format(st,128,"You have won ~g~$ %d~n~~r~Congrats!",LOTTO_AMOUNT);
    
GameTextForPlayer(randst60005);
    
LOTTO_AMOUNT=50000;
    }
    return 
1;
}
stock randomnumber(minmax// ******
{
    new 
rand random(max-min)+min;
    return 
rand;
}
public 
OnPlayerConnect(playerid)
{
    
tplayers++;
    return 
1;
}
public 
OnPlayerDisconnect(playerid)
{
    
tplayers--;
    return 
1;
}
public 
OnFilterScriptExit()
{
    return 
1;

there is my clock:


PHP код:
public Time()
{
    
minute++;
    if(
minute == 60)
    {
        
minute 0;
        
hour++;
        if(
hour == 24hour 0;
    }
    new 
string[6];
    
format(string,sizeof(string),"%02d:%02d",hour,minute);
    
TextDrawSetString(timetextstring);
    
SetWorldTime(hour);
    
checkevents();
    return 
1;
}
public 
checkevents()
{
    new 
st[128];
    if(
minute == && (hour == || hour == || hour == || hour == || hour == 12 || hour == 15 || hour == 18 || hour == 21))
    {
        
SetWeather(random(8));
    }
    if(
hour == 18 && minute == 0)
    {
    
format(st,128,"Today's lotto is now at $%d! The lotto will be drawn at 20:00. Good luck, everyone.",LOTTO_AMOUNT);
    
SendClientMessageToAll(COLOR_AQUAst);
    }
    if(
hour == 23 && minute == 0)
    {
    
format(st,128,"Today's lotto is now at $%d! The lotto will be drawn at 20:00. Good luck, everyone.",LOTTO_AMOUNT);
    
SendClientMessageToAll(COLOR_AQUAst);
    }
    if(
hour == 10 && minute == 0)
    {
    
format(st,128,"Today's lotto is now at $%d! The lotto will be drawn at 20:00. Good luck, everyone.",LOTTO_AMOUNT);
    
SendClientMessageToAll(COLOR_AQUAst);
    }
    if(
hour == && minute == 0)
    {
    
format(st,128,"Today's lotto is now at $%d! The lotto will be drawn at 20:00. Good luck, everyone.",LOTTO_AMOUNT);
    
SendClientMessageToAll(COLOR_AQUAst);
    }
    if(
hour == && == && minute == 0)
    {
    
TextDrawSetString(monday,"Monday");
    }
    if(
hour == && == && minute == 0)
    {
    
TextDrawSetString(monday,"Tuesday");
    }
    if(
hour == && == && minute == 0)
    {
    
TextDrawSetString(monday,"Wednesday");
    }
    if(
hour == && == && minute == 0)
    {
    
TextDrawSetString(monday,"Thursday");
    }
    if(
hour == && == && minute == 0)
    {
    
TextDrawSetString(monday,"Friday");
    }
    if(
hour == && == && minute == 0)
    {
    
TextDrawSetString(monday,"Saturday");
    }
    if(
hour == && == && minute == 0)
    {
    
TextDrawSetString(monday,"Sunday");
    }
    if(
hour == 18 && minute == 0)
    {
    
SendClientMessageToAll(COLOR_AQUA,"[GAME TIME] 18:00");
    }
    if(
hour == 12 && minute == 0)
    {
    
SendClientMessageToAll(COLOR_AQUA,"[GAME TIME] 12:00");
    }
    if(
hour == 23 && minute == 0)
    {
    
SendClientMessageToAll(COLOR_AQUA,"[GAME TIME] 23:00");
    }
    if(
hour == && minute == 0)
    {
    
SendClientMessageToAll(COLOR_AQUA,"[GAME TIME] 5:00");
    }
    return 
1;

Reply
#2

hm. the Lotto() is not getting called anywhere - is the lotto system working already?
Reply
#3

yea it's worked every 10 mins lotto will be drawn.


#define LOTTO_TIME_IN_MINUTES 10// Ten minutes

SetTimer("Lotto",LOTTO_TIME_IN_MINUTES/6000,1);
Reply
#4

It should be:
pawn Код:
SetTimer("Lotto",LOTTO_TIME_IN_MINUTES * 60000,1); // multiply instead of divide
You need to multiply, not divide.

Also, 1 minute is 60000ms, not 6000.
Reply
#5

so it's worked?

Quote:

SetTimer("Lotto",LOTTO_TIME_IN_MINUTE * 1200000,1);

Reply
#6

Quote:
Originally Posted by sscarface
Посмотреть сообщение
so it's worked?
No, just read my post and use that code, it should work.
Reply
#7

1 minute is 60000ms


so i multiplay 60000ms x 20 = 1200000 and i want lotto draw at clock 20 00.
Reply
#8

Remove this:
pawn Код:
SetTimer("Lotto",LOTTO_TIME_IN_MINUTES/6000,1);
Switch the time function (public time) with this

pawn Код:
public Time()
{
    minute++;
    if(minute == 60)
    {
        minute = 0;
        hour++;
        if(hour == 24) hour = 0;
    }
    if(hour == 20) // Change 20 to whatever time you want the lotto to draw.
    {
        lotto();
    }
    new string[6];
    format(string,sizeof(string),"%02d:%02d",hour,minute);
    TextDrawSetString(timetext, string);
    SetWorldTime(hour);
    checkevents();
    return 1;
}
Should work.

Edit: Make sure you remove the timer completely and the LOTTO_TIME_IN_MINUTES variable, since you don't need it. The variable and the killer.
You should be able to remove the timer by deleting those two lines.
pawn Код:
KillTimer(lotto);
and

pawn Код:
new lotto;
search them in the script.
Reply
#9

jimdevil13's solution is the perfect way:
the player clocks are not synced well, you need to take care for that - in your Time() callback, the SetWorldTime() syncs the player times already, the Lotto() fits into there quite well - its not a good idea to use a second (resident) timer for calling Lotto(), it will run faster (trigger lotto @ 19:50) after some time.
Reply
#10

(29652) : error 012: invalid function call, not a valid address
(29652) : error 029: invalid expression, assumed zero
(29652) : warning 215: expression has no effect
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.


29652: lotto();
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)