Sorry For To Much Help!
#6

I just wrote this not tested it but should work. Requires sscanf plugin and zcmd.
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))//read about strcmp on the wiki you could make it only require a partial string to match or change the case sensitivity on the comparisons.
                {
                    SetPlayerName(i, newname);
                    count++;
                    break;
                }
            }
        }
        if(!pCount)
            SendClientMessage(playerid, -1, "ERROR: Player Not Found!");
    }
    return 1;
}
EDIT: I messed the loop up, i fixed it now silly mistake sorry.
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)