Sorry For To Much Help!
#8

I messed up a bit sorry try this, i've tested and it works.
pawn Код:
COMMAND:setname(playerid, params[])
{
    new
        oldname[MAX_PLAYER_NAME], newname[MAX_PLAYER_NAME];

    if(sscanf(params, "s[24]s[24]", oldname, newname))
    {
        SendClientMessage(playerid, -1, "ERROR: Usage /setname [oldname][newname]");
        return 1;
    }
    else
    {
        new
            pCount,
            p_zName[MAX_PLAYER_NAME];
        for(new i; i != MAX_PLAYERS; i++)//would be better using foreach
        {
            if(IsPlayerConnected(i))
            {
                GetPlayerName(i, p_zName, MAX_PLAYER_NAME);
                if(!strcmp(oldname, p_zName, true, 4))//case insensitive and only the first four letters of the name are compared.
                {
                    SetPlayerName(i, newname);
                    pCount++;
                    break;
                }
            }
        }
        if(!pCount)
            SendClientMessage(playerid, -1, "ERROR: Player Not Found!");
    }
    return 1;
}
Reply


Messages In This Thread
Sorry For To Much Help! - by [Lsgw]LoL - 18.05.2011, 15:47
Re: Sorry For To Much Help! - by Marco_Valentine - 18.05.2011, 15:58
Re: Sorry For To Much Help! - by [Lsgw]LoL - 18.05.2011, 16:14
Re: Sorry For To Much Help! - by Marco_Valentine - 18.05.2011, 16:17
Re: Sorry For To Much Help! - by misho1 - 18.05.2011, 16:18
Re: Sorry For To Much Help! - by iggy1 - 18.05.2011, 16:51
Re: Sorry For To Much Help! - by [Lsgw]LoL - 18.05.2011, 17:16
Re: Sorry For To Much Help! - by iggy1 - 18.05.2011, 17:22

Forum Jump:


Users browsing this thread: 3 Guest(s)