Compilation Error - HELP
#4

Why do you use 128 size in "s" specifier in sscanf when the max size of newname is 24? Max client message length is 144 so using 250 is waste. And it'd be good if you checked whether the name is valid so if you rename it to some name, that user will be able to connect to the server and he won't get rejected due to an invalid character in the name: http://forum.sa-mp.com/showpost.php?...postcount=4284

Last, you don't need sscanf for just 1 argument which is string. It can be improved a little bit:

pawn Код:
CMD:changename(playerid,params[])
{
    if (!IsSpawned[playerid]) return SendClientMessage(playerid, -1, "ERROR : You must be logged in to use this command, nigga");
    if (!pInfo[playerid][pRDonator]) return SendClientMessage(playerid, -1, "You aren't authorized.");
    if (isnull(params)) return SendClientMessage(playerid, -1, "Correct Usage: /changename [newname]");
    if (!(3 <= strlen(params) <= 24)) return SendClientMessage(playerid, -1, "ERROR: Your new name cannot be smaller than 3 or longer than 24 Characters"); //Line - Here
    //if (!IsValidUsername(params)) return SendClientMessage(playerid, -1, "ERROR: Invalid character(s).");
    new filePath[98], pName[MAX_PLAYER_NAME + 1];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(filePath, 47, "System-x32/Users/%s.ini", params);
    if (fexist(filePath)) return SendClientMessage(playerid, -1, "ERROR: name was taken, please enter a different name.");
    frename(UserPath(playerid), filePath);
    SetPlayerName(playerid, params);
    format(filePath, sizeof(filePath), "You just successfully rename your account %s to %s.", pName, params);
    SendClientMessage(playerid, -1, filePath)
    return 1;
}
Reply


Messages In This Thread
Compilation Error - HELP - by SAMProductions - 03.06.2014, 11:27
Re: Compilation Error - HELP - by Tagathron - 03.06.2014, 11:29
Re: Compilation Error - HELP - by SAMProductions - 03.06.2014, 11:31
Re: Compilation Error - HELP - by Konstantinos - 03.06.2014, 11:50

Forum Jump:


Users browsing this thread: 1 Guest(s)