Money Reset! Please Help
#1

when i'm connect to server with Any money then spawned. my money reset to 0. why?

Код:
enum pInfo
{
    // other stuff
    pCash
}
new PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    // other stuff
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    return 1;
}

public OnPlayerConnect(playerid)
{
    PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pAdmin] = 0;
    if(fexist(UserPath(playerid)))
    {
		PlayerInfo[playerid][pLogged] = 0;
        INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
    }
    else
    {
        PlayerInfo[playerid][pLogged] = 0;
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    // other stuff
    INI_Close(File);
    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_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);
                // other stuff
                INI_Close(File);
                GivePlayerMoney(playerid, 5000);
                PlayerInfo[playerid][pLogged] = 1;
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! Your Y_INI system works perfectly. Relog to save your stats!","Ok","");
				PlayerInfo[playerid][pFirstSpawn] = 1;
			}
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]); 
                    SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                    PlayerInfo[playerid][pLogged] = 1;
                    PlayerInfo[playerid][pFirstSpawn] = 1;
				}
                else
                {
                    PlayerInfo[playerid][pFirstSpawn] = 0;
                    PlayerInfo[playerid][pLogged] = 0;
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}
i already follow all tutorial Register & Login from kush in https://sampforum.blast.hk/showthread.php?tid=273088
please help me to complete my gamemode project
Reply
#2

Do you have a folder at scriptfiles where you save the player status or
Reply
#3

Quote:
Originally Posted by TheLegend1
Посмотреть сообщение
Do you have a folder at scriptfiles where you save the player status or
yes i have it, other stats is normaly save, just the cash won't save
Reply
#4

Defined this ?
#define PATH "/Users/%s.ini"
Reply
#5

Quote:
Originally Posted by TheLegend1
Посмотреть сообщение
Defined this ?
#define PATH "/Users/%s.ini"
ofcourse
Reply
#6

but the folder name is it Users or and remove first "/" at Define
Reply
#7

PHP код:
public OnPlayerConnect(playerid)
{
    if(
fexist(UserPath(playerid)))
    {
        
PlayerInfo[playerid][pLogged] = 0;
        
INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra true, .extra playerid);
        
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
    }
    else
    {
        
PlayerInfo[playerid][pLogged] = 0;
        
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
    }
    return 
1;

PHP код:
forward LoadUser_data(playerid,name[],value[]);
public 
LoadUser_data(playerid,name[],value[])
{
    
// other stuff
    
INI_Int("Cash",GetPlayerMoney(playerid));
    return 
1;

Reply
#8

Quote:
Originally Posted by ._Xavier$$
Посмотреть сообщение
PHP код:
public OnPlayerConnect(playerid)
{
    if(
fexist(UserPath(playerid)))
    {
        
PlayerInfo[playerid][pLogged] = 0;
        
INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra true, .extra playerid);
        
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
    }
    else
    {
        
PlayerInfo[playerid][pLogged] = 0;
        
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
    }
    return 
1;

PHP код:
forward LoadUser_data(playerid,name[],value[]);
public 
LoadUser_data(playerid,name[],value[])
{
    
// other stuff
    
INI_Int("Cash",GetPlayerMoney(playerid)); <<--- here
    
return 1;

got warning
Код:
D:\gamemodes\Untitled.pwn(483) : error 022: must be lvalue (non-constant)
Reply
#9

PHP код:
forward LoadUser_data(playerid,name[],value[]); 
public 
LoadUser_data(playerid,name[],value[]) 

    
// other stuff 
    
INI_Int("Cash",PlayerInfo[playerid][pCash]); 
    return 
1

PHP код:
public OnPlayerDisconnect(playeridreason)
{
    new 
INI:File INI_Open(UserPath(playerid));
    
INI_SetTag(File,"data");
    
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    
// other stuff
    
INI_Close(File);
    return 
1;

PHP код:
public OnPlayerConnect(playerid

    if(
fexist(UserPath(playerid))) 
    { 
        
PlayerInfo[playerid][pLogged] = 0
        
INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra true, .extra playerid); 
        
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit"); 
    } 
    else 
    { 
        
PlayerInfo[playerid][pLogged] = 0
        
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit"); 
    } 
    return 
1

Reply
#10

Quote:
Originally Posted by ._Xavier$$
Посмотреть сообщение
PHP код:
forward LoadUser_data(playerid,name[],value[]); 
public 
LoadUser_data(playerid,name[],value[]) 

    
// other stuff 
    
INI_Int("Cash",PlayerInfo[playerid][pCash]); 
    return 
1

PHP код:
public OnPlayerDisconnect(playeridreason)
{
    new 
INI:File INI_Open(UserPath(playerid));
    
INI_SetTag(File,"data");
    
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    
// other stuff
    
INI_Close(File);
    return 
1;

PHP код:
public OnPlayerConnect(playerid

    if(
fexist(UserPath(playerid))) 
    { 
        
PlayerInfo[playerid][pLogged] = 0
        
INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra true, .extra playerid); 
        
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit"); 
    } 
    else 
    { 
        
PlayerInfo[playerid][pLogged] = 0
        
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit"); 
    } 
    return 
1

Doesnt work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)