Raised This Month: $ Target: $400
 0% 

Moving a String into a array


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Zor
Veteran Member
Join Date: Mar 2004
Location: Toronto, ON
Old 10-11-2004 , 10:04  
Reply With Quote #4

Hmmm...You could use Parse and Array. Are you getting this text from a text file? So instead of Parse use the new one:

Code:
strtok(const text[], Left[], leftLen, Right[], rightLen, token=' ', trimSpaces=0)
I'll assume that strtok will return the length of the string taken....

So I would look at it like this:

Code:
//Global
new MyString[84] = "de_dust de_aztec de_nuke de_inferno"
new MyArray = new_list_string()

public plugin_cfg()
{
     new mapName[32]

     while((strtok(MyString, mapName, 31, MyString, 83, ' ', 1)) > 0)
     {
          list_push_string(MyArray, mapName)
     }
}
....
Code
....

public plugin_end()
{
    list_delete_string(MyArray)
}
....
Code
....

public MapChange(param[])
{
     new positonIwant = str_to_num(param[0])
     new mapName[32]
     list_get_string ( MyArray, positonIwant, mapName, 31)
     server_cmd("changelevel %s", mapName)
}
Well thats about it. Now thats about as dynamic as you can get it. And there are probably some errors in it. But its an idea.

Cheers!
__________________
Zor is offline
Send a message via AIM to Zor Send a message via MSN to Zor Send a message via Yahoo to Zor
 



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 17:28.


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