Why the skin is not saved?
#1

I've been doing this code for almost a whole day and I can not understand why the skin is not being stored.

I think he has come to understand that the fault is in the charge of the skin. (Pawno does not give me any error when compiling)
Код:
#include <a_samp>
#include <YSI\y_ini>

#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2

#define PATH "/Users/%s.ini"

enum pInfo
{
    pPass,
    pSkin
}
new PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Pass",PlayerInfo[playerid][pPass]);
    INI_Int("Skin",PlayerInfo[playerid][pSkin]);
    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;
}

stock udb_hash(buf[]) {
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}

public OnPlayerConnect(playerid)
{
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Inicio de sesiуn.","Escribe tu contraseсa para iniciar la sesiуn.","Iniciar","Cancelar");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Registrando al jugador.","Escribe tu contraseсa para crear una nueva cuenta.","Registrar","Cancelar");
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
    INI_Close(File);
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registrando al jugador.","Has introducido una clave invбlida.\nEscribe tu clave para registrar una nueva cuenta.","Registrar","Cancelar");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Pass",udb_hash(inputtext));
                INI_WriteInt(File,"Skin",1);
                INI_Close(File);

				AddPlayerClass(PlayerInfo[playerid][pSkin], 1958.33, 1343.12, 15.36, 269.15, 26, 36, 28, 150, 0, 0);
            }
        }
        
        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);
	                AddPlayerClass(PlayerInfo[playerid][pSkin], 1958.33, 1343.12, 15.36, 269.15, 26, 36, 28, 150, 0, 0);
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Inicio de sesiуn.","Has introducido una clave invбlida.\nEscribe tu clave para iniciar la sesiуn.","Iniciar","Cancelar");
                }
                return 1;
        	}
        }
    }
    return 1;
}
Thanks in advance, I have some great ideas to do a RP, hopefully I can get to contribute to the community.
Reply
#2

Use GetPlayerSkin and add it to the PlayerInfo[playerid][pSkin] variable on OnPlayerDisconnect or on your saving function.
Reply
#3

nvm i got it wrong
Reply
#4

Quote:
Originally Posted by dakata994
Посмотреть сообщение
Use GetPlayerSkin and add it to the PlayerInfo[playerid][pSkin] variable on OnPlayerDisconnect or on your saving function.
How can i make this?
Reply
#5

Quote:
Originally Posted by Flamehaze7
Посмотреть сообщение
nvm i got it wrong
Can you help me?
Reply
#6

Here:

Код:
PlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid);
Put this on your Save Function.
Reply
#7

You're doing few things wrong:

PHP код:
        case DIALOG_REGISTER:
        {
            if (!
response) return Kick(playerid);
            if(
response)
            {
                if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT"Registrando al jugador.","Has introducido una clave invбlida.\nEscribe tu clave para registrar una nueva cuenta.","Registrar","Cancelar");
                new 
INI:File INI_Open(UserPath(playerid));
                
INI_SetTag(File,"data");
                
INI_WriteInt(File,"Pass",udb_hash(inputtext));
                
INI_WriteInt(File,"Skin",1); // You don't have to set this value as it'll set itself later when the player disconnects
                
INI_Close(File);
        
AddPlayerClass(PlayerInfo[playerid][pSkin], 1958.331343.1215.36269.1526362815000); // there's no PlayerInfo[playerid][pSkin] value yet as you have not written anything to it in this part of the script
            
}
        } 
Also, AddPlayerClass does not work as you think it does

PHP код:
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid); // This is useless here as you've loaded the player's data under OnPlayerConnect
                
AddPlayerClass(PlayerInfo[playerid][pSkin], 1958.331343.1215.36269.1526362815000); // Should be changed for SetSpawnInfo
                

https://sampwiki.blast.hk/wiki/SetSpawnInfo
Reply
#8

Quote:
Originally Posted by dakata994
Посмотреть сообщение
Here:

Код:
PlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid);
Put this on your Save Function.
Quote:
Originally Posted by Troydere
Посмотреть сообщение
You're doing few things wrong:

PHP код:
        case DIALOG_REGISTER:
        {
            if (!
response) return Kick(playerid);
            if(
response)
            {
                if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT"Registrando al jugador.","Has introducido una clave invбlida.\nEscribe tu clave para registrar una nueva cuenta.","Registrar","Cancelar");
                new 
INI:File INI_Open(UserPath(playerid));
                
INI_SetTag(File,"data");
                
INI_WriteInt(File,"Pass",udb_hash(inputtext));
                
INI_WriteInt(File,"Skin",1); // You don't have to set this value as it'll set itself later when the player disconnects
                
INI_Close(File);
        
AddPlayerClass(PlayerInfo[playerid][pSkin], 1958.331343.1215.36269.1526362815000); // there's no PlayerInfo[playerid][pSkin] value yet as you have not written anything to it in this part of the script
            
}
        } 
Also, AddPlayerClass does not work as you think it does

PHP код:
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid); // This is useless here as you've loaded the player's data under OnPlayerConnect
                
AddPlayerClass(PlayerInfo[playerid][pSkin], 1958.331343.1215.36269.1526362815000); // Should be changed for SetSpawnInfo
                

https://sampwiki.blast.hk/wiki/SetSpawnInfo
Thanks to all for the help.
I already managed to solve it, I love you

Closed topic.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)