Extract data from string
word1#word2#word3#
Is it possible to fill an array with words before each # Loads on round start |
Re: Extract data from string
Of course there is a way. Explain exactly what you're trying to do because there may be a different way to go about this. If not, I can show you how to parse the values.
|
Re: Extract data from string
I was actually thinking of creating an array which contains weapons each player class should have, like
weapon_glock18#weapon_deagle# And on round start to give_item |
Re: Extract data from string
Why #? Why not comma or space?
|
Re: Extract data from string
Are you planning on reading this info from a cvar or a file? If not, and you are hard coding this, it doesn't make sense to store the info in a string.
If you are reading it from a cvar or a file, a comma is probably recommended because it's more common (and proper for any list in a written language) and will therefore be more easily understood. |
Re: Extract data from string
Can be space, comma, doesn't really matter.
Lets go with the file then. I am preety sure I already know how to do this from a file, but don't know how to parse data if I have x weapons for each class. |
Re: Extract data from string
Something like that?
PHP Code:
|
Re: Extract data from string
I don't really see how that helps
I have managed to make this and it works for up to 2 weapons with this code. Is there a better way to parse data for X number of weapons or must i make more if conditions for more weapons PHP Code:
|
Re: Extract data from string
Of course there is a better way. Look into strtok and also the new file natives. Don't use read_file/write_file, they are old and dreprecated.
|
Re: Extract data from string
Here is an example that answers your original question:
PHP Code:
|
| All times are GMT -4. The time now is 20:42. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.