Don' save And Upgrade ExpSystem in ini file
#1

PHP код:
new Old_Exp[MAX_PLAYERS];
new 
New_Exp[MAX_PLAYERS];
new 
My_Level[MAX_PLAYERS];
new 
My_ExpFNL[MAX_PLAYERS];
new 
Exp_string[50];
new 
Level_string[50];
new 
ExpFNL_string[50];
new 
levels,Nam[MAX_PLAYER_NAME],pname[MAX_PLAYER_NAME],stp[128],ID;
enum pInfo
{
    
pOld,
    
pOld_Exp,
    
pNew_Exp,
    
pMy_Level,
    
pMy_Rank,
    
pMy_ExpFNL,
    
pPass,
    
pCash,
    
pAdmin,
    
pKills,
    
pDeaths,
    
pScore,
    
pColor,
    
pSkin,
}
new 
PlayerInfo[MAX_PLAYERS][pInfo];
stock LoginPlayer(playeridpasswd[])
{
    new 
iniFile ini_openFile(UserPath(playerid));
    new 
bool:ret false;
    if ( 
iniFile >= )
    {
        
ini_getInteger(iniFile"Password",PlayerInfo[playerid][pPass]);
        if(
udb_hash(passwd) == PlayerInfo[playerid][pPass])
        {
            
ini_getInteger(iniFile"Cash"PlayerInfo[playerid][pCash]);
            
ini_getInteger(iniFile"Admin"PlayerInfo[playerid][pAdmin]);
            
ini_getInteger(iniFile"Kills"PlayerInfo[playerid][pKills]);
            
ini_getInteger(iniFile"Deaths"PlayerInfo[playerid][pDeaths]);
            
ini_getInteger(iniFile"Score"PlayerInfo[playerid][pScore]);
            
ini_getInteger(iniFile"Color"PlayerInfo[playerid][pColor]);
            
ini_getInteger(iniFile"Skin"PlayerInfo[playerid][pSkin]);
            
ini_getInteger(iniFile"Old"PlayerInfo[playerid][pOld]);
                
ini_getInteger(iniFile"Old_Exp"PlayerInfo[playerid][pOld_Exp]);
            
ini_getInteger(iniFile"New_Exp"PlayerInfo[playerid][pNew_Exp]);
            
ini_getInteger(iniFile"My_Level"PlayerInfo[playerid][pMy_Level]);
            
ini_getInteger(iniFile"pMy_Rank"PlayerInfo[playerid][pMy_Rank]);
            
ini_getInteger(iniFile"My_ExpFNL"PlayerInfo[playerid][pMy_ExpFNL]);
            
            
ret true;
        } else 
ret false;
        
ini_closeFile(iniFile);
    }
    return 
ret;
}
stock UserPath(playerid)
{
    new 
string[128],playername[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,playername,sizeof(playername));
    
format(string,sizeof(string),PATH,playername);
    return 
string;
}
stock udb_hash(buf[]) {
    new 
length=strlen(buf);
    new 
s1 1;
    new 
s2 0;
    new 
n;
    for (
n=0n<lengthn++)
    {
       
s1 = (s1 buf[n]) % 65521;
       
s2 = (s2 s1)     % 65521;
    }
    return (
s2 << 16) + s1;
}
public 
OnPlayerConnect(playerid)
{
    
format(Exp_stringsizeof(Exp_string), "Exp: %d/%d"New_Exp[playerid], Old_Exp[playerid]);
    
Exp[playerid] = TextDrawCreate(484.00000098.559997"Exp 0/120");
    
TextDrawLetterSize(Exp[playerid], 0.3459981.413333);
    
TextDrawAlignment(Exp[playerid], 1);
    
TextDrawColor(Exp[playerid], -2139094785);
    
TextDrawSetShadow(Exp[playerid], 0);
    
TextDrawSetOutline(Exp[playerid], 1);
    
TextDrawBackgroundColor(Exp[playerid], 51);
    
TextDrawFont(Exp[playerid], 1);
    
TextDrawSetProportional(Exp[playerid], 1);
    
format(Level_stringsizeof(Level_string), "Level: %d Rank: Beginner"My_Level[playerid]);
    
    
    
Rank[playerid] = TextDrawCreate(483.999877113.493309"Level: 0 Rank: Beginner");
    
TextDrawLetterSize(Rank[playerid], 0.3539991.450666);
    
TextDrawAlignment(Rank[playerid], 1);
    
TextDrawColor(Rank[playerid], -2139094785);
    
TextDrawSetShadow(Rank[playerid], 0);
    
TextDrawSetOutline(Rank[playerid], 1);
    
TextDrawBackgroundColor(Rank[playerid], 51);
    
TextDrawFont(Rank[playerid], 1);
    
TextDrawSetProportional(Rank[playerid], 1);
    
format(ExpFNL_stringsizeof(ExpFNL_string), "Exp For Next Level: %d"My_ExpFNL[playerid]);
    
ExpFNL[playerid] = TextDrawCreate(472.000000126.186546"Exp For Next Level: 120");
    
TextDrawLetterSize(ExpFNL[playerid], 0.3739991.383466);
    
TextDrawAlignment(ExpFNL[playerid], 1);
    
TextDrawColor(ExpFNL[playerid], -2139094785);
    
TextDrawSetShadow(ExpFNL[playerid], 0);
    
TextDrawSetOutline(ExpFNL[playerid], 1);
    
TextDrawBackgroundColor(ExpFNL[playerid], 51);
    
TextDrawFont(ExpFNL[playerid], 1);
    
TextDrawSetProportional(ExpFNL[playerid], 1);
    
TextDrawShowForPlayer(playeridExp[playerid]);
    
TextDrawShowForPlayer(playeridRank[playerid]);
    
TextDrawShowForPlayer(playeridExpFNL[playerid]);
    if(
fexist(UserPath(playerid)))
    {   
        
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
    }
    else
    {
        
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
    }
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    new 
iniFile ini_openFile(UserPath(playerid));
    if ( 
iniFile >= )
    {
        
ini_setInteger(iniFile"Cash",GetPlayerMoney(playerid));
        
ini_setInteger(iniFile"Admin",PlayerInfo[playerid][pAdmin]);
        
ini_setInteger(iniFile"Old",PlayerInfo[playerid][pOld]);
        
ini_setInteger(iniFile"Kills",PlayerInfo[playerid][pKills]);
        
ini_setInteger(iniFile"Deaths",PlayerInfo[playerid][pDeaths]);
        
ini_setInteger(iniFile"Old_Exp",PlayerInfo[playerid][pOld_Exp]);
        
ini_setInteger(iniFile"New_Exp",PlayerInfo[playerid][pNew_Exp]);
        
ini_setInteger(iniFile"My_Level",PlayerInfo[playerid][pMy_Level]);
        
ini_setInteger(iniFile"pMy_Rank",PlayerInfo[playerid][pMy_Rank]);
        
ini_setInteger(iniFile"My_ExpFNL",PlayerInfo[playerid][pMy_ExpFNL]);
        
ini_setInteger(iniFile"Score",GetPlayerScore(playerid));
        
ini_setInteger(iniFile"Color",GetPlayerColor(playerid));
        
ini_setInteger(iniFile"Skin",GetPlayerSkin(playerid));
        
ini_closeFile(iniFile);
    }
    return 
1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    if(
killerid != INVALID_PLAYER_ID)
    {
        
GivePlayerMoney(playerid,-GetPlayerMoney(playerid)/2);
    
PlayerInfo[killerid][pKills] += 1;
    
PlayerInfo[killerid][pScore] += 1;
    
SetPlayerScore(killeridPlayerInfo[killerid][pScore]);
    
New_Exp[killerid] += 90;
    
New_Exp[playerid] -= 90;
      if(
New_Exp[playerid] < 0)
    {
        
New_Exp[playerid] = 0;
      }
    if(
New_Exp[killerid] >= 120 || 120 >= 380)
    {
           
Old_Exp[killerid] = 380;
           
My_Level[killerid] = 1;
        
SendClientMessage(killerid,COLOR_YELLOW,"New Level = 1");
      }
    if(
New_Exp[killerid] >= 380 || 380 >= 900)
    {
           
Old_Exp[killerid] = 900;
           
My_Level[killerid] = 2;
        
SendClientMessage(killerid,COLOR_YELLOW,"New Level = 2");
      }
    if(
New_Exp[killerid] >= 900 || 900 >= 1680)
    {
           
Old_Exp[killerid] = 1680;
           
My_Level[killerid] = 3;
        
SendClientMessage(killerid,COLOR_YELLOW,"New Level = 3");
      }
    if(
New_Exp[killerid] >= 1680 || 1680 >= 2720)
    {
           
Old_Exp[killerid] = 2720;
           
My_Level[killerid] = 4;
        
SendClientMessage(killerid,COLOR_YELLOW,"New Level = 4");
      }
    if(
New_Exp[killerid] >= 2720 || 2720 >= 4020)
    {
           
Old_Exp[killerid] = 4020;
           
My_Level[killerid] = 5;
        
SendClientMessage(killerid,COLOR_YELLOW,"New Level = 5");
      }
    
My_ExpFNL[playerid] = Old_Exp[playerid] - New_Exp[playerid];
    
My_ExpFNL[killerid] = Old_Exp[killerid] - New_Exp[killerid];
        
format(Exp_stringsizeof(Exp_string), "Exp: %d/%d"New_Exp[killerid], Old_Exp[killerid]);
        
        
format(Level_stringsizeof(Level_string), "Level: %d Rank: Beginner"My_Level[killerid]);
        
format(ExpFNL_stringsizeof(ExpFNL_string), "Exp For Next Level: %d"My_ExpFNL[killerid]);
        
TextDrawSetString(Exp[killerid], Exp_string);
        
TextDrawShowForPlayer(killeridExp[killerid]);
        
        
TextDrawSetString(Rank[killerid], Level_string);
        
TextDrawShowForPlayer(killeridRank[killerid]);
    
TextDrawSetString(ExpFNL[killerid], ExpFNL_string);
        
TextDrawShowForPlayer(killeridExpFNL[killerid]);
        
format(Exp_stringsizeof(Exp_string), "Exp: %d/%d"New_Exp[playerid], Old_Exp[playerid]);
        
        
format(Level_stringsizeof(Level_string), "Level: %d Rank: Beginner"My_Level[playerid]);
        
format(ExpFNL_stringsizeof(ExpFNL_string), "Exp For Next Level: %d"My_ExpFNL[playerid]);
        
TextDrawSetString(Exp[playerid], Exp_string);
        
TextDrawShowForPlayer(playeridExp[playerid]);
        
        
TextDrawSetString(Rank[playerid], Level_string);
        
TextDrawShowForPlayer(playeridRank[playerid]);
    
TextDrawSetString(ExpFNL[playerid], ExpFNL_string);
        
TextDrawShowForPlayer(playeridExpFNL[playerid]);    
    }
    return 
1;
}
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 
iniFile ini_createFile(UserPath(playerid));
                if ( 
iniFile )
                    
