SAVING & LOADING
#1

pawn Code:
stock LoadAccount(playerid)
{
    new Userfolder[64];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(Userfolder,sizeof(Userfolder),"/Users/%s.txt",name);
    SetPlayerScore(playerid,dini_Int(Userfolder,"Level"));// Score wird wieder gegeben, mit dini_int wird gelsen
    GivePlayerMoney(playerid,dini_Int(Userfolder,"Cash")); //Geld wird gegeben was man hatte, das gespeicherte
    PlayerInfo[playerid][Adminlevel]=dini_Int(Userfolder,"Adminlevel");
    PlayerInfo[playerid][Faction]=dini_Int(Userfolder,"Faction");
    PlayerInfo[playerid][pSex]=dini_Int(Userfolder,"pSex");
    PlayerInfo[playerid][pAge]=dini_Int(Userfolder,"pAge");
    PlayerInfo[playerid][pPnumber]=dini_Int(Userfolder,"pPnumber");
    return;
}

stock UserSave(playerid)
{
    new Userfolder[64];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(Userfolder,sizeof(Userfolder),"/Users/%s.txt",name);//Es wird in der SpielerDatei gespeichert
    dini_IntSet(Userfolder,"Level",GetPlayerScore(playerid)); //Level Speichern, mit Int eine Zahl speichern. Userfolder wo, welche Reihe fьr Level und was soll er speichern, getplayerscore
    dini_IntSet(Userfolder,"Cash",GetPlayerMoney(playerid)); //Geld Speichern
    dini_IntSet(Userfolder,"Adminlevel",PlayerInfo[playerid][Adminlevel]);
    dini_IntSet(Userfolder,"Faction",PlayerInfo[playerid][Faction]);
    dini_IntSet(Userfolder,"pSex",PlayerInfo[playerid][pSex]);
    dini_IntSet(Userfolder,"pAge",PlayerInfo[playerid][pAge]);
    dini_IntSet(Userfolder,"pPnumber",PlayerInfo[playerid][pPnumber]);
    dini_IntSet(Userfolder,"Faction",PlayerInfo[playerid][Faction]);
    return 1;
}


Thats my code. My problem is, after every Server Restart the PlayerInfo thingy\'s are resetted. Only the Cash and Level is saved, but it always ask\'s me by the tutorial which Gender I\'m, I need to buy again a mobile Phone etc..

How can I do this that those things are also automatically loaded and stay forever? (the PlayerInfo functions..)
Reply
#2

EDIT//:: I am sorry, the problem is that the system is always asking even he asked already and its safed
How to put it off if they asked already?
Reply
#3

pawn Code:
if(RegistrationStep[playerid] == 1)
    {
        if(!strlen(text)) //Checks to make sure there is atleast 1 character input
        {
            SendClientMessage(playerid,LIGHTBLUE,"What\'s your Age?");
            SendClientMessage(playerid,WHITE,"Hint: Enter your 2 digit age");
            return 0; //Ends the commands and doesnt display in text
        }
        if(strlen(text)< 2||strlen(text) > 2)//Checks that the input is only 2 characters long
        {
            SendClientMessage(playerid,0xD70000FF,"Only a 2 digit number will work!");
            return 0;
        }
        new string[128]; //Creates a new string 128 characters long
        format(string,sizeof(string),"Ok so you are %d years old",strval(text)); //Formats the string
        SendClientMessage(playerid,LIGHTBLUE,string); //Sends new message with the string
        PlayerInfo[playerid][pAge] = strval(text);
        SendClientMessage(playerid,LIGHTBLUE,"What is your Sex?");
        SendClientMessage(playerid,WHITE,"Hint: Enter male or female");
        RegistrationStep[playerid] = 2;
        return 0;

    }
    if(RegistrationStep[playerid] == 2)
    {
        new tmp[4];
        if(!strlen(text)) //Check to make sure there is at least 1 character input
        {
            SendClientMessage(playerid,LIGHTBLUE,"What is your Sex?");
            SendClientMessage(playerid,WHITE,"Hint: Enter male or female");
            return 0;
        }
        if(!strcmp("male", tmp, true, 4))
        {//Checks to see if the input matches "male" and if it does continues
            PlayerInfo[playerid][pSex] = strval(text);
            PlayerInfo[playerid][pSex] = 1; // CHANGED TO 1
            SendClientMessage(playerid,LIGHTBLUE,"Ok, so you are a male.");
            SendClientMessage(playerid,WHITE,"Thank you for filling in the information");
            RegistrationStep[playerid] = 3;
            TogglePlayerControllable(playerid,1);//Unfreezes the player and play resumes
            return 0;
        }
        else if(!strcmp("female", tmp, true, 6))
        {//Checks to see if the input matches "female" and if it does continues
            PlayerInfo[playerid][pSex] = strval(text);
            PlayerInfo[playerid][pSex] = 2;
            SendClientMessage(playerid,LIGHTBLUE,"Ok, so you are a Female.");
            SendClientMessage(playerid,WHITE,"Thank you for filling in the information");
            RegistrationStep[playerid] = 3;
            TogglePlayerControllable(playerid,1);//Unfreezes the player and play resumes
            return 0;
        }
        else
        { SendClientMessage(playerid,WHITE,"Please answer your Gender!"); return 0; }
    }

public OnPlayerSpawn(playerid)
{
    new newtext[41], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    format(newtext, sizeof(newtext), "~w~Welcome ~b~%s", name);
    GameTextForPlayer(playerid, newtext, 1000, 1);
    if(GetPlayerTeam(playerid) == 1) SetPlayerPos( playerid, 255.1449,66.4737,1003.6406); //If player is lspd, he spawns at lspd
    if(GetPlayerTeam(playerid) == 2) SetPlayerPos( playerid, 1654.8550,-1659.3982,22.5156); //If player is civilian, he spawns at civispawn
   
   
    if(RegistrationStep[playerid] == 0)
    {
        SendClientMessage(playerid,LIGHTBLUE,"What\'s your Age?");
        SendClientMessage(playerid,WHITE,"Hint: Enter your 2 digit age");
        TogglePlayerControllable(playerid,0); //Freezing the player
        RegistrationStep[playerid] = 1; //Sets our registrationstep to 1
        return 1;
    }
    return 1;
Reply
#4

I\'m gonna say 1 thing, we got a EDIT button here lol.
And you can save them by using dini, check this:
[ame]http://www.youtube.com/watch?v=OvFTMBr-QRA[/ame]
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)