SA-MP Forums Archive
gInfernusStock - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: gInfernusStock (/showthread.php?tid=575176)



gInfernusStock - PepsiCola23 - 24.05.2015

Hello guys i tried to add 10 infernuses in stock for dealership.If 10 infernuses are bought,you can-t buy any more infernuses.
But i get 2 errors:
PHP код:
C:\Users\Paul23\Desktop\ds\ds\ds\ds\gamemodes\dspep.pwn(25607) : error 032: array index out of bounds (variable "gInfernusStock")
C:\Users\Paul23\Desktop\ds\ds\ds\ds\gamemodes\dspep.pwn(25662) : error 032: array index out of bounds (variable "gInfernusStock")
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
2 Errors

Lines:
PHP код:
if(gInfernusStock[MAX_PLAYERS] > 0
PHP код:
gInfernusStock[MAX_PLAYERS]--; 
PHP код:
new gInfernusStock[MAX_PLAYERS] = 10



Re: gInfernusStock - Konstantinos - 24.05.2015

It's an array; thus having multiply indexes.
pawn Код:
new gInfernusStock[MAX_PLAYERS] = {10, ...};



Re: gInfernusStock - PepsiCola23 - 24.05.2015

I still dont get it,i tried to put = {10,9....0} and now i get out of bounds


Re: gInfernusStock - Vince - 24.05.2015

Why is this an array in the first place? I think you want 10 cars total, rather than 10 per player, right?


Re: gInfernusStock - PepsiCola23 - 24.05.2015

yes i want 10 cars in total.When the 10 infernus bought from ds is reach,then they can-t buy anymore.

10 cars in total for the entire server..


Re: gInfernusStock - Abagail - 24.05.2015

You don't need any additional cells:

pawn Код:
new gInfernusStock = 10;

if(gInfernusStock > 0)

gInfernusStock--;



Re: gInfernusStock - PepsiCola23 - 24.05.2015

Yes it worked thanks,but i have 1 more question, if i restart the server,the limit goes away.

So,how can i save it ?[if infernus is not in stock,if i restart ,it is again in stock,i want to be saved when i restart the server]


Re: gInfernusStock - PepsiCola23 - 25.05.2015

Up,any ideas on how to Save it?


Re: gInfernusStock - JaydenJason - 25.05.2015

depends on what you use to save, do you use sql or ini?


Re: gInfernusStock - PepsiCola23 - 25.05.2015

I use ini