 |
|
Veteran Member
|

01-04-2008
, 05:15
Re: String Help?
|
#7
|
Quote:
Originally Posted by Alka
Here...i've tested it, and works, but one little thing...read the comment at String[] :s
Code:
public plugin_cfg() //You can use your_func, i've used this for debug. :)
{
//Size 10, length 10 x).
new Array[10][10];
//Hmm, some odd thing, you must have an "." after last
//number to store it in array. Shity strotk.
//Or you can let it without "." at the end, and check the Sttring too after array.
new String[] = "1.5.15.64.34.";
new Num;
while(containi(String, ".") != -1)
{
strtok(String, Array[Num], sizeof Array[] - 1, String, sizeof String - 1, '.');
Num++;
}
for(new i = 0 ; i < sizeof Array ; i++)
{
//Magic skip.
if(!Array[i][0])
continue;
//Degug thing.
server_print("DEBUG: Array[%d] = %d", i, str_to_num(Array[i]));
//This is the magic trick.
if(containi(Array[i], "15") != -1) //Can use equal/i too. :p
server_print("DEBUG: Array[%d] matched with value %d", i, str_to_num(Array[i]));
}
}
|
Sweet, thanks.
Though.. I ran into a small problem. I commented the problem:
Code:
bool:CheckAchievement(id,achievement)
{
new Num,Array[ACHVS_NUM][ACHVS_NUM],String[64] // Right Here.
copy(String,63,g_Achvs[id]) // I have the string in a global variable. Do I need to copy it over?
new iAchievement[11]
num_to_str(achievement,iAchievement,10);
while(containi(g_Achvs[id],".") != -1)
{
strtok(String,Array[Num],sizeof(Array[]) - 1,String,sizeof(String) - 1,'.');
Num++
}
for(new i;i<sizeof(Array);i++)
{
if(!Array[i][0])
continue
if(containi(Array[i],iAchievement) != -1)
return true
}
return false
}
Running the current code, throws a "Index out of bounds" error.
EDIT: Also. "ACHVS_NUM" is defined as 10
__________________
Oh yeah
Last edited by Drak; 01-04-2008 at 05:36.
|
|
|
|