[Tutorial] Saving position and skin. [using Y_INI] [For newbies]
#10

Took me some time but found it:

pawn Code:
case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
                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,"Bank",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"Skin",159);
                INI_WriteInt(File,"NewReg",0);
                INI_WriteInt(File,"Xpos",0);
                INI_WriteInt(File,"Ypos",0);
                INI_WriteInt(File,"Zpos",0);
                INI_Close(File);

                SetPlayerSkin(playerid, 159); // Sets the player skin
                SpawnPlayer(playerid);
                PlayerInfo[playerid][NewReg] = 1;
            }
        }
Then change this:

pawn Code:
public OnPlayerSpawn(playerid)
{
    if(PlayerInfo[playerid][NewReg] == 0)
    {
        SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]); print("Stage 40");
        SetPlayerPos(playerid, PlayerInfo[playerid][Xpos], PlayerInfo[playerid][Ypos], PlayerInfo[playerid][Zpos]+0.3);    print("Stage 41");
    }
    else
    {
        SetPlayerPos(playerid, X, Y, Z); // CHANGE THIS FOR FIRST PLAYER SPAWN WHEN HE ENTERS THE GAME
    }
    print("Stage 42");
    return 1;
}
Delete your previous account and create a new one.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)