No removing underscore.
#2

We already went through this:
pawn Код:
// ** INCLUDES

#include <a_samp>

// ** MAIN

main()
{
    print("Loaded \"replace_underscore_with_space.amx\".");

    new source[20] = "CaNDy_Boy_Mr Sr_Hey";
    ReplaceUnderscoreWithSpace(source);

    printf("%s", source);
}

// ** CALLBACKS

public OnGameModeInit()
{
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

// ** FUNCTIONS

stock ReplaceUnderscoreWithSpace(source[])
{
    for(new i = 0, j = strlen(source); i < j; i ++)
    {
        if(source[i] == '_')
        {
            source[i] = ' ';
        }
    }
    return 1;
}
pawn Код:
// ** INCLUDES

#include <a_samp>

// ** MAIN

main()
{
    print("Loaded \"replace_string.amx\".");

    new source[20] = "CaNDy_Boy_Mr Sr_Hey";
    ReplaceString(source, "_", " ");

    printf("%s", source);
}

// ** CALLBACKS

public OnGameModeInit()
{
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

// ** FUNCTIONS

stock ReplaceString(source[], const search[], const replace[], size_of = sizeof(source))
{
    new search_length = strlen(search), temp, last_pos;
    for(;;)
    {
        temp = strfind(source, search, false, last_pos);

        if(temp != -1)
        {
            strdel(source, temp, (temp + search_length));
            strins(source, replace, temp, size_of);

            last_pos = (temp + search_length);
        }
        else
        {
            break;
        }
    }
    return 1;
}
Reply


Messages In This Thread
No removing underscore. - by Alex_T - 27.12.2015, 22:31
Re: No removing underscore. - by SickAttack - 27.12.2015, 22:33
Re: No removing underscore. - by Vince - 27.12.2015, 22:56
Re: No removing underscore. - by Alex_T - 28.12.2015, 17:10

Forum Jump:


Users browsing this thread: 1 Guest(s)