Raised This Month: $ Target: $400
 0% 

[SOLVED]Extractstr stock


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 11-27-2007 , 14:09   [SOLVED]Extractstr stock
Reply With Quote #1

Hi. I've maded a stock, but is not working as i expected...is not like "strtok" or something else... E.g i have a string...
Code:
static String[] = "wow | my stock | is working. :D";
i want to extract "my stock" from that string. Here is the stock...

Code:
stock extractstr(Source[], Char1, Char2, RetString[128])
{
 new iMaxLen;
 iMaxLen = strlen(Source);
 
 new bool:iStarted;
 new Len, TempString[256];
 
 Len = formatex(TempString, sizeof TempString - 1, "");
 
 for(new i = 0 ; i < iMaxLen ; i++)
 {
  if((Source[i] == Char2) && iStarted)
   iStarted = false;
 
  if((Source[i] == Char1) && !iStarted)
   iStarted = true;
 
  if(iStarted)
  {
   Len += formatex(TempString[Len], (sizeof TempString - 1) - Len, "%s", Source[i]);
   //i think here is the problem, because i must only add one by one char. :/
  }
 }
 trim(TempString);
 formatex(RetString, sizeof RetString - 1, "%s", TempString);
}
when i use this...

Code:
public Test(id)
{
 static String[] = "wow | my stock | is working. :D";
 static TempString[128];
 
 extractstr(String, '|', '|', TempString);
 
 client_print(id, print_chat, "Testing my stock : %s", TempString);
}
currently is printing, "| my stock | wow my is working ....and so on, mixing words :S" ,i want to show only "my stock". If anyone maybe know... :-p

Thanks.
__________________
Still...lovin' . Connor noob! Hello

Last edited by Alka; 11-29-2007 at 08:21.
Alka is offline
 


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 11:11.


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