Weird mistake?
#9

This is a lot longer code, but if this doesn't work then it is your ProxDetector or something else because this thing worked for me.

pawn Code:
CMD:b(playerid, params[])
{
    new textstr[130];
    format(textstr, sizeof(textstr), "(( %s [%i]: %s ))", ReplaceString("_", " ", PlayerName(playerid)), playerid, params);
    ProxDetector(5.0, playerid, textstr, COLOR_WHITE, COLOR_GRAD1, COLOR_GRAD2, COLOR_GRAD3, COLOR_GRAD4);
}

stock PlayerName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    return name;
}

stock ReplaceString(search[], replace[], source[])
{
    new string[256], length;
    for(new i = 0; i < strlen(source); i ++)
    {
        if(strlen(search) > 1 && i != (strlen(source) - 1))
        {
            new bool:match = false, start = i;
            for(new j = 0; j < strlen(search) && !match; j ++)
            {
                if(source[i] != search[j] && j == 0)
                {
                    string[length] = source[i];
                    match = true;
                }
                else
                {
                    if(source[i] == search[j]) i ++;
                    else match = true;
                }
            }

            if(match == true)
            {
                while(start <= i)
                {
                    string[length] = source[start];
                    length ++;
                    start ++;
                }
            }
            else
            {
                for(new j; j < strlen(replace); j ++)
                {
                    string[length] = replace[j];
                    length ++;
                }

                i = (start + (strlen(search) - 1));
            }
        }
        else
        {
            if(strlen(search) == 1 && source[i] == search[0])
            {
                for(new j; j < strlen(replace); j ++)
                {
                    string[length] = replace[j];
                    length ++;
                }
            }
            else
            {
                string[length] = source[i];
                length ++;
            }
        }
    }

    string[length] = EOS;
    return string;
}
Reply


Messages In This Thread
Weird mistake? - by JaydenJason - 07.07.2015, 14:04
Re: Weird mistake? - by Sime30 - 07.07.2015, 22:01
Re: Weird mistake? - by JaydenJason - 07.07.2015, 22:31
Re: Weird mistake? - by Sime30 - 08.07.2015, 00:40
Re: Weird mistake? - by JaydenJason - 08.07.2015, 04:40
Re: Weird mistake? - by Roberto80 - 08.07.2015, 06:32
Re: Weird mistake? - by Sime30 - 08.07.2015, 17:38
Re: Weird mistake? - by JaydenJason - 09.07.2015, 17:19
Re: Weird mistake? - by Sime30 - 09.07.2015, 18:40

Forum Jump:


Users browsing this thread: 1 Guest(s)