SA-MP Forums Archive
Server crashes upon changing name - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Server crashes upon changing name (/showthread.php?tid=343728)



Server crashes upon changing name - Supercop - 18.05.2012

I know that if the server crashes upon typing a command indicates a fault in the scriptfiles folder, although I couldn't figure out anything, I hope some of you who have more experience on scripting than I do can help me with it, thanks in advance.

pawn Код:
command(changename, playerid, params[])
{
    new id, NewName[MAX_PLAYER_NAME];
    if(sscanf(params, "uz", id, NewName))
    {
        if(Player[playerid][AdminLevel] >= 4)
        {
            SendClientMessage(playerid, WHITE, "SYNTAX: /changename [playerid] [new name]");
        }
    }
    else
    {
        new NameStr[40], CurrentName[MAX_PLAYER_NAME], string[128];
       
        if(Player[playerid][AdminLevel] >= 4)
        {
            if(Player[id][AdminLevel] >= 1 && Player[playerid][AdminLevel] < 5)
            {
                SendClientMessage(playerid, WHITE, "You cannot adjust the name of another Administrator unless being Head Admin.");
            }
            else
            {
                if(Player[playerid][AdminLevel] >= Player[id][AdminLevel])
                {
                    if(strlen(NewName) >= 3 && strlen(NewName) < MAX_PLAYER_NAME)
                    {
                        GetPlayerName(id, CurrentName, sizeof(CurrentName));
                        //format(string, sizeof(string), "scriptfiles/Accounts/%s.ini", CurrentName);
                        format(NameStr, sizeof(NameStr), "Accounts/%s.ini", NewName);

                        if(fexist(NameStr))
                        {
                            SendClientMessage(playerid, WHITE, "That account name is already registered.");
                        }
                        else
                        {
                            format(Player[id][NormalName], MAX_PLAYER_NAME, "%s", NewName);

                            //file_delete(string);
                            fremove(NameStr);
                           
                            CallRemoteFunction("OnPlayerNameChange", "ss", GetPlayerName(id), NewName);

                            SetPlayerName(id, NewName);

                            SavePlayerData(id);

                            format(string, sizeof(string), "WARNING: Server Admin %s has renamed %s to %s.", GetName(playerid), CurrentName, NewName);
                            AdminActionsLog(string);
                            NamechangeLog(string);
                            SendToAdmins(ADMINORANGE, string, 1);

                            if(Player[id][Business] >= 1 || Player[id][House] >= 1)
                            {
                                if(strcmp(Businesses[Player[id][Business]][bOwner], CurrentName, true) == 0)
                                {
                                    format(Businesses[Player[id][Business]][bOwner], MAX_PLAYER_NAME, "%s", NewName);
                                }

                                if(strcmp(Houses[Player[id][House]][hOwner], CurrentName, true) == 0)
                                {
                                    format(Houses[Player[id][House]][hOwner], 255, "%s", NewName);
                                }
                            }

                            format(string, sizeof(string), "Your name has been changed from %s to %s, by %s.", CurrentName, NewName, Player[playerid][AdminName]);
                            SendClientMessage(id, WHITE, string);

                            SendClientMessage(id, GREY, "Don't worry about re-connecting, just don't forget to change your name in the connection client!");

                        }

                    }
                    else
                    {
                        format(string, sizeof(string), "Names must be 3 - %d characters in length.", MAX_PLAYER_NAME);
                        SendClientMessage(playerid, WHITE, string);
                    }
                }
            }
        }
    }
    return 1;
}



Re: Server crashes upon changing name - Supercop - 22.05.2012

Still need help.


Re: Server crashes upon changing name - JaKe Elite - 22.05.2012

what saving system are you using? if its dini i can help.


Re: Server crashes upon changing name - Supercop - 22.05.2012

It is Dini.