[Tutorial] [TUT]Lotto script
#47

OK guys. I figured it out. If you copy this script exactly, you will be able to use number 0 and you won't be able to use number 100. This is because PAWN thinks that when you state there are 100 numbers up for grabs, it thinks you mean for 0-99. I don't know if you can do anything but what I did was give 101 numbers instead of 100. Like so:

Код:
new Numbers[101]
Then to fix the problem where you can use 0 as a ticket number, I did this:

All this comes under dcmd_lotto(playerid, params[]).
Код:
if(Num == 0)
	{
		SendClientMessage(playerid,0xE21F1FFF, "You cannot use 0 or any other number over 100."); //This appears as a rule then
		return 1;
	}
Then you must the winning number settings. You must change the way it is chosen. Not exactly. You must simply add 1 if you have a 100 numbers.

Код:
new Lnum = random(101) + 1;
See? If you have 100 numbers. You just have to add one. But to watch out for certain problems like getting number 101 or 102, you"ll have to do this.

Код:
    new Lnum = random(101) + 1; //Picks a random number
    if(Lnum == 102) return Lnum = 102 - random(101);
    if(Lnum == 101) return Lnum = 102 - random(101);
    if(Lnum == 0) return Lnum = random(101)
There is a simpler way, but I'm too tired to write that tiny piece now so I'll write it in the morning.

EDIT: Ok, to continue with this, you don't need to add one at all.

Код:
new Lnum = random(100) + 1; //Picks a random number
That code above ^^^ is much cleaner. That never really needs editing. I was just so tired that I couldn't think right.
Reply


Messages In This Thread
[TUT]Lotto script - by [HiC]TheKiller - 15.07.2010, 11:35
Re: [TUT]Lotto script - by willsuckformoney - 15.07.2010, 11:37
Re: [TUT]Lotto script - by jamesbond007 - 15.07.2010, 11:58
Re: [TUT]Lotto script - by [HiC]TheKiller - 15.07.2010, 12:00
Re: [TUT]Lotto script - by jamesbond007 - 15.07.2010, 12:02
Re: [TUT]Lotto script - by Aleluja - 15.07.2010, 13:22
Re: [TUT]Lotto script - by ViruZZzZ_ChiLLL - 15.07.2010, 14:07
Re: [TUT]Lotto script - by Kar - 16.07.2010, 02:52
Re: [TUT]Lotto script - by FireCat - 16.07.2010, 10:08
Re: [TUT]Lotto script - by Amit_B - 17.07.2010, 16:02
Re: [TUT]Lotto script - by DiddyBop - 17.07.2010, 16:53
Re: [TUT]Lotto script - by willsuckformoney - 17.07.2010, 21:43
Re: [TUT]Lotto script - by [HiC]TheKiller - 17.07.2010, 23:58
Re: [TUT]Lotto script - by Amit_B - 18.07.2010, 03:47
Re: [TUT]Lotto script - by Kar - 18.07.2010, 05:48
Re: [TUT]Lotto script - by Scenario - 19.07.2010, 08:34
Re: [TUT]Lotto script - by [HiC]TheKiller - 19.07.2010, 08:35
Re: [TUT]Lotto script - by Scenario - 19.07.2010, 08:38
Re: [TUT]Lotto script - by Juve913 - 23.07.2010, 08:54
Re: [TUT]Lotto script - by Armin_Avdic - 23.07.2010, 11:23
Re: [TUT]Lotto script - by Flake. - 23.07.2010, 11:45
Re: [TUT]Lotto script - by DrifteX_ - 23.07.2010, 11:49
Re: [TUT]Lotto script - by Elviss - 23.08.2010, 08:37
Re: [TUT]Lotto script - by Claude - 23.08.2010, 17:53
Re: [TUT]Lotto script - by [HiC]TheKiller - 23.08.2010, 19:39
Re: [TUT]Lotto script - by playbox12 - 24.08.2010, 15:40
Re: [TUT]Lotto script - by Elviss - 28.08.2010, 17:59
Re: [TUT]Lotto script - by [HiC]TheKiller - 28.08.2010, 21:06
Re: [TUT]Lotto script - by Lenny the Cup - 11.10.2010, 23:59
Re: [TUT]Lotto script - by [HiC]TheKiller - 12.10.2010, 03:53
Re: [TUT]Lotto script - by CrunkBankS - 16.03.2011, 16:39
Re: [TUT]Lotto script - by justsomeguy - 16.03.2011, 18:09
Re: [TUT]Lotto script - by alpha500delta - 17.03.2011, 14:21
Re: [TUT]Lotto script - by justsomeguy - 17.03.2011, 20:11
Re: [TUT]Lotto script - by Venice - 06.04.2011, 04:13
Respuesta: [TUT]Lotto script - by Host-samp - 08.04.2011, 15:28
Re: [TUT]Lotto script - by ScriptJorkis - 11.01.2012, 12:06
Re: [TUT]Lotto script - by Min - 11.01.2012, 12:52
AW: [TUT]Lotto script - by Babul - 11.01.2012, 14:41
Re: [TUT]Lotto script - by (ETR)Geto244 - 25.02.2012, 15:10
Re: [TUT]Lotto script - by [Cali]ChrOnic_T - 03.03.2012, 00:45
Re: [TUT]Lotto script - by Ukko - 28.06.2012, 14:34
Re: [TUT]Lotto script - by $$inSane - 29.06.2012, 14:28
Re: [TUT]Lotto script - by Lordzy - 29.06.2012, 14:40
Re: [TUT]Lotto script - by HighPitchedVoice - 29.06.2012, 14:56
Re: [TUT]Lotto script - by Sufrdude099 - 27.10.2012, 16:20
FIXED - by Sufrdude099 - 27.10.2012, 19:04
Re: [TUT]Lotto script - by Dawood - 16.05.2015, 14:09
Re: [TUT]Lotto script - by FernandoLight - 16.05.2015, 16:59
Re: [TUT]Lotto script - by Konverse - 16.05.2015, 17:17
Re: [TUT]Lotto script - by J0sh... - 16.05.2015, 17:19
Re: [TUT]Lotto script - by Dawood - 17.05.2015, 14:16
Re: [TUT]Lotto script - by Dawood - 18.05.2015, 14:02
Re: [TUT]Lotto script - by Luis- - 18.05.2015, 14:19
Re: [TUT]Lotto script - by jamesbond007 - 18.05.2015, 20:48

Forum Jump:


Users browsing this thread: 1 Guest(s)