SA-MP Forums Archive
Level not save - 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: Level not save (/showthread.php?tid=667482)



Level not save - Calinut200 - 24.06.2019

Helo, i make a bonus command and is work very good. One problem, when i enter again in game i have level 1 and again i can use /bonus.
HOW TO FIX TO SAVE LEVEL WHEN EXIT
PHP Code:
CMD:bonus(playerid)
{
    if(
PlayerInfo[playerid][pLevel] == || GetPlayerScore(playerid) == 1)
    {
        
SendClientMessage(playerid,-1,"Deoarece ai folosit comanda /bonus ai primit:");
        
SendClientMessage(playerid,-1,"-LEVEL: 3");
        
SendClientMessage(playerid,-1,"-MONEY: $5.000.000");
        
GivePlayerMoney(playerid,5000000);
        
PlayerInfo[playerid][pLevel] = SetPlayerScore(playerid,3);
    }
    else
    {
        
SendClientMessage(playerid,-1,"Trebuie sa ai minim level 1 pentru a folosi aceasta comanda.");
    }
     return 
1;




Re: Level not save - Symon - 24.06.2019

pawn Code:
CMD:bonus(playerid)
{
    if(PlayerInfo[playerid][pLevel] == 1 || GetPlayerScore(playerid) == 1)
    {
        SendClientMessage(playerid,-1,"Deoarece ai folosit comanda /bonus ai primit:");
        SendClientMessage(playerid,-1,"-LEVEL: 3");
        SendClientMessage(playerid,-1,"-MONEY: $5.000.000");
        GivePlayerMoney(playerid,5000000);
        SetPlayerScore(playerid, 3);
        PlayerInfo[playerid][pLevel] = GetPlayerScore(playerid));
    }
    else
    {
        SendClientMessage(playerid,-1,"Trebuie sa ai minim level 1 pentru a folosi aceasta comanda.");
    }
     return 1;
}



Re: Level not save - SiaReyes - 24.06.2019

Fix of above code!
Code:
       SetPlayerScore(playerid, GetPlayerScore(playerid)+3);
        PlayerInfo[playerid][pLevel] = GetPlayerScore(playerid));



Re: Level not save - SnakePit - 24.06.2019

After the player login is successful, place this:

PHP Code:
     
       
new name[MAX_PLAYER_NAME], yourfile[256];
       
GetPlayerName(playeridnameMAX_PLAYER_NAME);
       
format(yourfile256"insert here the file you want to save the level"name);
       
PlayerInfo[playerid][pLevel] = DOF2_GetInt(yourfile,"Level");
       
SetPlayerScore(playeridPlayerInfo[playerid][pLevel]); 
Inside the public OnPlayerDisconnect:

PHP Code:
        new name[MAX_PLAYER_NAME], yourfile[256];
        
GetPlayerName(playeridnameMAX_PLAYER_NAME);
        
format(yourfile256"insert here the file you want to save the level"name);
    
        if(!
DOF2_FileExists(yourfile))
    {
           
DOF2_CreateFile(yourfile);
    }
       
        
PlayerInfo[playerid][pLevel] = GetPlayerScore(playerid);
        
DOF2_SetInt(yourfile"Level"PlayerInfo[playerid][pLevel]);
        
DOF2_SaveFile(); 
Then, your command should look like this:

PHP Code:
CMD:bonus(playerid

    
    
PlayerInfo[playerid][pLevel] = GetPlayerScore(playerid); 
    if(
PlayerInfo[playerid][pLevel] == 1
    { 
        
SendClientMessage(playerid,-1,"Deoarece ai folosit comanda /bonus ai primit:"); 
        
SendClientMessage(playerid,-1,"-LEVEL: 3"); 
        
SendClientMessage(playerid,-1,"-MONEY: $5.000.000"); 
        
GivePlayerMoney(playerid,5000000); 
        
SetPlayerScore(playerid3); 
        
PlayerInfo[playerid][pLevel] = 3;
    } 
    else 
    { 
        
SendClientMessage(playerid,-1,"Trebuie sa ai minim level 1 pentru a folosi aceasta comanda."); 
    } 
     return 
1

I have not tested it, but hope it works for you, if you get errors, just show me the line.


Re: Level not save - Symon - 24.06.2019

@SnakePit what the hell? Why are you setting player's level based on fetched score, then setting it again to 3? Also whats all that file saving part? You don't even know which saving system is using the OP...


Re: Level not save - SnakePit - 24.06.2019

Quote:
Originally Posted by KeyOfKey
View Post
@SnakePit what the hell? Why are you setting player's level based on fetched score, then setting it again to 3? Also whats all that file saving part? You don't even know which saving system is using the OP...
He was supposed to replace it.