SA-MP Forums Archive
PayDay/Level Up help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: PayDay/Level Up help (/showthread.php?tid=641799)



PayDay/Level Up help - Escobabe - 20.09.2017

So basically, im trying to make a simple payday every 1 hour. The payday works fine, but i want to add level up too, but it's not working, here is my code:

Код:
forward payday();
public payday()
{
    for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i))
    {
        GameTextForPlayer(i, "PAYDAY", 1000, 1);
        GivePlayerMoney(i, 1000); // You can change the ammount of money.
        SetPlayerScore(i, +1);
    }
    return 1;
}
What should i do with SetPlayerScore? I want to make it every 1 hour +1 score.

PS: This is the Timer code

Код:
SetTimer("payday", 360000, 1);



Re: PayDay/Level Up help - aoky - 20.09.2017

PHP код:
SetPlayerScore(playeridGetPlayerScore(playerid) + 1); 



Re: PayDay/Level Up help - Escobabe - 20.09.2017

Quote:
Originally Posted by aoky
Посмотреть сообщение
PHP код:
SetPlayerScore(playeridGetPlayerScore(playerid) + 1); 
I changed all "i" to "playerid". It works now, thank you (+rep)

But now my score wont save?

enums:
Код:
enum pInfo
{
    pPass,
    pCash,
    pKills,
    pDeaths,
    pScore,
    pAdmin,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
LoadUserData:
Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Score",PlayerInfo[playerid][pScore]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    return 1;
}
OnPlayerDisconnect:
Код:
public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Score",PlayerInfo[playerid][pScore]);
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_Close(File);
    return 1;
}
OnDialogResponse:
Код:
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);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"Score",0);
                INI_WriteInt(File,"Admin",0);
                INI_Close(File);

                SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Thanks! You are registered at, "COL_LIGHTBLUE"District Gaming","Ok","");
			}
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
					ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                }
                else
                {
                    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;
}
Anny suggestions? Why isn't the score saving?


Re: PayDay/Level Up help - aoky - 20.09.2017

Haven't really tested this, but try doing this:

PHP код:
SetPlayerScore(playeridGetPlayerScore(PlayerInfo[playerid][pScore]) + 1); 



Re: PayDay/Level Up help - Escobabe - 20.09.2017

Quote:
Originally Posted by aoky
Посмотреть сообщение
Haven't really tested this, but try doing this:

PHP код:
SetPlayerScore(playeridGetPlayerScore(PlayerInfo[playerid][pScore]) + 1); 
It compiles without errors nor warnings, but still won't save the score.


Re: PayDay/Level Up help - aoky - 20.09.2017

Keep that and try this:
PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch( 
dialogid )
    {
        case 
DIALOG_REGISTER:
        {
            if (!
response) return Kick(playerid);
            if(
response)
            {
                if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_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,"Kills",0);
                
INI_WriteInt(File,"Deaths",0);
                
INI_WriteInt(File,"Score",0);
                
INI_WriteInt(File,"Admin",0);
                
INI_Close(File);
                
SetSpawnInfo(playerid001958.331343.1215.36269.15000000);
                
SpawnPlayer(playerid);
                
ShowPlayerDialog(playeridDIALOG_SUCCESS_1DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Thanks! You are registered at, "COL_LIGHTBLUE"District Gaming","Ok","");
            }
        }
        case 
DIALOG_LOGIN:
        {
            if ( !
response ) return Kick playerid );
            if( 
response )
            {
                if(
udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
                    
SetPlayerScore(playeridPlayerInfo[playerid][pScore]);
                    
GivePlayerMoney(playeridPlayerInfo[playerid][pCash]);
                    
ShowPlayerDialog(playeridDIALOG_SUCCESS_2DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                }
                else
                {
                    
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_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;




Re: PayDay/Level Up help - Escobabe - 20.09.2017

Quote:
Originally Posted by aoky
Посмотреть сообщение
Keep that and try this:
PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch( 
dialogid )
    {
        case 
DIALOG_REGISTER:
        {
            if (!
response) return Kick(playerid);
            if(
response)
            {
                if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_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,"Kills",0);
                
INI_WriteInt(File,"Deaths",0);
                
INI_WriteInt(File,"Score",0);
                
INI_WriteInt(File,"Admin",0);
                
INI_Close(File);
                
SetSpawnInfo(playerid001958.331343.1215.36269.15000000);
                
SpawnPlayer(playerid);
                
ShowPlayerDialog(playeridDIALOG_SUCCESS_1DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Thanks! You are registered at, "COL_LIGHTBLUE"District Gaming","Ok","");
            }
        }
        case 
DIALOG_LOGIN:
        {
            if ( !
response ) return Kick playerid );
            if( 
response )
            {
                if(
udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
                    
SetPlayerScore(playeridPlayerInfo[playerid][pScore]);
                    
GivePlayerMoney(playeridPlayerInfo[playerid][pCash]);
                    
ShowPlayerDialog(playeridDIALOG_SUCCESS_2DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                }
                else
                {
                    
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_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;

Still won't save the score.


Re: PayDay/Level Up help - Logic_ - 20.09.2017

Instead of having a slow saving system and have issues later on, just use SQL, it features a lot more possiblities and way better.

You can use SQLITE or MySQL, anything that suits you the best. I prefer SQLite for lighter content and MySQL for heavier and larger projects.


Re: PayDay/Level Up help - Escobabe - 20.09.2017

Quote:
Originally Posted by Logic_
Посмотреть сообщение
Instead of having a slow saving system and have issues later on, just use SQL, it features a lot more possiblities and way better.
I don't know how to use other saving systems, other than Dini and Yini.


Re: PayDay/Level Up help - aoky - 20.09.2017

Quote:
Originally Posted by Escobabe
Посмотреть сообщение
I don't know how to use other saving systems, other than Dini and Yini.
MySQL is pretty stressful and it's good if you want to have a UCP etc. but, don't let others stop you from your style of scripting. Keep doing what you doing, and learn from there.