SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 27/03/2020, 03:50 PM   #1
Calinut200
Big Clucker
 
Join Date: Jun 2016
Posts: 74
Reputation: 0
Default Account not save

Hello everyone! I make a register/login sistem from a tutorial and is works fine but when i put my server on host, after dissconect from server, the server dosen't save the account in scriptfiles/users/x.ini. That .ini notepad is blank, but in my pc is working.
Look here for code
PHP Code:
//============================================================================//
//                           INCLUDURI
#include <a_samp>
#define MAX_INI_ENTRY_TEXT 130
#include <YSI\y_ini>
#include <zcmd>
#include <sscanf2>
//============================================================================//
//                          PRESCURTARI
#define SCM SendClientMessage
//============================================================================//
//                         DEFINERUI
#define dialog_tp 1
#define DIALOG_REGISTER 2
#define DIALOG_LOGIN 3
#define DIALOG_SUCCESS_1 4
#define DIALOG_SUCCESS_2 5
#define PATH "/Users/%s.ini"
//============================================================================//
/*                              SPECIFICATORI
Specifier(s)            Name                Example values
    i, d            Integer                1, 42, -10
    c            Character            a, o, *
    l            Logical                true, false
    b            Binary                01001, 0b1100
    h, x            Hex                1A, 0x23
    o            Octal                045 12
    n            Number                42, 0b010, 0xAC, 045
    f            Float                0.7, -99.5
    g            IEEE Float            0.7, -99.5, INFINITY, -INFINITY, NAN, NAN_E
    u            User name/id (bots and players)    ******, 0
    q            Bot name/id            ShopBot, 27
    r            Player name/id            ******, 42
*/
//============================================================================//
//                              CULORI
#define alb "{FFFFFF}"
#define rosu "{F81414}"
#define COL_WHITE "{FFFFFF}"
#define COL_RED "{F81414}"
#define COL_GREEN "{00FF22}"
#define COL_LIGHTBLUE "{00CED1}"

//============================================================================//
enum pInfo
{
    
pPass,
    
pMoney,
    
pAdmin,
    
pSkin,
    
pLevel
}
new 
PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public 
LoadUser_data(playerid,name[],value[])
{
    
INI_Int("Password",PlayerInfo[playerid][pPass]);
    
INI_Int("Cash",PlayerInfo[playerid][pMoney]);
    
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    return 
1;
}
stock UserPath(playerid)
{
    new 
string[128],playername[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,playername,sizeof(playername));
    
format(string,sizeof(string),PATH,playername);
    return 
string;
}

/*Credits to Dracoblue*/
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 OnGameModeInit()
{
    
SetGameModeText("Beta Version 0.1");
    
AddPlayerClass(02850.0876,1290.6294,11.3906,88.6742000000);
    
CreateVehicle(411,2039.9590,1337.3813,10.6719,0,222,0,-1,0);
    return 
1;
}

public 
OnGameModeExit()
{
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    
//====================//
    
if(fexist(UserPath(playerid)))
    {
        
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra 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 
INI:File INI_Open(UserPath(playerid));
    
INI_SetTag(File,"data");
    
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    
INI_Close(File);
    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 
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,"Admin",0);
                
INI_WriteInt(File,"Kills",0);
                
INI_WriteInt(File,"Deaths",0);
                
INI_Close(File);

                
SetSpawnInfo(playerid001958.331343.1215.36269.15000000);
                
SpawnPlayer(playerid);
                
ShowPlayerDialog(playeridDIALOG_SUCCESS_1DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! Your Y_INI system works perfectly. Relog to save your stats!","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(playeridPlayerInfo[playerid][pMoney]);
                    
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;
            }
        }
    }

    
//=================================//
    
if(response)
    {
    switch(
dialogid)
    {
    case 
dialog_tp:
    {
    switch(
listitem)
    {
    case 
0:
    {
        
SCM(playerid,-1,"Te-ai teleportat cu succes!");
        
SetPlayerPos(playerid,2323.4741,1283.0110,97.3602);
    }
    case 
1:
    {
        
SCM(playerid,-1,"Nu esti autorizat!");
    }
    case 
2:
    {
        
SCM(playerid,-1,"Nu esti autorizat!");
     }
    }
    }
    }
    }
    return 
1;
    
//=================================//
}

public 
OnPlayerClickPlayer(playeridclickedplayeridsource)
{
    return 
1;

Calinut200 is offline   Reply With Quote
Old 27/03/2020, 05:41 PM   #2
Calinut200
Big Clucker
 
Join Date: Jun 2016
Posts: 74
Reputation: 0
Default Re: Account not save

Someone|?
Calinut200 is offline   Reply With Quote
Old 27/03/2020, 05:45 PM   #3
v1k1nG
Huge Clucker
 
v1k1nG's Avatar
 
Join Date: Feb 2018
Posts: 497
Reputation: 35
Default Re: Account not save

Don't go crazy after .ini files, to save players' accounts it's better to learn MySql.
Backup your gamemode and try.
__________________
My test server: 51.91.122.18:7778
My Discord contact: [SF]kAn3#9933
YT https://www.youtube.com/channel/UCrM...QtP2pczguqvppw
v1k1nG 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
can't save account fahlevy Scripting Help 8 21/12/2014 11:49 PM
Save all account in /gmx? alanhutch Scripting Help 3 08/08/2014 04:52 PM
Save Account radiobizza Scripting Help 7 15/09/2013 03:14 PM
Save Account problem falling Scripting Help 1 04/01/2012 08:02 AM
bug with account save qUick1337 Help Archive 14 24/07/2011 11:53 AM


All times are GMT. The time now is 04:38 AM.


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