Not setting skin from MySQL?
#1

pawn Код:
public OnPlayerSpawn(playerid)
{
    PlayerSkin[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "Skin", "Accounts");
    SetPlayerSkin(playerid, PlayerSkin[playerid]);
    ResetPlayerWeapons(playerid);
    new fieldname[50];
    for(new w = 0; w < 13; w++)
    {
        format(fieldname, sizeof(fieldname), "Weapon%d", w);
        PlayerWeapons[playerid][w] = MySQL_GetValue(PlayerSQLID[playerid], fieldname, "Accounts");
        format(fieldname, sizeof(fieldname), "Weapon%dAmmo", w);
        PlayerWeaponAmmo[playerid][w] = MySQL_GetValue(PlayerSQLID[playerid], fieldname, "Accounts");

        if(PlayerWeapons[playerid][w] > 0) GivePlayerWeapon(playerid, PlayerWeapons[playerid][w], PlayerWeaponAmmo[playerid][w]);
    }
    if(AdminJail[playerid] >= 1)
    {
        new string2[128];
        format(string2, sizeof(string2), "You have %d minutes left in Admin Jail.", AdminJail[playerid]);
        SendClientMessage(playerid, COLOUR_GREY, string2);

        SetPlayerPos(playerid, 264.58, 77.38, 1001.04);
        SetPlayerInterior(playerid, 6);
        SetPlayerVirtualWorld(playerid, 0);
    }
    return 1;
}
It simply will not set this skin. Any reasons as to why? It set's as default? In the SQL, it shows the correct skin id (58.)
Reply
#2

pawn Код:
PlayerSkin[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "Skin", "Accounts");
printf("Skin: %d", PlayerSkin[playerid]); // Please debug your variable
SetPlayerSkin(playerid, PlayerSkin[playerid]);
Reply
#3

Thanks, that'll help.
Reply
#4

Edit: It didn't even display. I placed the code... It didn't print in the server.

Quote:

----------------------------------
[22:01:54] Factions Loaded
[22:01:54] ----------------------------------

[22:01:54] Number of vehicle models: 0
[22:02:50] [part] Grant_McCaw has left the server (0:0)
[22:03:00] 1 minute has passed!
[22:03:15] Incoming connection: 127.0.0.1:56722
[22:03:16] [join] Grant_McCaw has joined the server (0:127.0.0.1)
[22:04:07] 1 minute has passed!

Reply
#5

Do you perhaps use SpawnPlayer somewhere before? If I recall correctly, OnPlayerSpawn isn't called when SpawnPlayer is used.
Reply
#6

That's correct, its here:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_LOGIN)
    {
        if(response == 0)
        {
            Kick(playerid);
        }
        else
        {
            new query[300], password[128];
            format(query, sizeof(query), "SELECT `Password` FROM `Accounts` WHERE id = %d", PlayerSQLID[playerid]);
            mysql_query(query);
            mysql_store_result();
            mysql_fetch_row(password);
            mysql_free_result();
           
            if(strcmp(password, inputtext, false) == 0)
            {
                PreloadAnimLib(playerid,"BOMBER");
                PreloadAnimLib(playerid,"RAPPING");
                PreloadAnimLib(playerid,"SHOP");
                PreloadAnimLib(playerid,"BEACH");
                PreloadAnimLib(playerid,"SMOKING");
                PreloadAnimLib(playerid,"ON_LOOKERS");
                PreloadAnimLib(playerid,"DEALER");
                PreloadAnimLib(playerid,"CRACK");
                PreloadAnimLib(playerid,"CARRY");
                PreloadAnimLib(playerid,"COP_AMBIENT");
                PreloadAnimLib(playerid,"PARK");
                PreloadAnimLib(playerid,"INT_HOUSE");
                PreloadAnimLib(playerid,"FOOD");
                PreloadAnimLib(playerid,"GANGS");
                PreloadAnimLib(playerid,"PED");
                PreloadAnimLib(playerid,"FAT");

                LoggedIn[playerid] = 1;
                PlayerBanned[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "Banned", "Accounts");
                if(PlayerBanned[playerid] == 1)
                {
                    SendClientMessage(playerid, COLOUR_RED, "You are banned from this server.");
                    Kick(playerid);
                    return 1;
                }

                PlayerLevel[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "Level", "Accounts");
                SetPlayerScore(playerid, PlayerLevel[playerid]);
               
                PlayerMoney[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "Money", "Accounts");
                ResetPlayerMoney(playerid);
                GivePlayerMoney(playerid, PlayerMoney[playerid]);
               
                AdminLevel[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "AdminLevel", "Accounts");
               
                PlayerArmour[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "Armour", "Accounts");
                SetPlayerArmour(playerid, PlayerArmour[playerid]);
               
                Faction[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "Faction", "Accounts");
                FRank[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "FRank", "Accounts");
                PlayerSkin[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "Skin", "Accounts");
               
                SetSpawnInfo(playerid, -1, PlayerSkin[playerid], -227.3866, 1039.8873, 19.7422, 180.0, 0,0,0,0,0,0);
                SpawnPlayer(playerid);
                new string[256];
                format(string, sizeof(string), "Welcome to Bone County Roleplay %s : Level: %d Money: $ %d Admin Level: %d Faction: %s Faction Rank: %d", GetNameEx(playerid), PlayerLevel[playerid], PlayerMoney[playerid], AdminLevel[playerid], FactionName[Faction[playerid]], FRank[playerid]);
                SendClientMessage(playerid, 0xFFD99FFF, string);
               
            }
I done it in OnPlayerSpawn as it still didn't work, as well as giving weapons. its like it "Overwrites" you see it for a split second and then it goes.
Reply
#7

Also: Basically it just doesnt set it. I don't know if it overwrites, I think so, but even the printf wont display.
Reply
#8

Still not solved, Help please? Really much appreciated.
Reply
#9

Try this.

Код:
new query[128];
format(query ,sizeof(query), "SELECT skin FROM Accounts WHERE id = %i LIMIT 1", PlayerSQLID[playerid]);
mysql_query(query);
mysql_store_result();
new sid = mysql_fetch_int();
mysql_free_result();
SetPlayerSkin(playerid, sid);
By the way, you shouldn't retrieve and store the password on the client like that to authenticate users. During registration, store the password as an MD5 hash and then perform a query similar to this:

Код:
SELECT * FROM Accounts WHERE password = md5(inputtext);
It's more secure.
Reply
#10

Did you saved it correct?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)