SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 21/09/2019, 11:24 AM   #11
B3x7K
Big Clucker
 
B3x7K's Avatar
 
Join Date: Aug 2017
Location: 惑星黒トカゲ
Posts: 69
Reputation: 3
Default Re: Returning strings and arrays

Quote:
Originally Posted by darkdrago View Post
Really nice tutorial, well explained! +REP

Code:
new string[] = "Hello_Hello";
str_replace("_","",string);
print(string); //Will output "HelloHello"

stock str_replace(needle[], replace[], haystack[]) //By JaTochNietDan
{
    new index = strfind(haystack, needle, true);
    
    while(index != -1)
    {
        strdel(haystack, index, index + strlen(needle));
        strins(haystack, replace, index, strlen(haystack));
        
        index = strfind(haystack, needle, true);
    }
}
About the other thing you asked, i don't get what are you asking for, your code should work already, you just need to declare
Code:
new txt[10]; //Depending on how much characters you need on this string
inside the callback
Please see the post and my question because i think you didn't get it, and why i would use strreplace if i can just replace directly...

For example:
Code:
new idx;
if ((idx = strfind(string, '_', true)) != -1)
       string[idx] = ' ';
__________________

HOW TO ENGLISH?!
AAAAAAAAAAAAAAAA

B3x7K is offline   Reply With Quote
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tag mismatch returning arrays Baboon Scripting Help 2 02/01/2019 07:47 PM
Returning strings or floats PowerPC603 Scripting Help 5 19/12/2013 09:29 PM
Returning Strings TheLazySloth Scripting Help 4 22/01/2012 12:36 PM
Returning 2 strings letters Help Archive 8 16/08/2011 10:24 AM
Returning arrays niCe Help Archive 3 28/11/2009 12:45 AM


All times are GMT. The time now is 02:40 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.