Raised This Month: $99 Target: $400
 24% 

String to array


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
boomix
Senior Member
Join Date: May 2015
Location: Latvia
Old 05-27-2015 , 18:27   String to array
Reply With Quote #1

Hello!

Very simple question, how can I make from String array?

String looks like this

weapons = "weapon_awp;weapon_smokegrenade;weapon_deagle "

I want after some kind of function to make it look like this

weapon[0] is weapon_awp
weapon[1] is weapon_smokegrenade
weapon[2] is weapon_deagle


And is it possible to count, how many weapons are in array? Thanks alot!

Last edited by boomix; 05-27-2015 at 18:56.
boomix is offline
Darkness_
Veteran Member
Join Date: Nov 2014
Old 05-27-2015 , 18:48   Re: String to array
Reply With Quote #2

I think this works; not totally sure though.

PHP Code:
const char[][] szWeapons = { "weapon_awp""weapon_deagle" }; 
And then just do sizeof(szWeapons) to get the size.
Darkness_ is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 05-27-2015 , 19:03   Re: String to array
Reply With Quote #3

ExplodeString is what you're looking for, I think
__________________
View my Plugins | Donate
TnTSCS is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 05-27-2015 , 19:04   Re: String to array
Reply With Quote #4

If this is hard-coded, you want Darkness_'s post.
If it is coming from user input (like a convar), look at ExplodeString.
__________________
asherkin is offline
boomix
Senior Member
Join Date: May 2015
Location: Latvia
Old 05-27-2015 , 19:27   Re: String to array
Reply With Quote #5

Thanks!
Thats what I was searching for - ExplodeString!
boomix is offline
Reply


Thread Tools
Display Modes

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 21:23.


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