iniFile ini_openFile(UserPath(playerid));
                    
                if ( 
iniFile >= )
                {
                    
ini_setInteger(iniFile"Password",udb_hash(inputtext));
                    
ini_setInteger(iniFile"Cash",5000);
                    
ini_setInteger(iniFile"Admin",0);
                    
ini_setInteger(iniFile"Kills",0);
                    
ini_setInteger(iniFile"Deaths",0);
                    
ini_setInteger(iniFile"Score",0);
                    
ini_setInteger(iniFile"Color",-1);
                    
ini_setInteger(iniFile"Skin",0);
                    
ini_setInteger(iniFile"Old",0);
                    
ini_setInteger(iniFile"Old_Exp",0);
                    
ini_setInteger(iniFile"New_Exp",0);
                    
ini_setInteger(iniFile"My_Level",0);
                    
ini_setInteger(iniFile"pMy_Rank",0);
                    
ini_setInteger(iniFile"My_ExpFNL",0);
                    
ini_closeFile(iniFile);
                }
                 
PlayerInfo[playerid][pOld] = 0;
                
PlayerInfo[playerid][pOld_Exp] = 0;
                
PlayerInfo[playerid][pNew_Exp] = 0;
                
PlayerInfo[playerid][pMy_Level] = 0;
                
