Can someone convert please? [FAST]
#1

pawn Код:
dcmd_changename(playerid, params[])
{
    new name[MAX_PLAYER_NAME], newname[16];
    GetPlayerName(playerid, name, sizeof(name));
    if(sscanf(params,"s", newname)) return SendClientMessage(playerid, 0xF60000AA, "USAGE: /changename [new name]");
    if(dini_Exists(newname)) return SendClientMessage(playerid, COLOUR_RED, "That name has already been taken!");
    if(strlen(params) >= 3)
    {
        format(file, sizeof(file), "users/%s.txt", name);
        dini_Set(file, "users/%s.txt", newname);
        SendClientMessage(playerid, COLOUR_GREEN, "Your name has been successfully been changed");
        SetPlayerName(playerid, newname);
    }
    else
    {
        SendClientMessage(playerid, COLOUR_YELLOW, "That name is too short, pick something else!");
    }
    return 1;
}

To strcmp?
Reply
#2

Код:
public OnPlayerCommandText( playerid, cmdtext[ ] )
{
    	if (strcmp("/changename", cmdtext, true, 10) == 0)
	{
    new name[MAX_PLAYER_NAME], newname[16];
    GetPlayerName(playerid, name, sizeof(name));
    if(sscanf(params,"s", newname)) return SendClientMessage(playerid, 0xF60000AA, "USAGE: /changename [new name]");
    if(dini_Exists(newname)) return SendClientMessage(playerid, COLOUR_RED, "That name has already been taken!");
    if(strlen(params) >= 3)
    {
        format(file, sizeof(file), "users/%s.txt", name);
        dini_Set(file, "users/%s.txt", newname);
        SendClientMessage(playerid, COLOUR_GREEN, "Your name has been successfully been changed");
        SetPlayerName(playerid, newname);
    }
    else
    {
        SendClientMessage(playerid, COLOUR_YELLOW, "That name is too short, pick something else!");
    }
    return 1;
}
I tested it not.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)