gInfernusStock
#1

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
Reply
#2

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

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

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

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..
Reply
#6

You don't need any additional cells:

pawn Код:
new gInfernusStock = 10;

if(gInfernusStock > 0)

gInfernusStock--;
Reply
#7

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]
Reply
#8

Up,any ideas on how to Save it?
Reply
#9

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

I use ini
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)