SA-MP Forums Archive
yini problem - 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: yini problem (/showthread.php?tid=636100)



yini problem - asri - 20.06.2017

im new in yini.

why i create login script,the ini file is blank?

PHP код:
#include <a_samp>
#include <YSI\y_ini>
#include <sscanf2>
#include <zcmd>
 
#define FILTERSCRIPT
 
#define DIALOG_REGISTER                 9998
#define DIALOG_LOGIN                    9999
#define UserPath                                "/Users/%s.ini"
 
#define COLOR_RED                               0xFF0000FF
#define COLOR_BLUE                              0x0000FFFF
#define COLOR_YELLOW                    0xFFFF00FF
#define COLOR_GREEN                             0x00FF00FF
#define COLOR_LIGHTBLUE                 0x00FFFFFF
#define COLOR_WHITE                             0xFFFFFFFF
#define COLOR_BLACK                             0x000000FF
#define COLOR_GRAY                              0x808080FF
 
native WP_Hash(buffer[],len,const str[]);
 
forward loadaccount_user(playeridname[], value[]);
 
#if defined FILTERSCRIPT
 
public OnFilterScriptInit()
{
        return 
1;
}
 
public 
OnFilterScriptExit()
{
        return 
1;
}
 
#else
 
main()
{
        print(
"\n----------------------------------");
        print(
" Blank Gamemode by your name here");
        print(
"----------------------------------\n");
}
 
#endif
 
 
enum PlayerStats
{
        
password[128],
        
money,
        
score,
        
deaths,
        
admin,
}
new 
pStats[MAX_PLAYERS][PlayerStats];
 
public 
OnPlayerConnect(playerid)
{
        new 
name[MAX_PLAYER_NAME];
        
GetPlayerName(playerid,name,sizeof(name));
        if(
fexist(Path(playerid)))
        {
                
INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra true, .extra playerid);
                
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_PASSWORD"{00FFFF}Login""{00FFFF}Please enter your password to login.""OK""Cancel");
        }
        else
        {
                
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_PASSWORD"{00FFFF}Register""{00FFFF}Please enter your password to register.""OK""Cancel");
        }
        return 
1;
}
 
public 
OnPlayerDisconnect(playeridreason)
{
    new 
INI:file INI_Open(Path(playerid));
    
INI_WriteInt(file,"Money",GetPlayerMoney(playerid));
    
INI_WriteInt(file,"Score",GetPlayerScore(playerid));
    
INI_WriteInt(file,"Deaths",pStats[playerid][deaths]);
    
INI_WriteInt(file,"Admin",pStats[playerid][admin]);
    
INI_Close(file);
    return 
1;
}
 
public 
OnPlayerSpawn(playerid)
{
        
ResetPlayerMoney(playerid);
        
GivePlayerMoney(playeridpStats[playerid][money]);
        
SetPlayerScore(playeridpStats[playerid][score]);
        return 
1;
}
 
public 
OnPlayerDeath(playeridkilleridreason)
{
        
pStats[killerid][score]++;
        
pStats[killerid][money]++;
        
pStats[playerid][deaths]++;
        
GivePlayerMoney(killerid1);
        
SetPlayerScore(killeridpStats[killerid][score]);
        return 
1;
}
 
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if(
response)
    {
        switch(
dialogid)
        {
            case 
DIALOG_REGISTER:
            {
                                if(!
response) return Kick(playerid);
                                if(
response)
                                {
                                        if(!
strlen(inputtext))
                                        {
                                                
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_PASSWORD"{00FFFF}Register""{00FFFF}Please enter your password to register.\n{FF0000}You can't leave this empty.""OK""Cancel");
                                                return 
1;
                                        }
                                        new 
hashpass[129];
                                        
WP_Hash(hashpass,sizeof(hashpass),inputtext);
                                        new 
string[128];
                                        new 
INI:file INI_Open(Path(playerid));
                                        
INI_WriteString(file,"Password",hashpass);
                                        
INI_WriteInt(file,"Money",0);
                                        
INI_WriteInt(file,"Score",0);
                                        
INI_WriteInt(file,"Deaths",0);
                                        
INI_WriteInt(file,"Admin",0);
                                        
INI_Close(file);
                                        
format(stringsizeof(string), "You have successfully registered. Password: {00FF00)%s"inputtext);
                                        
SendClientMessage(playeridCOLOR_WHITEstring);
                                        return 
1;
                                }
                        }
                        case 
DIALOG_LOGIN:
                        {
                                if(!
response) return Kick(playerid);
                                if(
response)
                                {
                                new 
hashpass[129];
                                
WP_Hash(hashpass,sizeof(hashpass),inputtext);
                                if(!
strcmp(hashpasspStats[playerid][password], false))
                                {
                                                
INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra true, .extra playerid);
                                                
SendClientMessage(playerid,COLOR_WHITE,"You have successfully logged in.");
                                        }
                                        else
                                        {
                                                
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_PASSWORD"Login""{00FFFF}Please enter your password to login.\n{FF0000}Incorrect password.""OK""Cancel");
                                                return 
1;
                                        }
                                }
                        }
                }
    }
    return 
1;
}
 
public 
loadaccount_user(playeridname[], value[])
{
        
INI_String("Password",pStats[playerid][password],128);
        
INI_Int("Money",pStats[playerid][money]);
        
INI_Int("Score",pStats[playerid][score]);
        
INI_Int("Deaths",pStats[playerid][deaths]);
        
INI_Int("Admin",pStats[playerid][admin]);
        return 
1;
}
 
stock Path(playerid)
{
        new 
str[128],name[MAX_PLAYER_NAME];
        
GetPlayerName(playerid,name,sizeof(name));
        
format(str,sizeof(str),UserPath,name);
        return 
str;




Re: yini problem - NewFreeroamStunt - 20.06.2017

does you get some errors when you compile the script?
Try update your include


Re: yini problem - crukk11 - 21.06.2017

All i update it


Re: yini problem - Whatname - 21.06.2017

PHP код:
password[128
PHP код:
password[129
whirlpool takes 129!


Re: yini problem - crukk11 - 21.06.2017

Same


Re: yini problem - crukk11 - 21.06.2017

The script is fine.why you ini is blank


Re: yini problem - asri - 21.06.2017

I dont no.


Re: yini problem - asri - 22.06.2017

bump


Re: yini problem - asri - 23.06.2017

Why i enter the wrong it can login


Re: yini problem - asri - 23.06.2017

Why?