YINI money problem
#1

Hey guys!
I've created the register/login system by my own, but im having problems with the Money value(Dinero in spanish).
While the registering im trying to set it to 5000, but in the saved file its always set to 0.

Any idea?

Code here:

pawn Код:
#include <a_samp>
#include <YSI\y_ini>

//Colores
#define COL_WHITE "{FFFFFF}"
#define COL_RED "{F81414}"
#define COL_GREEN "{00FF22}"
#define COL_LIGHTBLUE "{00CED1}"

//Dialogs
#define DIALOG_REGISTER  1
#define DIALOG_LOGIN     2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4

//Users Path
#define PATH "/Usuarios/%s.ini"

//Enums
enum pInfo
{
    pPass,
    pDinero,
    pAdmin,
    pTelefono,
    pCoche1,
    pCoche2,
    pCoche3,
    pCasa1,
    pCasa2,
    pFaccion,
    pJob,
    pSkin,
    pInterior,
    Float:pPosX,
    Float:pPosY,
    Float:pPosZ
}
new PlayerInfo[MAX_PLAYERS][pInfo];

//Forwards
forward LoadUser_data(playerid,name[],value[]);

//Stocks
stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}



main(){}


public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Pass",PlayerInfo[playerid][pPass]);
    INI_Int("Dinero",PlayerInfo[playerid][pDinero]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Telefono",PlayerInfo[playerid][pTelefono]);
    INI_Int("Coche1",PlayerInfo[playerid][pCoche1]);
    INI_Int("Coche2",PlayerInfo[playerid][pCoche2]);
    INI_Int("Coche3",PlayerInfo[playerid][pCoche3]);
    INI_Int("Casa1",PlayerInfo[playerid][pCasa1]);
    INI_Int("Coche2",PlayerInfo[playerid][pCasa2]);
    INI_Int("Faccion",PlayerInfo[playerid][pFaccion]);
    INI_Int("Job",PlayerInfo[playerid][pJob]);
    INI_Int("Skin",PlayerInfo[playerid][pSkin]);
    INI_Int("Interior",PlayerInfo[playerid][pInterior]);
    INI_Float("PosX",PlayerInfo[playerid][pPosX]);
    INI_Float("PosY",PlayerInfo[playerid][pPosY]);
    INI_Float("PosZ",PlayerInfo[playerid][pPosZ]);
    return 1;
}