PlayerInfo[playerid][pMy_Rank] = 0;
                
PlayerInfo[playerid][pMy_ExpFNL] = 0;
                
PlayerInfo[playerid][pAdmin] = 0;
                
PlayerInfo[playerid][pKills] = 0;
                
PlayerInfo[playerid][pDeaths] = 0;
                
PlayerInfo[playerid][pSkin] = 0;
                
PlayerInfo[playerid][pScore] = 0;
                
PlayerInfo[playerid][pCash] = 5000;
                
PlayerInfo[playerid][pColor] = -1;
                
                
GivePlayerMoney(playerid5000);
                
SetPlayerColor(playerid, -1);
                
SetPlayerScore(playerid0);
                
GameTextForPlayer(playerid"You succesfully registered your account !Welcome to the server :-)."100004);
            }
        }
        case 
DIALOG_LOGIN:
        {
            if ( !
response ) {
                
Kick playerid );
            }
            else
            {
                if(
LoginPlayer(playeridinputtext))
                {
                    
SetPlayerColor(playeridPlayerInfo[playerid][pColor]);
                
SetPlayerScore(playeridPlayerInfo[playerid][pScore]);
                
GivePlayerMoney(playeridPlayerInfo[playerid][pCash]);
                }
                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;

Please Help Me Problem is When Player Left The Server New_Exp & Old_Exp & My_Level & My_ExpFNL Don't Save
When i Go To Users in Scriptfiles give number to Them And Re Run Server That's Not Change In Server
Please Give Me True Codes For Submit This {New_Exp & Old_Exp & My_Level & My_ExpFNL} Thank's A lot
Reply
#2

Stop using dini. Seriously, just stop.
Reply
#3

For Stop Dini I Should Change A Lot In Gm But i'm not Pro Scripter <3 Please Some One Help
Reply
#4

Any Answer?
Reply
#5

Be patient
Reply
#6

i posted my problem yesterday but no one answer me :<
Reply
#7


Please don't send me PM, you should learn sqlite if you don't want using mysql server.

https://sampwiki.blast.hk/wiki/SQLite
https://en.wikipedia.org/wiki/SQLite
Reply
#8

Transferring over to Y_INI would be rather easy..

Also

stock udb_hash(buf[])

I recommend not to use that, as it's really insecure..
Use Whirlpool or https://sampwiki.blast.hk/wiki/SHA256_PassHash
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)