Saving age Variable || A little help please.
#1

Im trying to make a registration system, but im stuck in age things

When player enter the age this happend

pawn Код:
public OnAgeGiven(playerid, Age[])
{
    new string2[128];
    format(string2, sizeof(string2), "users/%s.ini", GetPlayerNameEx(playerid));
    new File:example = fopen(string2, io_append);
    if(example)
    {
        strmid(PlayerInfo[playerid][pAge], Age, 0, strlen(Age), 255);
        new ap[32];
        format(ap, 32, "Age=%s\n", PlayerInfo[playerid][pAge]);fwrite(example, ap);
        fclose(example);
        SendClientMessage(playerid, COLOR_RED, "Step 2 Completed!");
        SetPlayerCameraPos(playerid, -2274.2588,110.6220,66.7716);
        SetPlayerCameraLookAt(playerid, -2309.3486,105.3977,35.5809);
        ShowPlayerDialog(playerid,4,DIALOG_STYLE_LIST,"Religon","Jewish\nMuslim\nChristian\nCatholic\nIslam\nHindu\nBuddist\nAtheist","Continue","Cancel");
    }
    return 1;
}
What it makes is instead of opening the current User file , it creates another one with Only age,

For example i register with Steven_Ward, when i enter my age, and go check the user folder, i see 2 same files, one has all the Stats but the Age=0 (which means that function or what ever it is has no thing with this file) and i file with only Age=The age i entered , i want to make it edit the current file instead of creating a new one
Reply
#2

Use https://sampwiki.blast.hk/wiki/Fexist perhaps that solves the problem.

pawn Код:
if(!fexist(string2)) return printf("An error occurred, no such user exist: %s" string2);
Another solution https://sampforum.blast.hk/showthread.php?tid=175565

Now question; why do you need strmid? Age is supposed to be an integer.
Reply
#3

Im just editing , transfering registration system from a GM to another, What's the difference between them ?
Reply
#4

Bump
Reply
#5

Anyone ?
Reply
#6

This will probably give you some errors, but I hope you can fix them yourself.

pawn Код:
public OnAgeGiven(playerid, Age) //Age as integer, not string
{
    new string2[64];
    format(string2, sizeof(string2), "users/%s.ini", GetPlayerNameEx(playerid));

    if(!fexist(string2))

    return SendCliendMessage(playerid, -1, "The impossible has happened, your account does not exist! Notify Administrator.");

    else
    {
        new File:example = fopen(string2, io_append);
        if(example)
        {
            new ap[32];
            format(ap, 32, "Age=%s\n", Age);
            fwrite(example, ap);
            fclose(example);
            SendClientMessage(playerid, COLOR_RED, "Step 2 Completed!");
            SetPlayerCameraPos(playerid, -2274.2588,110.6220,66.7716);
            SetPlayerCameraLookAt(playerid, -2309.3486,105.3977,35.5809);
            PlayerInfo[playerid][pAge] = Age;
            ShowPlayerDialog(playerid,4,DIALOG_STYLE_LIST,"Religon","Jewish\nMuslim\nChristian\nCatholic\nIslam\nHindu\nBuddist\nAtheist","Continue","Cancel");
        }
    }
    return 1;
}
However, it would be better to store all user data in variables until they disconnect, and then do all the saves.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)