Help With SetPlayerName
#1

Hi I been up all night trying to figure out how i can SetPlayerName From a .ini file I want it to get the name the user created for there Roleplay name The File locations is ARS_SERVERFILES and the Name line in The user.ini is [pFirstname]

I tried this but made the server shut down

pawn Код:
SetPlayerName(playerid, PlayerInfo[playerid][pFirstname]);

Please Someone Help me..
Reply
#2

Server crashes when you set a blank name. You can either, try debugging your code, or at least show us part of the code!
Reply
#3

part of what where i want it Okay..

pawn Код:
if (dialogid == 2)
    {
        new name[MAX_PLAYER_NAME], file[256], string[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), ARS_SERVERFILES, name);
        if(!response)
        {
            SendClientMessage( playerid, WHITE, "Fine, have it your way!" );
            Kick( playerid );
        }
        if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "This account is registered in our data base.", "Enter your password below, or leave if you're the wrong person", "Login", "Leave");
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) != tmp) {
            SendClientMessage(playerid, RED, "..::Invalid password::..  Re-enter your password correctly or leave!");
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "This account is registered in our data base.", "Enter your password below, or leave if you're a wrong person", "Login", "Leave");
        }
        else
        {
            PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
            PlayerInfo[playerid][pJob] = dini_Int(file, "Job");
            SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
            GivePlayerMoney(playerid, dini_Int(file, "Money"));
            SetPlayerHealth(playerid, dini_Int(file, "Health"));
            SetPlayerArmour(playerid, dini_Int(file, "Armour"));
            format(string, 128, "You have succesfully logged into your account. %s, Welcome back.", name);
            SendClientMessage(playerid, DARKBLUE, string);
            SpawnLastSaved(playerid);
            PlayerOnline[playerid] = 1;
            SetPlayerName(playerid, PlayerInfo[playerid][pFirstname]);
        }
    }
Reply
#4

Come On man.. Why everyone ignore this problem..
Reply
#5

I don't see when you load "PlayerInfo[playerid][pFirstname]". Try "printf("%s", PlayerInfo[playerid][pFirstname]);".

Since you aren't loading that string, you are setting a blank name to the player = server crash.
Reply
#6

Um that shut it down aswell what is going on grrrr.... How hard is it to change the player ingame name to the name they created In the users.ini file...

So you Understand what im try to do Ok on the client I typed in Buzzbomb Thats my account name.. Now i connected to the server it asked me to register my name so i did Now it logged me in Now it asked me for my gender then asked me for my age Now it asked me to create a Roleplay First name... So i did " Jose" So I spawned... So all i want to do is the Firstname that was stored in the UseraccountFile.ini I want it to Replace the account name with the name I created for a firstname ... So The name i want Shown Is Jose ...
Reply
#7

I know what you mean, but like I said, you aren't loading the name. Try this:
pawn Код:
PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
            PlayerInfo[playerid][pJob] = dini_Int(file, "Job");
            SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
            GivePlayerMoney(playerid, dini_Int(file, "Money"));
            SetPlayerHealth(playerid, dini_Int(file, "Health"));
            SetPlayerArmour(playerid, dini_Int(file, "Armour"));

        strcat(PlayerInfo[playerid][pFirstname], dini_Get(file, "Name")); // Change "Name" to the one in your user file. eg: "Name=Jose"
        printf("Name: %s", PlayerInfo[playerid][pFirstname]); // Testing to check if it loaded.

            format(string, 128, "You have succesfully logged into your account. %s, Welcome back.", name);
            SendClientMessage(playerid, DARKBLUE, string);
            SpawnLastSaved(playerid);
            PlayerOnline[playerid] = 1;
            SetPlayerName(playerid, PlayerInfo[playerid][pFirstname]);
Reply
#8

Idk if u can set a name to a string man...
Reply
#9

That Sucks..
Reply
#10

Quote:
Originally Posted by knackworst
Посмотреть сообщение
Idk if u can set a name to a string man...
?? A player's name is a string, so ofc you can do that.

@ post above: Try before you post!
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)