player variable in array problem... -
knackworst - 15.10.2011
Hello, I'm creating a simple servershop system where you can buy some stuff that gives u advantages on my server...
ofcourse this is not that hard, but I wanna make it a bit professional, so instead of just doing: if(listitem == 1)
then SetPlayerMoney++
or something, no...
I'm making that u have a list of stuff to buy, and when u already bought something it turns green
else its just white...
ok so I have this enum to make easy buyable stuff(achievements in this case)
pawn Код:
enum Shops
{
shop_name[500],
shop_costmoney,
shop_costscore,
shop_reward[500],
shop_unlocked[MAX_PLAYERS],
}
new ServerShop[1][Shops]=
{
{"No more speeding control", 150000, 10 , "You have bought 'No More Speeding Control' you cannot be caught by speedtraps no more!", 0}
};
ok as u can see theres:
pawn Код:
shop_unlocked[MAX_PLAYERS],
I do this to check if the player has already bought the shop item...
then the command to show the shop:
pawn Код:
if ( !strcmp( "/servershop", cmdtext, true, 11 ) )
{
for(new i; i<sizeof ServerShop ; i++)
{
if(ServerShop[i][shop_unlocked[playerid]] == 0]) //Error line
{
format(string, sizeof(string), "{00FF00}%s \n\t{00FF00}Already Bought",ServerShop[i][shop_name], ServerShop[i][shop_costmoney], ServerShop[i][shop_costscore]);
ShowPlayerDialog(playerid,72,DIALOG_STYLE_LIST,"{E4FF47}Server Shop", string ,"Select", "Cancel");
}
else if(ServerShop[i][shop_unlocked[playerid]] == 1])
{
format(string, sizeof(string), "{FFFFFF}%s \n\t{FFFFFF}%i Money\n\t{FFFFFF}%i Score",ServerShop[i][shop_name], ServerShop[i][shop_costmoney], ServerShop[i][shop_costscore]);
ShowPlayerDialog(playerid,72,DIALOG_STYLE_LIST,"{E4FF47}Server Shop", string ,"Select", "Cancel");
}
return 1;
}
}
but I get these errors:
Код:
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(3835) : error 028: invalid subscript (not an array or too many subscripts): "shop_unlocked"
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(3835) : warning 215: expression has no effect
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(3835) : error 001: expected token: ";", but found "]"
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(3835) : error 029: invalid expression, assumed zero
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(3835) : fatal error 107: too many error messages on one line
error line: [look at the code]
thanks in advance
Re: player variable in array problem... -
SmiT - 15.10.2011
pawn Код:
if(ServerShop[i][shop_unlocked[playerid]] == 0])
To:
pawn Код:
if(ServerShop[i][shop_unlocked[playerid]] == 0)
Re: player variable in array problem... -
knackworst - 15.10.2011
still have the 4 errors on this line
pawn Код:
if(ServerShop[i][shop_unlocked[playerid]] == 0)
Re: player variable in array problem... -
Stigg - 15.10.2011
Try:
pawn Код:
enum Shops
{
shop_name[500],
shop_costmoney,
shop_costscore,
shop_reward[500],
shop_unlocked[MAX_PLAYERS]
}
Re: player variable in array problem... -
knackworst - 15.10.2011
U haven't changed anything...
still get the errors
Re: player variable in array problem... -
Stigg - 15.10.2011
Quote:
Originally Posted by knackworst
U haven't changed anything...
still get the errors
|
You have:
pawn Код:
enum Shops
{
shop_name[500],
shop_costmoney,
shop_costscore,
shop_reward[500],
shop_unlocked[MAX_PLAYERS],//the ',' should not be here
}
Correct:
pawn Код:
enum Shops
{
shop_name[500],
shop_costmoney,
shop_costscore,
shop_reward[500],
shop_unlocked[MAX_PLAYERS]//removed the ','
}
Re: player variable in array problem... -
knackworst - 15.10.2011
oh, i see
but still doesn't work...
pawn Код:
enum Shops
{
shop_name[500],
shop_costmoney,
shop_costscore,
shop_reward[500],
shop_unlocked[MAX_PLAYERS]
}
new ServerShop[10][Shops]=
{
{"No more speeding control", 150000, 10 , "You have bought 'No More Speeding Control' you cannot be caught by speedtraps no more!", 0},
{"Instant Level 2", 100000, 0 , "You have bought 'Instant Level 2' and you are now Level 2 (120 score)", 0},
{"Instant Level 3", 200000, 0 , "You have bought 'Instant Level 3' and you are now Level 3 (180 score)", 0},
{"Save Deathpos", 500000, 50 , "You have bought 'Save Deathpos' and you will be auto spawned to your death pos when you!", 0},
{"10 Score", 25000, 0 , "You have bought 10 score points", 0},
{"50 Score", 100000, 0 , "You have bought 50 score points", 0},
{"100 Score", 1750000, 0 , "You have bought 100 score points", 0},
{"Auto Armour", 50000, 7 , "You have bought 'Auto Armour' and u can now use the command: /auto armour once every 10 minuts", 0},
{"Auto Health", 750000, 12 , "You have bought 'Auto Armour' and u can now use the command: /autp health once every 10 minuts", 0},
}; //line 157
Код:
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(157) : error 029: invalid expression, assumed zero
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(157) : error 008: must be a constant expression; assumed zero
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(3848) : error 028: invalid subscript (not an array or too many subscripts): "shop_unlocked"
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(3848) : warning 215: expression has no effect
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(3848) : error 001: expected token: ";", but found "]"
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(3848) : error 029: invalid expression, assumed zero
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(3848) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
6 Errors.
and other error line is still the same
Re: player variable in array problem... -
Stigg - 15.10.2011
Try:
pawn Код:
new ServerShop[10][Shops]=
{
{"No more speeding control", 150000, 10 , "You have bought 'No More Speeding Control' you cannot be caught by speedtraps no more!", 0},
{"Instant Level 2", 100000, 0 , "You have bought 'Instant Level 2' and you are now Level 2 (120 score)", 0},
{"Instant Level 3", 200000, 0 , "You have bought 'Instant Level 3' and you are now Level 3 (180 score)", 0},
{"Save Deathpos", 500000, 50 , "You have bought 'Save Deathpos' and you will be auto spawned to your death pos when you!", 0},
{"10 Score", 25000, 0 , "You have bought 10 score points", 0},
{"50 Score", 100000, 0 , "You have bought 50 score points", 0},
{"100 Score", 1750000, 0 , "You have bought 100 score points", 0},
{"Auto Armour", 50000, 7 , "You have bought 'Auto Armour' and u can now use the command: /auto armour once every 10 minuts", 0},
{"Auto Health", 750000, 12 , "You have bought 'Auto Armour' and u can now use the command: /autp health once every 10 minuts", 0}//removed the ',' here too
}; //line 157
Re: player variable in array problem... -
knackworst - 15.10.2011
now I get:
Код:
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(157) : error 052: multi-dimensional arrays must be fully initialized
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(3848) : error 028: invalid subscript (not an array or too many subscripts): "shop_unlocked"
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(3848) : warning 215: expression has no effect
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(3848) : error 001: expected token: ";", but found "]"
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(3848) : error 029: invalid expression, assumed zero
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(3848) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
5 Errors.
Re: player variable in array problem... -
knackworst - 15.10.2011
SOLVED
Seemed to be not that hard even for me
-_-
no reps since noones help actually helped