SA-MP Forums Archive
'_' replace with ' ' - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: '_' replace with ' ' (/showthread.php?tid=518855)



-- FIXED - thaKing - 11.06.2014

Problem was fixed.

-- This post is too old!


Re: '_' replace with ' ' - Shockey HD - 11.06.2014

Try

pawn Код:
stock strreplace(string[], find, replace)
{
    for(new i=0; string[i]; i++)
    {
        if(string[i] == find) string[i] = replace;  
    }
    return string;
}



Re: '_' replace with ' ' - DobbysGamertag - 11.06.2014

You may be looping it wrong,

its:

pawn Код:
for(new i = 0; i<strlen(string); i++)
Also, why stock? you're writing this for your mode right? why not use a public function?


Re: '_' replace with ' ' - TakeiT - 11.06.2014

Quote:
Originally Posted by DobbysGamertag
Посмотреть сообщение
You may be looping it wrong,

its:

pawn Код:
for(new i = 0; i<strlen(string); i++)
Also, why stock? you're writing this for your mode right? why not use a public function?
Why write a public function?


Re: '_' replace with ' ' - Kyle - 11.06.2014

Код:
strreplace2(string[], const find[], const replace[], bool:ignorecase=true, count=cellmax, maxlength=sizeof(string))
{
    if(isnull(find) || isnull(string)) return 0;
    new matches;
    for(new idx, flen = strlen(find), rlen = strlen(replace), pos = strfind(string, find, ignorecase); pos != -1 && idx < maxlength && matches < count; pos = strfind(string, find, ignorecase, idx)) {
        strdel(string, pos, pos + flen);
        if(rlen) strins(string, replace, pos, maxlength);
        idx = pos + rlen;
        matches++;
    }
    return matches;
}



Re: '_' replace with ' ' - DobbysGamertag - 11.06.2014

Quote:
Originally Posted by TakeiT
Посмотреть сообщение
Why write a public function?
why use the "stock" word when you can use public. Go check out the pawn language pdf. Or SAMP Wiki explains it well.


https://sampwiki.blast.hk/wiki/Stocks


You're writing a stock, which will be used. Correct? You're using it incorrectly (my opinion)


Re: '_' replace with ' ' - thaKing - 11.06.2014

Alright.. Thx.. I understood.


Re: '_' replace with ' ' - TakeiT - 12.06.2014

Quote:
Originally Posted by DobbysGamertag
Посмотреть сообщение
why use the "stock" word when you can use public. Go check out the pawn language pdf. Or SAMP Wiki explains it well.


https://sampwiki.blast.hk/wiki/Stocks


You're writing a stock, which will be used. Correct? You're using it incorrectly (my opinion)
Lol, why use public when you can use stock? Why use stock when you can use function? Why use either when simply writing the function works too?

pawn Код:
stock Myfunction()
pawn Код:
public Myfunction()
pawn Код:
function Myfunction()
pawn Код:
Myfunction()
All work the exact same.