Raised This Month: $ Target: $400
 0% 

Solved Strings array


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Alexbruma
New Member
Join Date: Sep 2017
Old 09-09-2017 , 06:28   Strings array
Reply With Quote #1

I get
Code:
(149) : error 008: must be a constant expression; assumed zero
(166) : error 008: must be a constant expression; assumed zero
arrays and variables
Code:
int g_weaponLevel[MAXPLAYERS + 1]; 
int maxWLevel = 20;
int wLevelPrice[21] = { 6, 10, 14, 18, 22, 26, 30, 36, 42, 48, 54, 60, 68, 76, 84, 92, 100, 110, 120, 130};
char wLevelWeapon[][] = { "weapon_glock", "weapon_tec9", "weapon_deagle", "weapon_mp9", "weapon_mp7", "weapon_mac10", "weapon_m4a1_silencer", "weapon_ump45", "weapon_famas", "weapon_aug" , "weapon_sg556", "weapon_m4a1", "weapon_ak47", "weapon_galilar", "weapon_nova", "weapon_xm1014", "weapon_scar20", "weapon_bizon", "weapon_p90", "weapon_negev"};
char wLevelWeaponName[][] = { "Glock-18", "Tec-9", "Desert Eagle", "MP9", "MP7", "MAC-10", "M4A1-S", "UMP-45", "Famas", "AUG", "SG 553", "M4A4", "AK-47", "Galil AR", "Nova", "XM1014", "SCAR-20", "PP-Bizon", "P90", "Negev" };
Line 149 and 150
Code:
char weapon[128] = wLevelWeapon[g_weaponLevel[client]];
	GivePlayerItem(client, weapon);
line 165,166,167
Code:
	int price = wLevelPrice[g_weaponLevel[client]];
	char wName[128] = wLevelWeaponName[g_weaponLevel[client]];
	char pstr[64];
I'm trying to do like a level based weapon system

Last edited by Alexbruma; 09-10-2017 at 08:38.
Alexbruma is offline
AI_
Member
Join Date: Oct 2014
Location: Canada
Old 09-09-2017 , 06:59   Re: Strings array
Reply With Quote #2

Strings are not pointers in Sourcemod. You will have to use strcopy.
__________________
AI_ is offline
Alexbruma
New Member
Join Date: Sep 2017
Old 09-09-2017 , 07:36   Re: Strings array
Reply With Quote #3

Thanks for your help ^^ <3
Alexbruma is offline
AI_
Member
Join Date: Oct 2014
Location: Canada
Old 09-09-2017 , 07:37   Re: Strings array
Reply With Quote #4

Cheers.
__________________
AI_ is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 09-09-2017 , 11:28   Re: Strings array
Reply With Quote #5

You don't have to use strcopy. However, initialization (char s[128] = other) and assignment (char s[128]; s = other) are different. Initializations have to involve constant expressions, as the error says, so you can only do the latter.
Fyren is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:29.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode