Where need put command code to make it work self
#1

Sup!
i find lottery script and it have /startlotto command bat i want make it without command just when server online this system start by her self
Код:
CMD:startlotto(playerid,params[])
{
   new startername[MAX_PLAYER_NAME],stri[200];
   if(IsLottoStarted==true)return SendClientMessage(playerid, 0xFF4500AA, "Lottery has already been started");
   IsLottoStarted=true;
   GetPlayerName(playerid,startername,sizeof(startername));
   format(stri,sizeof(stri),"%s has started Lottery",startername);
   SendClientMessageToAll(0xCCFF00,stri);
   format(stri,sizeof(stri),"It will be drawed after %i minutes.",lottogap);
   SendClientMessageToAll(0xCCFF00,stri);
   format(stri,sizeof(stri),"Current lottery is of %i score",lottoadd);
   SendClientMessageToAll(0xCCFF00,stri);
   format(stri,sizeof(stri),"Do /ticket [your number] to take a ticket | The number should be in range of 0-%i",numrange);
   SendClientMessageToAll(0xCCFF00,stri);
   SetTimer("draw",2000*60*lottogap,true);
   return 1;
}
I tried put this code part into ongamemodeinit
Код:
if(IsLottoStarted==true)return SendClientMessage(playerid, 0xFF4500AA, "Lottery has already been started");
IsLottoStarted=true;
GetPlayerName(playerid,startername,sizeof(startername));
format(stri,sizeof(stri),"%s has started Lottery",startername);
SendClientMessageToAll(0xCCFF00,stri);
format(stri,sizeof(stri),"It will be drawed after %i minutes.",lottogap);
SendClientMessageToAll(0xCCFF00,stri);
format(stri,sizeof(stri),"Current lottery is of %i $",lottoadd);
SendClientMessageToAll(0xCCFF00,stri);
format(stri,sizeof(stri),"Do /ticket [your number] to take a ticket | The number should be in range of 0-%i",numrange);
SendClientMessageToAll(0xCCFF00,stri);
lotto_timer=SetTimer("draw",1000*60*lottogap,true);
Bat happen nothing
Reply
#2

OK, first of all there are no parameters in OnGameModeInit so you can't do anything with "playerid". Second there is no point of sending messages at OnGameModeInit as there will be no players online at this moment, therefore nobody will see them.
Код:
public OnGameModeInit()
{
    IsLottoStarted = true;
    lotto_timer=SetTimer("draw", 1000 * 60 * lottogap, true);
    return 1;
}
This is all you need to do. Third, it's "but", not "bat". This has been annoying me for a while lol.
Reply
#3

Thanks its work bat maybe know how can i make random define? from this
#define minlottoadd 14
I want it make random like from 1-14
Reply
#4

PHP код:
new minlottoadd[][14] = 
{
      
"1",
      
"2",
      
"3",
      
"4",
      
"5",
      
"6",
      
"7",
      
"8",
      
"9",
      
"10",
      
"11",
      
"12"
      
"13",
      
"14"
};
new 
lrand random(sizeof(minlottoadd));
// and use minlottoadd[lrand] in your scripts 
Reply
#5

Pawn stopped working after this
Reply
#6

You can use random to get a random number between 1 and 14 like this:
Код:
random(13) + 1;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)