Saving
#1

How can I save the skin they chose after registering?

and when they connect again, the skin they chose will load.
The enum:
pawn Код:
enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pWarnings,
    pDeaths,
    pScores,
    pDonator,
}
Forward:
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Scores",PlayerInfo[playerid][pScores]);
    INI_Int("Donator",PlayerInfo[playerid][pDonator]);
    return 1;
}
OnPlayerDisconnect
pawn Код:
new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Scores",PlayerInfo[playerid][pScores]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Donator",PlayerInfo[playerid][pDonator]);
    INI_Close(File);
OnDialogResponse:
pawn Код:
new INI:File = INI_Open(UserPath(playerid));
         INI_SetTag(File,"data");
         INI_WriteInt(File,"Password",udb_hash(inputtext));
         INI_WriteInt(File,"Cash",0);
         INI_WriteInt(File,"Admin",0);
         INI_WriteInt(File,"Kills",0);
         INI_WriteInt(File,"Deaths",0);
         INI_WriteInt(File,"Scores",0);
         INI_WriteInt(File,"Donator",0);

         INI_Close(File);

I'm learning about this codes.
Thanks.
Reply
#2

pawn Код:
enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pWarnings,
    pDeaths,
    pScores,
    pDonator,
    pSkin
}

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Scores",PlayerInfo[playerid][pScores]);
    INI_Int("Donator",PlayerInfo[playerid][pDonator]);
    INI_Int("Skin", PlayerInfo[playerid][pSkin]);
    return 1;
}

//OnPlayerDisconnect

new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Scores",PlayerInfo[playerid][pScores]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Donator",PlayerInfo[playerid][pDonator]);
INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
INI_Close(File);

//Whenever you want to load the skin (make sure the player is spawned)

SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
Seriously, use ****** before making a thread, this will raise your common sense from 0 to 1.
Reply
#3

Quote:
Originally Posted by Kindred
Посмотреть сообщение
Seriously, use ****** before making a thread, this will raise your common sense from 0 to 1.
Thank you but I tried making that Score in enum but it doesn't show my score on tab. I have the Users folder in scriptfiles.
Reply
#4

pawn Код:
enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pWarnings,
    pDeaths,
    pScores,
    pDonator,
    pSkin
}

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Scores",PlayerInfo[playerid][pScores]);
    INI_Int("Donator",PlayerInfo[playerid][pDonator]);
    INI_Int("Skin",PlayerInfo[playerid][pSkin]);
    return 1;
}

new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Scores",PlayerInfo[playerid][pScores]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Donator",PlayerInfo[playerid][pDonator]);
    INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
    PlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid);
    INI_Close(File);

new INI:File = INI_Open(UserPath(playerid));
         INI_SetTag(File,"data");
         INI_WriteInt(File,"Password",udb_hash(inputtext));
         INI_WriteInt(File,"Cash",0);
         INI_WriteInt(File,"Admin",0);
         INI_WriteInt(File,"Kills",0);
         INI_WriteInt(File,"Deaths",0);
         INI_WriteInt(File,"Scores",0);
         INI_WriteInt(File,"Donator",0);
         INI_WriteInt(File,"Skin",[here add the skinid that you want the registered user to have]);

         INI_Close(File);
Also add in

pawn Код:
public OnPlayerSpawn(playerid);
pawn Код:
public OnPlayerSpawn(playerid);
{
     SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
     return 1;
}
EDIT: too late -.-
Reply
#5

Do what he did ^

Only problem is, this code that he provided won't work:

pawn Код:
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Scores",PlayerInfo[playerid][pScores]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Donator",PlayerInfo[playerid][pDonator]);
INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
PlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid);
INI_Close(File);
Change it to this:

pawn Код:
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Scores",PlayerInfo[playerid][pScores]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Donator",PlayerInfo[playerid][pDonator]);
PlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid);
INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
INI_Close(File);
Made it so it Gets the player skin BEFORE saving it, the way you did it before saves a nulled variable considering no value was ever placed on it before you saved it.
Reply
#6

Thank You for your reply, I'll test it. I'll learn next time instead of posting here.
Reply
#7

Yeah my mistake thanks for correcting me.
Reply
#8

Did you use the code he ^ provided for OnPlayerSpawn, where it sets the players skin.

If not, get it.
Reply
#9

Quote:
Originally Posted by Kindred
Посмотреть сообщение
Did you use the code he ^ provided for OnPlayerSpawn, where it sets the players skin.

If not, get it.
I tested the script he provided but after pressing the "Spawn" button, I spawn with the skin of CJ.
Reply
#10

Did you actually set your skin? Everything here looks completely fine, so I'm not sure why it wouldn't work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)