SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 24/06/2019, 07:03 PM   #1
Calinut200
Big Clucker
 
Join Date: Jun 2016
Posts: 74
Reputation: 0
Default Level not save

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;

Calinut200 is offline   Reply With Quote
Old 24/06/2019, 07:51 PM   #2
Symon
Gangsta
 
Symon's Avatar
 
Join Date: Apr 2019
Location: Italy
Posts: 914
Reputation: 89
Default Re: Level not save

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;
}
Symon is offline   Reply With Quote
Old 24/06/2019, 07:53 PM   #3
SiaReyes
Gangsta
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 618
Reputation: 57
Default Re: Level not save

Fix of above code!
Code:
       SetPlayerScore(playerid, GetPlayerScore(playerid)+3);
        PlayerInfo[playerid][pLevel] = GetPlayerScore(playerid));
SiaReyes is offline   Reply With Quote
Old 24/06/2019, 08:06 PM   #4
SnakePit
Little Clucker
 
SnakePit's Avatar
 
Join Date: Jun 2019
Location: Rio de Janeiro
Posts: 38
Reputation: 0
Default Re: Level not save

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.
__________________
BOTAFOGO DE FUTEBOL E REGATAS

SnakePit is offline   Reply With Quote
Old 24/06/2019, 08:10 PM   #5
Symon
Gangsta
 
Symon's Avatar
 
Join Date: Apr 2019
Location: Italy
Posts: 914
Reputation: 89
Default Re: Level not save

@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...
Symon is offline   Reply With Quote
Old 24/06/2019, 08:16 PM   #6
SnakePit
Little Clucker
 
SnakePit's Avatar
 
Join Date: Jun 2019
Location: Rio de Janeiro
Posts: 38
Reputation: 0
Default Re: Level not save

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.
__________________
BOTAFOGO DE FUTEBOL E REGATAS

SnakePit is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Save administration level CSLangdale Scripting Help 9 10/03/2016 06:46 PM
Save admin level Vasu99 Scripting Help 4 28/02/2014 11:14 PM
Need help wanted level save Lynet Scripting Help 4 01/01/2013 12:53 AM
[HELP] How to save Admin level/other misc Scratch Scripting Help 0 21/12/2011 08:05 PM
Level save GaGlets(R) Help Archive 2 13/11/2009 03:15 PM


All times are GMT. The time now is 08:10 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.