public OnGameModeInit()
{
    SetGameModeText("Blank Script");
    AddPlayerClass(0,1643.4510,-2287.4954,-1.1971,276.4842,0,0,0,0,0,0);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerConnect(playerid)
{
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_WHITE"Bienvenido!\nEscribe tu contraseсa debajo para entrar.","Login","Salir");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,""COL_WHITE"Registrando...",""COL_WHITE"Introduce una contraseсa debajo para registrar una nueva cuenta.","Registrar","Salir");
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new Float:Pos[3];
    new INI:File = INI_Open(UserPath(playerid));
   
    GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
   
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Dinero",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Telefono",PlayerInfo[playerid][pTelefono]);
    INI_WriteInt(File,"Coche1",PlayerInfo[playerid][pCoche1]);
    INI_WriteInt(File,"Coche2",PlayerInfo[playerid][pCoche2]);
    INI_WriteInt(File,"Coche3",PlayerInfo[playerid][pCoche3]);
    INI_WriteInt(File,"Casa1",PlayerInfo[playerid][pCasa1]);
    INI_WriteInt(File,"Casa2",PlayerInfo[playerid][pCasa2]);
    INI_WriteInt(File,"Faccion",PlayerInfo[playerid][pFaccion]);
    INI_WriteInt(File,"Job",PlayerInfo[playerid][pJob]);
    INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
    INI_WriteInt(File,"Interior",PlayerInfo[playerid][pInterior]);
    INI_WriteFloat(File,"PosX",Pos[0]);
    INI_WriteFloat(File,"PosY",Pos[1]);
    INI_WriteFloat(File,"PosZ",Pos[2]);
    INI_Close(File);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(PlayerInfo[playerid][pPosX] == 0 && PlayerInfo[playerid][pPosY] == 0)
    {
        SetPlayerPos(playerid, 1643.4510, -2287.4954, -1.1971);
    }else
    {
        SetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COL_WHITE"Registrando...",""COL_RED"Has introducido una contrasela invalida.\n"COL_WHITE"Introduce una contraseсa debajo para registrar una nueva cuenta.","Registrar","Salir");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteString(File,"Password",inputtext);
                INI_WriteInt(File,"Dinero", 5000);
                INI_WriteInt(File,"Admin", 1);
                INI_WriteInt(File,"Telefono", 0);
                INI_WriteInt(File,"Coche1", 0);
                INI_WriteInt(File,"Coche2", 0);
                INI_WriteInt(File,"Coche3", 0);
                INI_WriteInt(File,"Casa1", 0);
                INI_WriteInt(File,"Casa2", 0);
                INI_WriteInt(File,"Faccion", 0);
                INI_WriteInt(File,"Job", 0);
                INI_WriteInt(File,"Skin", 0);
                INI_WriteInt(File,"Interior", 0);
                INI_WriteFloat(File,"PosX", 0.0);
                INI_WriteFloat(File,"PosY", 0.0);
                INI_WriteFloat(File,"PosZ", 0.0);
                INI_Close(File);

                SetSpawnInfo(playerid, PlayerInfo[playerid][pSkin], 0, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosZ], PlayerInfo[playerid][pPosZ], 269.15, 0, 0, 0, 0, 0, 0);
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Bien!!",""COL_GREEN"Registrado correctamente! Reloguea para guardar tus datos!","Ok","");
            }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(strcmp(inputtext, PlayerInfo[playerid][pPass]) == 0)
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    SetSpawnInfo(playerid, PlayerInfo[playerid][pSkin], 0, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosZ], PlayerInfo[playerid][pPosZ], 269.15, 0, 0, 0, 0, 0, 0);
                    SpawnPlayer(playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pDinero]);
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"Contraseсa incorrecta.\n"COL_WHITE"Introduce tu contraseсa para entrar.","Login","Salir");
                }
                return 1;
            }
        }
       
        case DIALOG_SUCCESS_1:
        {
            if(!response) return 0;
            if(response) return SpawnPlayer(playerid);
        }
    }
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}
Reply
#2

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COL_WHITE"Registrando...",""COL_RED"Has introducido una contrasela invalida.\n"COL_WHITE"Introduce una contraseсa debajo para registrar una nueva cuenta.","Registrar","Salir");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteString(File,"Password",inputtext);
                INI_WriteInt(File,"Dinero", 5000);
                INI_WriteInt(File,"Admin", 1);
                INI_WriteInt(File,"Telefono", 0);
                INI_WriteInt(File,"Coche1", 0);
                INI_WriteInt(File,"Coche2", 0);
                INI_WriteInt(File,"Coche3", 0);
                INI_WriteInt(File,"Casa1", 0);
                INI_WriteInt(File,"Casa2", 0);
                INI_WriteInt(File,"Faccion", 0);
                INI_WriteInt(File,"Job", 0);
                INI_WriteInt(File,"Skin", 0);
                INI_WriteInt(File,"Interior", 0);
                INI_WriteFloat(File,"PosX", 0.0);
                INI_WriteFloat(File,"PosY", 0.0);
                INI_WriteFloat(File,"PosZ", 0.0);
                INI_Close(File);
                PlayerInfo[playerid][pDinero] = 5000;
                GivePlayerMoney(playerid,5000);
                SetSpawnInfo(playerid, PlayerInfo[playerid][pSkin], 0, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosZ], PlayerInfo[playerid][pPosZ], 269.15, 0, 0, 0, 0, 0, 0);
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Bien!!",""COL_GREEN"Registrado correctamente! Reloguea para guardar tus datos!","Ok","");
            }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(strcmp(inputtext, PlayerInfo[playerid][pPass]) == 0)
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    SetSpawnInfo(playerid, PlayerInfo[playerid][pSkin], 0, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosZ], PlayerInfo[playerid][pPosZ], 269.15, 0, 0, 0, 0, 0, 0);
                    SpawnPlayer(playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pDinero]);
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"Contraseсa incorrecta.\n"COL_WHITE"Introduce tu contraseсa para entrar.","Login","Salir");
                }
                return 1;
            }
        }

        case DIALOG_SUCCESS_1:
        {
            if(!response) return 0;
            if(response) return SpawnPlayer(playerid);
        }
    }
    return 1;
}
Reply
#3

I solvented the problem by setting de Money variable to 0 in the registering step and giving the player 5000 on the first spawn.
Reply
#4

Yes, that works too and my code above also works, I've tested it in my own registeration system.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)