Loading system failing
#1

Hi!

I have some problems with my loading system, I'm trying to load a file called Vehicles, it's saved properly, but when I log-in automatically, all the values in that file become to 0. That's happening with the skin, money and position loading. Don't know why that can be. I post here the code where I modify, save and load the file. I have tried everything, even rewriting the full loading/saving system...

The enum:
Код:
enum CarInfo
{
    pVehicle1,
	pVehicle1Model,
	Float:pVehicle1X,
	Float:pVehicle1Y,
	Float:pVehicle1Z,
	Float:pVehicle1C,
	pVehicle1Color1,
	pVehicle1Color2,
	pVehicle1Value,
	pVehicle1Plate,
	pVehicle1Lock,
	pVehicle2,
	pVehicle2Model,
	Float:pVehicle2X,
	Float:pVehicle2Y,
	Float:pVehicle2Z,
	Float:pVehicle2C,
	pVehicle2Color1,
	pVehicle2Color2,
	pVehicle2Value,
	pVehicle2Plate,
	pVehicle2Lock,
	pVehicle3,
	pVehicle3Model,
	Float:pVehicle3X,
	Float:pVehicle3Y,
	Float:pVehicle3Z,
	Float:pVehicle3C,
	pVehicle3Color1,
	pVehicle3Color2,
	pVehicle3Value,
	pVehicle3Plate,
	pVehicle3Lock
}
new PlayerCars[MAX_PLAYERS][CarInfo];
Dialog register:
Код:
case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registering...","You've entered an invalid password.\nEnter a new password to create a new account.","Register","Exit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Admin",0);
                INI_WriteFloat(File,"Pos_x",0);
    			INI_WriteFloat(File,"Pos_y",0);
    			INI_WriteFloat(File,"Pos_z",0);
   			 	INI_WriteInt(File,"Accent",0);
                INI_Close(File);
                
                new INI:Archivo = INI_Open(UserCars(playerid));
                INI_SetTag(Archivo,"Vehicles");
                INI_WriteInt(Archivo,"Vehicle1",PlayerCars[playerid][pVehicle1]);
				INI_WriteInt(Archivo,"Vehicle1Model",PlayerCars[playerid][pVehicle1Model]);
				INI_WriteFloat(Archivo,"Vehicle1X",PlayerCars[playerid][pVehicle1X]);
				INI_WriteFloat(Archivo,"Vehicle1Y",PlayerCars[playerid][pVehicle1Y]);
				INI_WriteFloat(Archivo,"Vehicle1Z",PlayerCars[playerid][pVehicle1Z]);
				INI_WriteFloat(Archivo,"Vehicle1C",PlayerCars[playerid][pVehicle1C]);
				INI_WriteInt(Archivo,"Vehicle1Color1",PlayerCars[playerid][pVehicle1Color1]);
				INI_WriteInt(Archivo,"Vehicle1Color2",PlayerCars[playerid][pVehicle1Color2]);
				INI_WriteInt(Archivo,"Vehicle1Value",PlayerCars[playerid][pVehicle1Value]);
				INI_WriteString(Archivo,"Vehicle1Plate",PlayerCars[playerid][pVehicle1Plate]);
				INI_WriteInt(Archivo,"Vehicle1Lock",PlayerCars[playerid][pVehicle1Lock]);
				INI_WriteInt(Archivo,"Vehicle2",PlayerCars[playerid][pVehicle2]);
				INI_WriteInt(Archivo,"Vehicle2Model",PlayerCars[playerid][pVehicle2Model]);
				INI_WriteFloat(Archivo,"Vehicle2X",PlayerCars[playerid][pVehicle2X]);
				INI_WriteFloat(Archivo,"Vehicle2Y",PlayerCars[playerid][pVehicle2Y]);
				INI_WriteFloat(Archivo,"Vehicle2Z",PlayerCars[playerid][pVehicle2Z]);
				INI_WriteFloat(Archivo,"Vehicle2C",PlayerCars[playerid][pVehicle2C]);
				INI_WriteInt(Archivo,"Vehicle2Color1",PlayerCars[playerid][pVehicle2Color1]);
				INI_WriteInt(Archivo,"Vehicle2Color2",PlayerCars[playerid][pVehicle2Color2]);
				INI_WriteInt(Archivo,"Vehicle2Value",PlayerCars[playerid][pVehicle2Value]);
				INI_WriteString(Archivo,"Vehicle2Plate",PlayerCars[playerid][pVehicle2Plate]);
				INI_WriteInt(Archivo,"Vehicle2Lock",PlayerCars[playerid][pVehicle2Lock]);
				INI_WriteInt(Archivo,"Vehicle3",PlayerCars[playerid][pVehicle3]);
				INI_WriteInt(Archivo,"Vehicle3Model",PlayerCars[playerid][pVehicle3Model]);
				INI_WriteFloat(Archivo,"Vehicle3X",PlayerCars[playerid][pVehicle3X]);
				INI_WriteFloat(Archivo,"Vehicle3Y",PlayerCars[playerid][pVehicle3Y]);
				INI_WriteFloat(Archivo,"Vehicle3Z",PlayerCars[playerid][pVehicle3Z]);
				INI_WriteFloat(Archivo,"Vehicle3C",PlayerCars[playerid][pVehicle3C]);
				INI_WriteInt(Archivo,"Vehicle3Color1",PlayerCars[playerid][pVehicle3Color1]);
				INI_WriteInt(Archivo,"Vehicle3Color2",PlayerCars[playerid][pVehicle3Color2]);
				INI_WriteInt(Archivo,"Vehicle3Value",PlayerCars[playerid][pVehicle3Value]);
				INI_WriteString(Archivo,"Vehicle3Plate",PlayerCars[playerid][pVehicle3Plate]);
				INI_WriteInt(Archivo,"Vehicle3Lock",PlayerCars[playerid][pVehicle3Lock]);

                INI_Close(Archivo);
                
                ShowPlayerDialog(playerid, DIALOG_SEX, DIALOG_STYLE_MSGBOX, "- Sex -","Put your gender","Male","Female");
            }
        }
The UserCars stock used:
Код:
#define PATH "Vehicles/%s.ini"

stock UserCars(playerid)
{
	new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}
OnPlayerSpawn:
Код:
new personalcar1[MAX_PLAYERS];
new personalcar2[MAX_PLAYERS];
new personalcar3[MAX_PLAYERS];

if(PlayerCars[playerid][pVehicle1] != 0)
		{
		    new model1 = PlayerCars[playerid][pVehicle1Model];
		    new Float:car1x = PlayerCars[playerid][pVehicle1X];
		    new Float:car1y = PlayerCars[playerid][pVehicle1Y];
		    new Float:car1z = PlayerCars[playerid][pVehicle1Z];
		    new Float:car1c = PlayerCars[playerid][pVehicle1C];
		    new car1color1 = PlayerCars[playerid][pVehicle1Color1];
		    new car1color2 = PlayerCars[playerid][pVehicle1Color2];
		    new car1lock = PlayerCars[playerid][pVehicle1Lock];
		    personalcar1[playerid] = CreateVehicle(model1, car1x, car1y, car1z, car1c, car1color1, car1color2, 999999);
		    SetVehicleNumberPlate(personalcar1[playerid], PlayerCars[playerid][pVehicle1Plate]);
			new engine, lights, alarm, doors, bonnet, boot, objective;
		    if(car1lock != 0)
		    {
				GetVehicleParamsEx(personalcar1[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
				SetVehicleParamsEx(personalcar1[playerid], engine, lights, alarm, 1, bonnet, boot, objective);
			}
		}
		if(PlayerCars[playerid][pVehicle2] != 0)
		{
		    new model2 = PlayerCars[playerid][pVehicle2Model];
		    new Float:car2x = PlayerCars[playerid][pVehicle2X];
		    new Float:car2y = PlayerCars[playerid][pVehicle2Y];
		    new Float:car2z = PlayerCars[playerid][pVehicle2Z];
		    new Float:car2c = PlayerCars[playerid][pVehicle2C];
		    new car2color1 = PlayerCars[playerid][pVehicle2Color1];
		    new car2color2 = PlayerCars[playerid][pVehicle2Color2];
		    new car2lock = PlayerCars[playerid][pVehicle2Lock];
		    personalcar2[playerid] = CreateVehicle(model2, car2x, car2y, car2z, car2c, car2color1, car2color2, 999999);
		    SetVehicleNumberPlate(personalcar2[playerid], PlayerCars[playerid][pVehicle2Plate]);
		    new engine, lights, alarm, doors, bonnet, boot, objective;
		    if(car2lock != 0)
		    {
				GetVehicleParamsEx(personalcar2[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
				SetVehicleParamsEx(personalcar2[playerid], engine, lights, alarm, 1, bonnet, boot, objective);
			}
		}
		if(PlayerCars[playerid][pVehicle3] != 0)
		{
		    new model3 = PlayerCars[playerid][pVehicle3Model];
		    new Float:car3x = PlayerCars[playerid][pVehicle3X];
		    new Float:car3y = PlayerCars[playerid][pVehicle3Y];
		    new Float:car3z = PlayerCars[playerid][pVehicle3Z];
		    new Float:car3c = PlayerCars[playerid][pVehicle3C];
		    new car3color1 = PlayerCars[playerid][pVehicle3Color1];
		    new car3color2 = PlayerCars[playerid][pVehicle3Color2];
		    new car3lock = PlayerCars[playerid][pVehicle3Lock];
		    personalcar3[playerid] = CreateVehicle(model3, car3x, car3y, car3z, car3c, car3color1, car3color2, 999999);
		    SetVehicleNumberPlate(personalcar3[playerid], PlayerCars[playerid][pVehicle3Plate]);
		    new engine, lights, alarm, doors, bonnet, boot, objective;
		    if(car3lock != 0)
		    {
				GetVehicleParamsEx(personalcar3[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
				SetVehicleParamsEx(personalcar3[playerid], engine, lights, alarm, 1, bonnet, boot, objective);
			}
		}
SaveAccountStats function:
Код:
function SaveAccountStats(playerid)
{
	new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    
   	PlayerInfo[playerid][Skin] = GetPlayerSkin(playerid);
    PlayerInfo[playerid][Cartera] = GetPlayerMoney(playerid);
   	new
	   	Float:x,
	    Float:y,
		Float:z
	;
	GetPlayerPos(playerid,x,y,z);
	PlayerInfo[playerid][pPos_x] = x;
	PlayerInfo[playerid][pPos_y] = y;
	PlayerInfo[playerid][pPos_z] = z;

    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Faccion",PlayerInfo[playerid][Faccion]);
    INI_WriteInt(File,"Rango",PlayerInfo[playerid][Rango]);
    INI_WriteInt(File,"Payday",PlayerInfo[playerid][Payday]);
    INI_WriteInt(File,"Respeto",PlayerInfo[playerid][Respeto]);
    INI_WriteInt(File,"Nivel",PlayerInfo[playerid][Nivel]);
    INI_WriteFloat(File,"Pos_x",PlayerInfo[playerid][pPos_x]);
    INI_WriteFloat(File,"Pos_y",PlayerInfo[playerid][pPos_y]);
    INI_WriteFloat(File,"Pos_z",PlayerInfo[playerid][pPos_z]);
    INI_WriteInt(File,"Accent",PlayerInfo[playerid][pAccent]);
    INI_WriteInt(File,"Sexo",PlayerInfo[playerid][Sexo]);
    INI_WriteInt(File,"Edad",PlayerInfo[playerid][Edad]);
    INI_WriteInt(File,"Skin",PlayerInfo[playerid][Skin]);
    INI_WriteInt(File,"Cartera",PlayerInfo[playerid][Cartera]);
    
    INI_Close(File);
    
    new INI:Archivo = INI_Open(UserCars(playerid));
    INI_SetTag(Archivo,"Vehicles");
    
    INI_WriteInt(Archivo,"Vehicle1",PlayerCars[playerid][pVehicle1]);
	INI_WriteInt(Archivo,"Vehicle1Model",PlayerCars[playerid][pVehicle1Model]);
	INI_WriteFloat(Archivo,"Vehicle1X",PlayerCars[playerid][pVehicle1X]);
	INI_WriteFloat(Archivo,"Vehicle1Y",PlayerCars[playerid][pVehicle1Y]);
	INI_WriteFloat(Archivo,"Vehicle1Z",PlayerCars[playerid][pVehicle1Z]);
	INI_WriteFloat(Archivo,"Vehicle1C",PlayerCars[playerid][pVehicle1C]);
	INI_WriteInt(Archivo,"Vehicle1Color1",PlayerCars[playerid][pVehicle1Color1]);
	INI_WriteInt(Archivo,"Vehicle1Color2",PlayerCars[playerid][pVehicle1Color2]);
	INI_WriteInt(Archivo,"Vehicle1Value",PlayerCars[playerid][pVehicle1Value]);
	INI_WriteString(Archivo,"Vehicle1Plate",PlayerCars[playerid][pVehicle1Plate]);
	INI_WriteInt(Archivo,"Vehicle1Lock",PlayerCars[playerid][pVehicle1Lock]);
	INI_WriteInt(Archivo,"Vehicle2",PlayerCars[playerid][pVehicle2]);
	INI_WriteInt(Archivo,"Vehicle2Model",PlayerCars[playerid][pVehicle2Model]);
	INI_WriteFloat(Archivo,"Vehicle2X",PlayerCars[playerid][pVehicle2X]);
	INI_WriteFloat(Archivo,"Vehicle2Y",PlayerCars[playerid][pVehicle2Y]);
	INI_WriteFloat(Archivo,"Vehicle2Z",PlayerCars[playerid][pVehicle2Z]);
	INI_WriteFloat(Archivo,"Vehicle2C",PlayerCars[playerid][pVehicle2C]);
	INI_WriteInt(Archivo,"Vehicle2Color1",PlayerCars[playerid][pVehicle2Color1]);
	INI_WriteInt(Archivo,"Vehicle2Color2",PlayerCars[playerid][pVehicle2Color2]);
	INI_WriteInt(Archivo,"Vehicle2Value",PlayerCars[playerid][pVehicle2Value]);
	INI_WriteString(Archivo,"Vehicle2Plate",PlayerCars[playerid][pVehicle2Plate]);
	INI_WriteInt(Archivo,"Vehicle2Lock",PlayerCars[playerid][pVehicle2Lock]);
	INI_WriteInt(Archivo,"Vehicle3",PlayerCars[playerid][pVehicle3]);
	INI_WriteInt(Archivo,"Vehicle3Model",PlayerCars[playerid][pVehicle3Model]);
	INI_WriteFloat(Archivo,"Vehicle3X",PlayerCars[playerid][pVehicle3X]);
	INI_WriteFloat(Archivo,"Vehicle3Y",PlayerCars[playerid][pVehicle3Y]);
	INI_WriteFloat(Archivo,"Vehicle3Z",PlayerCars[playerid][pVehicle3Z]);
	INI_WriteFloat(Archivo,"Vehicle3C",PlayerCars[playerid][pVehicle3C]);
	INI_WriteInt(Archivo,"Vehicle3Color1",PlayerCars[playerid][pVehicle3Color1]);
	INI_WriteInt(Archivo,"Vehicle3Color2",PlayerCars[playerid][pVehicle3Color2]);
	INI_WriteInt(Archivo,"Vehicle3Value",PlayerCars[playerid][pVehicle3Value]);
	INI_WriteString(Archivo,"Vehicle3Plate",PlayerCars[playerid][pVehicle3Plate]);
	INI_WriteInt(Archivo,"Vehicle3Lock",PlayerCars[playerid][pVehicle3Lock]);
	
	INI_Close(Archivo);
    return 1;
}
And LoadUserData:
Код:
forward LoadUser_data(playerid,name[],value[]);

public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Faccion",PlayerInfo[playerid][Faccion]);
    INI_Int("Rango",PlayerInfo[playerid][Rango]);
    INI_Int("Payday",PlayerInfo[playerid][Payday]);
    INI_Int("Respeto",PlayerInfo[playerid][Respeto]);
    INI_Int("Nivel",PlayerInfo[playerid][Nivel]);
    INI_Float("Pos_x",PlayerInfo[playerid][pPos_x]);
    INI_Float("Pos_y",PlayerInfo[playerid][pPos_y]);
    INI_Float("Pos_z",PlayerInfo[playerid][pPos_z]);
    INI_Int("Accent",PlayerInfo[playerid][pAccent]);
    INI_Int("Sexo",PlayerInfo[playerid][Sexo]);
    INI_Int("Edad",PlayerInfo[playerid][Edad]);
    INI_Int("Skin",PlayerInfo[playerid][Skin]);
    INI_Int("Cartera",PlayerInfo[playerid][Cartera]);
    
    INI_Int("Vehicle1",PlayerCars[playerid][pVehicle1]);
	INI_Int("Vehicle1Model",PlayerCars[playerid][pVehicle1Model]);
	INI_Float("Vehicle1X",PlayerCars[playerid][pVehicle1X]);
	INI_Float("Vehicle1Y",PlayerCars[playerid][pVehicle1Y]);
	INI_Float("Vehicle1Z",PlayerCars[playerid][pVehicle1Z]);
	INI_Float("Vehicle1C",PlayerCars[playerid][pVehicle1C]);
	INI_Int("Vehicle1Color1",PlayerCars[playerid][pVehicle1Color1]);
	INI_Int("Vehicle1Color2",PlayerCars[playerid][pVehicle1Color2]);
	INI_Int("Vehicle1Value",PlayerCars[playerid][pVehicle1Value]);
	INI_ParseFile("Vehicle1Plate",PlayerCars[playerid][pVehicle1Plate]);
	INI_Int("Vehicle1Lock",PlayerCars[playerid][pVehicle1Lock]);
	INI_Int("Vehicle2",PlayerCars[playerid][pVehicle2]);
	INI_Int("Vehicle2Model",PlayerCars[playerid][pVehicle2Model]);
	INI_Float("Vehicle2X",PlayerCars[playerid][pVehicle2X]);
	INI_Float("Vehicle2Y",PlayerCars[playerid][pVehicle2Y]);
	INI_Float("Vehicle2Z",PlayerCars[playerid][pVehicle2Z]);
	INI_Float("Vehicle2C",PlayerCars[playerid][pVehicle2C]);
	INI_Int("Vehicle2Color1",PlayerCars[playerid][pVehicle2Color1]);
	INI_Int("Vehicle2Color2",PlayerCars[playerid][pVehicle2Color2]);
	INI_Int("Vehicle2Value",PlayerCars[playerid][pVehicle2Value]);
	INI_ParseFile("Vehicle2Plate",PlayerCars[playerid][pVehicle2Plate]);
	INI_Int("Vehicle2Lock",PlayerCars[playerid][pVehicle2Lock]);
	INI_Int("Vehicle3",PlayerCars[playerid][pVehicle3]);
	INI_Int("Vehicle3Model",PlayerCars[playerid][pVehicle3Model]);
	INI_Float("Vehicle3X",PlayerCars[playerid][pVehicle3X]);
	INI_Float("Vehicle3Y",PlayerCars[playerid][pVehicle3Y]);
	INI_Float("Vehicle3Z",PlayerCars[playerid][pVehicle3Z]);
	INI_Float("Vehicle3C",PlayerCars[playerid][pVehicle3C]);
	INI_Int("Vehicle3Color1",PlayerCars[playerid][pVehicle3Color1]);
	INI_Int("Vehicle3Color2",PlayerCars[playerid][pVehicle3Color2]);
	INI_Int("Vehicle3Value",PlayerCars[playerid][pVehicle3Value]);
	INI_ParseFile("Vehicle3Plate",PlayerCars[playerid][pVehicle3Plate]);
	INI_Int("Vehicle3Lock",PlayerCars[playerid][pVehicle3Lock]);
	
    return 1;
}
And that's a command I've created to test:
Код:
CMD:asetveh(playerid, params[])
{
	new targetid, space, model, vehicleid, string[128], Float:x, Float:y, Float:z, Float:r, color1, color2;
	vehicleid = GetClosestVehicle(playerid, 10);
	model = GetVehicleModel(vehicleid);
	GetVehiclePos(vehicleid, x, y, z);
	GetVehicleZAngle(vehicleid, r);
	GetVehicleColor(vehicleid, color1, color2);
    if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_GRAD1, "[ERROR] You are not authorised!");
	if(PlayerInfo[playerid][AdminDuty] == 0) return SendClientMessage(playerid, COLOR_GRAD1, "[ERROR] You are not admin duty!");
	if(PlayerInfo[playerid][AdminDuty] == 1)
	if(sscanf(params, "ud", targetid, space)) return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: {FFFFFF}/asetveh [ID] [Space]");
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Invalid ID.");
	if(space< 1 || space> 3) return SendClientMessage(playerid, COLOR_GREY, "* Space must be 1, 2 or 3.");
	
	format(string, sizeof(string),"AdmCmd: %s set  %s car %d(model %d), into the slot %d", RPName( playerid ), RPName(targetid), vehicleid, model, space);
	SendAdminMessage(COLOR_RED,string);
	if(space== 1)
	{
		PlayerCars[playerid][pVehicle1] = vehicleid;
		PlayerCars[playerid][pVehicle1Model] = model;
		PlayerCars[playerid][pVehicle1X] = x;
		PlayerCars[playerid][pVehicle1Y] = y;
		PlayerCars[playerid][pVehicle1Z] = z;
        PlayerCars[playerid][pVehicle1C] = r;
        PlayerCars[playerid][pVehicle1Color1] = color1;
        PlayerCars[playerid][pVehicle1Color2] = color2;
		return 1;
	}
	if(space== 2)
	{
		PlayerCars[playerid][pVehicle2] = vehicleid;
		PlayerCars[playerid][pVehicle2Model] = model;
		PlayerCars[playerid][pVehicle2X] = x;
		PlayerCars[playerid][pVehicle2Y] = y;
		PlayerCars[playerid][pVehicle2Z] = z;
        PlayerCars[playerid][pVehicle2C] = r;
        PlayerCars[playerid][pVehicle2Color1] = color1;
        PlayerCars[playerid][pVehicle2Color2] = color2;
		return 1;
	}
	if(space== 3)
	{
		PlayerCars[playerid][pVehicle3] = vehicleid;
		PlayerCars[playerid][pVehicle3Model] = model;
		PlayerCars[playerid][pVehicle3X] = x;
		PlayerCars[playerid][pVehicle3Y] = y;
		PlayerCars[playerid][pVehicle3Z] = z;
        PlayerCars[playerid][pVehicle3C] = r;
        PlayerCars[playerid][pVehicle3Color1] = color1;
        PlayerCars[playerid][pVehicle3Color2] = color2;
		return 1;
	}
	SaveAccountStats(playerid);
	return 1;
}
I don't know why is that, but I need to solve it because I have the same issue in skin, money loading, but with other values like password or age I don't have any problems. +REP to who solve this problem, I will thank him/her during all the life.
Reply
#2

Where do you call the LoadUser_data function?
Reply
#3

Quote:
Originally Posted by Aly
Посмотреть сообщение
Where do you call the LoadUser_data function?
Here, OnPlayerConnect
Код:
if(fexist(UserPath(playerid)))
{
        new string[128];
        format(string, sizeof(string), "{FFFFFF}Welcome {00CF00}%s{FFFFFF}. \nEnter your password below:",RPName(playerid));
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Server - Login",string,"Login","Exit");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Server - Register","Enter a new password to create a new account:","Register","Exit");
    }
Reply
#4

Ok, so look at this code:
Код:
function SaveAccountStats(playerid)
{
	new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    
   	PlayerInfo[playerid][Skin] = GetPlayerSkin(playerid);
    PlayerInfo[playerid][Cartera] = GetPlayerMoney(playerid);
   	new
	   	Float:x,
	    Float:y,
		Float:z
	;
	GetPlayerPos(playerid,x,y,z);
	PlayerInfo[playerid][pPos_x] = x;
	PlayerInfo[playerid][pPos_y] = y;
	PlayerInfo[playerid][pPos_z] = z;

    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Faccion",PlayerInfo[playerid][Faccion]);
    INI_WriteInt(File,"Rango",PlayerInfo[playerid][Rango]);
    INI_WriteInt(File,"Payday",PlayerInfo[playerid][Payday]);
    INI_WriteInt(File,"Respeto",PlayerInfo[playerid][Respeto]);
    INI_WriteInt(File,"Nivel",PlayerInfo[playerid][Nivel]);
    INI_WriteFloat(File,"Pos_x",PlayerInfo[playerid][pPos_x]);
    INI_WriteFloat(File,"Pos_y",PlayerInfo[playerid][pPos_y]);
    INI_WriteFloat(File,"Pos_z",PlayerInfo[playerid][pPos_z]);
    INI_WriteInt(File,"Accent",PlayerInfo[playerid][pAccent]);
    INI_WriteInt(File,"Sexo",PlayerInfo[playerid][Sexo]);
    INI_WriteInt(File,"Edad",PlayerInfo[playerid][Edad]);
    INI_WriteInt(File,"Skin",PlayerInfo[playerid][Skin]);
    INI_WriteInt(File,"Cartera",PlayerInfo[playerid][Cartera]);
    
    INI_Close(File);
    
    new INI:Archivo = INI_Open(UserCars(playerid));
    INI_SetTag(Archivo,"Vehicles");
    
    INI_WriteInt(Archivo,"Vehicle1",PlayerCars[playerid][pVehicle1]);
	INI_WriteInt(Archivo,"Vehicle1Model",PlayerCars[playerid][pVehicle1Model]);
	INI_WriteFloat(Archivo,"Vehicle1X",PlayerCars[playerid][pVehicle1X]);
	INI_WriteFloat(Archivo,"Vehicle1Y",PlayerCars[playerid][pVehicle1Y]);
	INI_WriteFloat(Archivo,"Vehicle1Z",PlayerCars[playerid][pVehicle1Z]);
	INI_WriteFloat(Archivo,"Vehicle1C",PlayerCars[playerid][pVehicle1C]);
	INI_WriteInt(Archivo,"Vehicle1Color1",PlayerCars[playerid][pVehicle1Color1]);
	INI_WriteInt(Archivo,"Vehicle1Color2",PlayerCars[playerid][pVehicle1Color2]);
	INI_WriteInt(Archivo,"Vehicle1Value",PlayerCars[playerid][pVehicle1Value]);
	INI_WriteString(Archivo,"Vehicle1Plate",PlayerCars[playerid][pVehicle1Plate]);
	INI_WriteInt(Archivo,"Vehicle1Lock",PlayerCars[playerid][pVehicle1Lock]);
	INI_WriteInt(Archivo,"Vehicle2",PlayerCars[playerid][pVehicle2]);
	INI_WriteInt(Archivo,"Vehicle2Model",PlayerCars[playerid][pVehicle2Model]);
	INI_WriteFloat(Archivo,"Vehicle2X",PlayerCars[playerid][pVehicle2X]);
	INI_WriteFloat(Archivo,"Vehicle2Y",PlayerCars[playerid][pVehicle2Y]);
	INI_WriteFloat(Archivo,"Vehicle2Z",PlayerCars[playerid][pVehicle2Z]);
	INI_WriteFloat(Archivo,"Vehicle2C",PlayerCars[playerid][pVehicle2C]);
	INI_WriteInt(Archivo,"Vehicle2Color1",PlayerCars[playerid][pVehicle2Color1]);
	INI_WriteInt(Archivo,"Vehicle2Color2",PlayerCars[playerid][pVehicle2Color2]);
	INI_WriteInt(Archivo,"Vehicle2Value",PlayerCars[playerid][pVehicle2Value]);
	INI_WriteString(Archivo,"Vehicle2Plate",PlayerCars[playerid][pVehicle2Plate]);
	INI_WriteInt(Archivo,"Vehicle2Lock",PlayerCars[playerid][pVehicle2Lock]);
	INI_WriteInt(Archivo,"Vehicle3",PlayerCars[playerid][pVehicle3]);
	INI_WriteInt(Archivo,"Vehicle3Model",PlayerCars[playerid][pVehicle3Model]);
	INI_WriteFloat(Archivo,"Vehicle3X",PlayerCars[playerid][pVehicle3X]);
	INI_WriteFloat(Archivo,"Vehicle3Y",PlayerCars[playerid][pVehicle3Y]);
	INI_WriteFloat(Archivo,"Vehicle3Z",PlayerCars[playerid][pVehicle3Z]);
	INI_WriteFloat(Archivo,"Vehicle3C",PlayerCars[playerid][pVehicle3C]);
	INI_WriteInt(Archivo,"Vehicle3Color1",PlayerCars[playerid][pVehicle3Color1]);
	INI_WriteInt(Archivo,"Vehicle3Color2",PlayerCars[playerid][pVehicle3Color2]);
	INI_WriteInt(Archivo,"Vehicle3Value",PlayerCars[playerid][pVehicle3Value]);
	INI_WriteString(Archivo,"Vehicle3Plate",PlayerCars[playerid][pVehicle3Plate]);
	INI_WriteInt(Archivo,"Vehicle3Lock",PlayerCars[playerid][pVehicle3Lock]);
	
	INI_Close(Archivo);
    return 1;
}
You're saving the informations Admin, ..., Cartera into the file generated by the function:
Код:
UserPath(playerid)
You're saving the informations about vehicles into a file generated by the function:
Код:
UserCars(playerid)
Now, the problem is when you're loading the information as you said. You're calling the function
Код:
public LoadUser_data(playerid,name[],value[])
using
Код:
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
Your LoadUser_data function tries to get information about vehicle, but you saved the information about vehicles inside the file
Код:
UserCars(playerid)
with the Tag "Vehicles"

Have I lost you?

Now to correct this you should add
Код:
if(fexist(UserPath(playerid)))
{
        new string[128];
        format(string, sizeof(string), "{FFFFFF}Welcome {00CF00}%s{FFFFFF}. \nEnter your password below:",RPName(playerid));
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
		INI_ParseFile(UserCars(playerid), "LoadCars_%s", .bExtra = true, .extra = playerid); //I added this
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Server - Login",string,"Login","Exit");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Server - Register","Enter a new password to create a new account:","Register","Exit");
    }
}
And create two separate functions:
Код:
forward LoadUser_data(playerid,name[],value[]);

public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Faccion",PlayerInfo[playerid][Faccion]);
    INI_Int("Rango",PlayerInfo[playerid][Rango]);
    INI_Int("Payday",PlayerInfo[playerid][Payday]);
    INI_Int("Respeto",PlayerInfo[playerid][Respeto]);
    INI_Int("Nivel",PlayerInfo[playerid][Nivel]);
    INI_Float("Pos_x",PlayerInfo[playerid][pPos_x]);
    INI_Float("Pos_y",PlayerInfo[playerid][pPos_y]);
    INI_Float("Pos_z",PlayerInfo[playerid][pPos_z]);
    INI_Int("Accent",PlayerInfo[playerid][pAccent]);
    INI_Int("Sexo",PlayerInfo[playerid][Sexo]);
    INI_Int("Edad",PlayerInfo[playerid][Edad]);
    INI_Int("Skin",PlayerInfo[playerid][Skin]);
    INI_Int("Cartera",PlayerInfo[playerid][Cartera]);
	
    return 1;
}

forward LoadCars_Vehicles(playerid, name[], value[]);
public LoadCars_Vehicles(playerid, name[], value[])
{
	INI_Int("Vehicle1",PlayerCars[playerid][pVehicle1]);
	INI_Int("Vehicle1Model",PlayerCars[playerid][pVehicle1Model]);
	INI_Float("Vehicle1X",PlayerCars[playerid][pVehicle1X]);
	INI_Float("Vehicle1Y",PlayerCars[playerid][pVehicle1Y]);
	INI_Float("Vehicle1Z",PlayerCars[playerid][pVehicle1Z]);
	INI_Float("Vehicle1C",PlayerCars[playerid][pVehicle1C]);
	INI_Int("Vehicle1Color1",PlayerCars[playerid][pVehicle1Color1]);
	INI_Int("Vehicle1Color2",PlayerCars[playerid][pVehicle1Color2]);
	INI_Int("Vehicle1Value",PlayerCars[playerid][pVehicle1Value]);
	INI_ParseFile("Vehicle1Plate",PlayerCars[playerid][pVehicle1Plate]);
	INI_Int("Vehicle1Lock",PlayerCars[playerid][pVehicle1Lock]);
	INI_Int("Vehicle2",PlayerCars[playerid][pVehicle2]);
	INI_Int("Vehicle2Model",PlayerCars[playerid][pVehicle2Model]);
	INI_Float("Vehicle2X",PlayerCars[playerid][pVehicle2X]);
	INI_Float("Vehicle2Y",PlayerCars[playerid][pVehicle2Y]);
	INI_Float("Vehicle2Z",PlayerCars[playerid][pVehicle2Z]);
	INI_Float("Vehicle2C",PlayerCars[playerid][pVehicle2C]);
	INI_Int("Vehicle2Color1",PlayerCars[playerid][pVehicle2Color1]);
	INI_Int("Vehicle2Color2",PlayerCars[playerid][pVehicle2Color2]);
	INI_Int("Vehicle2Value",PlayerCars[playerid][pVehicle2Value]);
	INI_ParseFile("Vehicle2Plate",PlayerCars[playerid][pVehicle2Plate]);
	INI_Int("Vehicle2Lock",PlayerCars[playerid][pVehicle2Lock]);
	INI_Int("Vehicle3",PlayerCars[playerid][pVehicle3]);
	INI_Int("Vehicle3Model",PlayerCars[playerid][pVehicle3Model]);
	INI_Float("Vehicle3X",PlayerCars[playerid][pVehicle3X]);
	INI_Float("Vehicle3Y",PlayerCars[playerid][pVehicle3Y]);
	INI_Float("Vehicle3Z",PlayerCars[playerid][pVehicle3Z]);
	INI_Float("Vehicle3C",PlayerCars[playerid][pVehicle3C]);
	INI_Int("Vehicle3Color1",PlayerCars[playerid][pVehicle3Color1]);
	INI_Int("Vehicle3Color2",PlayerCars[playerid][pVehicle3Color2]);
	INI_Int("Vehicle3Value",PlayerCars[playerid][pVehicle3Value]);
	INI_ParseFile("Vehicle3Plate",PlayerCars[playerid][pVehicle3Plate]);
	INI_Int("Vehicle3Lock",PlayerCars[playerid][pVehicle3Lock]);
	return 1;
}
Reply
#5

Quote:
Originally Posted by Antenastyle
Посмотреть сообщение
The enum:
Код:
enum CarInfo
{
    pVehicle1,
// ...
	pVehicle2,
// ...
	pVehicle3,
// ...
}
new PlayerCars[MAX_PLAYERS][CarInfo];
Ok, now imagine that you need to support 20 vehicles. Or 100 vehicles. Are you going to add 1200 new specifiers? Are you going to copy all your INI_Writes 100 times? Is that maintainable? Think ahead before diving in head first.

Create a 3D array instead. You will only have to change one number and you can use loops.

PHP код:
enum CarInfo 
{
    
pVehicle,
    
pVehicleModel,
    
Float:pVehicleX,
    
Float:pVehicleY,
    
Float:pVehicleZ,
    
Float:pVehicleC,
    
pVehicleColor1,
    
pVehicleColor2,
    
pVehicleValue,
    
pVehiclePlate,
    
pVehicleLock
}
new 
PlayerCars[MAX_PLAYERS][3][CarInfo]; 
Sorry for the rant. I'm allergic to non-DRY code.
Reply
#6

Quote:
Originally Posted by Aly
Посмотреть сообщение
Ok, so look at this code:
Код:
function SaveAccountStats(playerid)
{
	new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    
   	PlayerInfo[playerid][Skin] = GetPlayerSkin(playerid);
    PlayerInfo[playerid][Cartera] = GetPlayerMoney(playerid);
   	new
	   	Float:x,
	    Float:y,
		Float:z
	;
	GetPlayerPos(playerid,x,y,z);
	PlayerInfo[playerid][pPos_x] = x;
	PlayerInfo[playerid][pPos_y] = y;
	PlayerInfo[playerid][pPos_z] = z;

    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Faccion",PlayerInfo[playerid][Faccion]);
    INI_WriteInt(File,"Rango",PlayerInfo[playerid][Rango]);
    INI_WriteInt(File,"Payday",PlayerInfo[playerid][Payday]);
    INI_WriteInt(File,"Respeto",PlayerInfo[playerid][Respeto]);
    INI_WriteInt(File,"Nivel",PlayerInfo[playerid][Nivel]);
    INI_WriteFloat(File,"Pos_x",PlayerInfo[playerid][pPos_x]);
    INI_WriteFloat(File,"Pos_y",PlayerInfo[playerid][pPos_y]);
    INI_WriteFloat(File,"Pos_z",PlayerInfo[playerid][pPos_z]);
    INI_WriteInt(File,"Accent",PlayerInfo[playerid][pAccent]);
    INI_WriteInt(File,"Sexo",PlayerInfo[playerid][Sexo]);
    INI_WriteInt(File,"Edad",PlayerInfo[playerid][Edad]);
    INI_WriteInt(File,"Skin",PlayerInfo[playerid][Skin]);
    INI_WriteInt(File,"Cartera",PlayerInfo[playerid][Cartera]);
    
    INI_Close(File);
    
    new INI:Archivo = INI_Open(UserCars(playerid));
    INI_SetTag(Archivo,"Vehicles");
    
    INI_WriteInt(Archivo,"Vehicle1",PlayerCars[playerid][pVehicle1]);
	INI_WriteInt(Archivo,"Vehicle1Model",PlayerCars[playerid][pVehicle1Model]);
	INI_WriteFloat(Archivo,"Vehicle1X",PlayerCars[playerid][pVehicle1X]);
	INI_WriteFloat(Archivo,"Vehicle1Y",PlayerCars[playerid][pVehicle1Y]);
	INI_WriteFloat(Archivo,"Vehicle1Z",PlayerCars[playerid][pVehicle1Z]);
	INI_WriteFloat(Archivo,"Vehicle1C",PlayerCars[playerid][pVehicle1C]);
	INI_WriteInt(Archivo,"Vehicle1Color1",PlayerCars[playerid][pVehicle1Color1]);
	INI_WriteInt(Archivo,"Vehicle1Color2",PlayerCars[playerid][pVehicle1Color2]);
	INI_WriteInt(Archivo,"Vehicle1Value",PlayerCars[playerid][pVehicle1Value]);
	INI_WriteString(Archivo,"Vehicle1Plate",PlayerCars[playerid][pVehicle1Plate]);
	INI_WriteInt(Archivo,"Vehicle1Lock",PlayerCars[playerid][pVehicle1Lock]);
	INI_WriteInt(Archivo,"Vehicle2",PlayerCars[playerid][pVehicle2]);
	INI_WriteInt(Archivo,"Vehicle2Model",PlayerCars[playerid][pVehicle2Model]);
	INI_WriteFloat(Archivo,"Vehicle2X",PlayerCars[playerid][pVehicle2X]);
	INI_WriteFloat(Archivo,"Vehicle2Y",PlayerCars[playerid][pVehicle2Y]);
	INI_WriteFloat(Archivo,"Vehicle2Z",PlayerCars[playerid][pVehicle2Z]);
	INI_WriteFloat(Archivo,"Vehicle2C",PlayerCars[playerid][pVehicle2C]);
	INI_WriteInt(Archivo,"Vehicle2Color1",PlayerCars[playerid][pVehicle2Color1]);
	INI_WriteInt(Archivo,"Vehicle2Color2",PlayerCars[playerid][pVehicle2Color2]);
	INI_WriteInt(Archivo,"Vehicle2Value",PlayerCars[playerid][pVehicle2Value]);
	INI_WriteString(Archivo,"Vehicle2Plate",PlayerCars[playerid][pVehicle2Plate]);
	INI_WriteInt(Archivo,"Vehicle2Lock",PlayerCars[playerid][pVehicle2Lock]);
	INI_WriteInt(Archivo,"Vehicle3",PlayerCars[playerid][pVehicle3]);
	INI_WriteInt(Archivo,"Vehicle3Model",PlayerCars[playerid][pVehicle3Model]);
	INI_WriteFloat(Archivo,"Vehicle3X",PlayerCars[playerid][pVehicle3X]);
	INI_WriteFloat(Archivo,"Vehicle3Y",PlayerCars[playerid][pVehicle3Y]);
	INI_WriteFloat(Archivo,"Vehicle3Z",PlayerCars[playerid][pVehicle3Z]);
	INI_WriteFloat(Archivo,"Vehicle3C",PlayerCars[playerid][pVehicle3C]);
	INI_WriteInt(Archivo,"Vehicle3Color1",PlayerCars[playerid][pVehicle3Color1]);
	INI_WriteInt(Archivo,"Vehicle3Color2",PlayerCars[playerid][pVehicle3Color2]);
	INI_WriteInt(Archivo,"Vehicle3Value",PlayerCars[playerid][pVehicle3Value]);
	INI_WriteString(Archivo,"Vehicle3Plate",PlayerCars[playerid][pVehicle3Plate]);
	INI_WriteInt(Archivo,"Vehicle3Lock",PlayerCars[playerid][pVehicle3Lock]);
	
	INI_Close(Archivo);
    return 1;
}
You're saving the informations Admin, ..., Cartera into the file generated by the function:
Код:
UserPath(playerid)
You're saving the informations about vehicles into a file generated by the function:
Код:
UserCars(playerid)
Now, the problem is when you're loading the information as you said. You're calling the function
Код:
public LoadUser_data(playerid,name[],value[])
using
Код:
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
Your LoadUser_data function tries to get information about vehicle, but you saved the information about vehicles inside the file
Код:
UserCars(playerid)
with the Tag "Vehicles"

Have I lost you?

Now to correct this you should add
Код:
if(fexist(UserPath(playerid)))
{
        new string[128];
        format(string, sizeof(string), "{FFFFFF}Welcome {00CF00}%s{FFFFFF}. \nEnter your password below:",RPName(playerid));
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
		INI_ParseFile(UserCars(playerid), "LoadCars_%s", .bExtra = true, .extra = playerid); //I added this
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Server - Login",string,"Login","Exit");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Server - Register","Enter a new password to create a new account:","Register","Exit");
    }
}
And create two separate functions:
Код:
forward LoadUser_data(playerid,name[],value[]);

public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Faccion",PlayerInfo[playerid][Faccion]);
    INI_Int("Rango",PlayerInfo[playerid][Rango]);
    INI_Int("Payday",PlayerInfo[playerid][Payday]);
    INI_Int("Respeto",PlayerInfo[playerid][Respeto]);
    INI_Int("Nivel",PlayerInfo[playerid][Nivel]);
    INI_Float("Pos_x",PlayerInfo[playerid][pPos_x]);
    INI_Float("Pos_y",PlayerInfo[playerid][pPos_y]);
    INI_Float("Pos_z",PlayerInfo[playerid][pPos_z]);
    INI_Int("Accent",PlayerInfo[playerid][pAccent]);
    INI_Int("Sexo",PlayerInfo[playerid][Sexo]);
    INI_Int("Edad",PlayerInfo[playerid][Edad]);
    INI_Int("Skin",PlayerInfo[playerid][Skin]);
    INI_Int("Cartera",PlayerInfo[playerid][Cartera]);
	
    return 1;
}

forward LoadCars_Vehicles(playerid, name[], value[]);
public LoadCars_Vehicles(playerid, name[], value[])
{
	INI_Int("Vehicle1",PlayerCars[playerid][pVehicle1]);
	INI_Int("Vehicle1Model",PlayerCars[playerid][pVehicle1Model]);
	INI_Float("Vehicle1X",PlayerCars[playerid][pVehicle1X]);
	INI_Float("Vehicle1Y",PlayerCars[playerid][pVehicle1Y]);
	INI_Float("Vehicle1Z",PlayerCars[playerid][pVehicle1Z]);
	INI_Float("Vehicle1C",PlayerCars[playerid][pVehicle1C]);
	INI_Int("Vehicle1Color1",PlayerCars[playerid][pVehicle1Color1]);
	INI_Int("Vehicle1Color2",PlayerCars[playerid][pVehicle1Color2]);
	INI_Int("Vehicle1Value",PlayerCars[playerid][pVehicle1Value]);
	INI_ParseFile("Vehicle1Plate",PlayerCars[playerid][pVehicle1Plate]);
	INI_Int("Vehicle1Lock",PlayerCars[playerid][pVehicle1Lock]);
	INI_Int("Vehicle2",PlayerCars[playerid][pVehicle2]);
	INI_Int("Vehicle2Model",PlayerCars[playerid][pVehicle2Model]);
	INI_Float("Vehicle2X",PlayerCars[playerid][pVehicle2X]);
	INI_Float("Vehicle2Y",PlayerCars[playerid][pVehicle2Y]);
	INI_Float("Vehicle2Z",PlayerCars[playerid][pVehicle2Z]);
	INI_Float("Vehicle2C",PlayerCars[playerid][pVehicle2C]);
	INI_Int("Vehicle2Color1",PlayerCars[playerid][pVehicle2Color1]);
	INI_Int("Vehicle2Color2",PlayerCars[playerid][pVehicle2Color2]);
	INI_Int("Vehicle2Value",PlayerCars[playerid][pVehicle2Value]);
	INI_ParseFile("Vehicle2Plate",PlayerCars[playerid][pVehicle2Plate]);
	INI_Int("Vehicle2Lock",PlayerCars[playerid][pVehicle2Lock]);
	INI_Int("Vehicle3",PlayerCars[playerid][pVehicle3]);
	INI_Int("Vehicle3Model",PlayerCars[playerid][pVehicle3Model]);
	INI_Float("Vehicle3X",PlayerCars[playerid][pVehicle3X]);
	INI_Float("Vehicle3Y",PlayerCars[playerid][pVehicle3Y]);
	INI_Float("Vehicle3Z",PlayerCars[playerid][pVehicle3Z]);
	INI_Float("Vehicle3C",PlayerCars[playerid][pVehicle3C]);
	INI_Int("Vehicle3Color1",PlayerCars[playerid][pVehicle3Color1]);
	INI_Int("Vehicle3Color2",PlayerCars[playerid][pVehicle3Color2]);
	INI_Int("Vehicle3Value",PlayerCars[playerid][pVehicle3Value]);
	INI_ParseFile("Vehicle3Plate",PlayerCars[playerid][pVehicle3Plate]);
	INI_Int("Vehicle3Lock",PlayerCars[playerid][pVehicle3Lock]);
	return 1;
}
Thanks for the help, but it isn't working, it just creates again all the variables in the same file again and again...
Reply
#7

I tried to rewrite your code a little bit.Here's what I did:

PHP код:
#include <a_samp>
#include <YSI\y_ini>
#define DIALOG_REGISTER 2
#define DIALOG_LOGIN 3
#define DIALOG_SEX 4
#define VEHICLE_PATH "Vehicles/%s.ini"
#define USER_PATH "Players/%s.ini"
#define MAX_PLAYER_VEHICLES 3
enum CarInfo
{
    
pVehicle,
    
pVehicleModel,
    
Float:pVehicleX,
    
Float:pVehicleY,
    
Float:pVehicleZ,
    
Float:pVehicleC,
    
pVehicleColor1,
    
pVehicleColor2,
    
pVehicleValue,
    
pVehiclePlate[32],
    
pVehicleLock
}
new 
PlayerCars[MAX_PLAYERS][MAX_PLAYER_VEHICLES][CarInfo];
enum pInfo
{
    
pPass,
    
pAdmin,
    
Faccion,
    
Rango,
    
Payday,
    
Respeto,
    
Nivel,
    
pAccent,
    
Sexo,
    
Edad,
    
Skin,
    
Cartera,
    
Float:pPos_x,
    
Float:pPos_y,
    
Float:pPos_z
};
new 
PlayerInfo[MAX_PLAYERS][pInfo];
public 
OnPlayerConnect(playerid)
{
    if(
fexist(UserPath(playerid)))
    {
        new 
string[128];
        
format(stringsizeof(string), "{FFFFFF}Welcome {00CF00}%s{FFFFFF}. \nEnter your password below:"RPName(playerid));
        
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
        
INI_ParseFile(UserCars(playerid), "LoadCars_%s", .bExtra true, .extra playerid);
        
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_PASSWORD"Server - Login"string"Login""Exit");
    }
    else
        
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT"Server - Register","Enter a new password to create a new account:""Register""Exit");
    return 
1;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        case 
DIALOG_REGISTER:
        {
            if(!
response)
                return 
Kick(playerid);
            else
            {
                if(!
strlen(inputtext))
                    return 
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT"Registering...","You've entered an invalid password.\nEnter a new password to create a new account.","Register","Exit");
                
PlayerInfo[playerid][pPass] = udb_hash(inputtext);
                
/*
                Code to init your variables like:
                PlayerInfo[playerid][Admin] = 0;
                Just if it's needed
                */
                
SaveAccountStats(playerid); //Saves the stats from pInfo enum
                
SaveAccountCars(playerid); //Saves the account's cars stats from CarInfo enum
                
ShowPlayerDialog(playeridDIALOG_SEXDIALOG_STYLE_MSGBOX"- Sex -","Put your gender","Male","Female");
            }
        }
    }
    return 
1;
}
//Save Functions
stock SaveAccountStats(playerid)
{
    new 
INI:File INI_Open(UserPath(playerid));
    
INI_SetTag(File"data");
    
    
GetPlayerPos(playeridPlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z]);
    
PlayerInfo[playerid][Cartera] = GetPlayerMoney(playerid);
    
PlayerInfo[playerid][Skin] = GetPlayerSkin(playerid);
    
    
INI_WriteInt(File,"Password"udb_hash(PlayerInfo[playerid][pPass]));
    
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    
INI_WriteInt(File,"Faccion",PlayerInfo[playerid][Faccion]);
    
INI_WriteInt(File,"Rango",PlayerInfo[playerid][Rango]);
    
INI_WriteInt(File,"Payday",PlayerInfo[playerid][Payday]);
    
INI_WriteInt(File,"Respeto",PlayerInfo[playerid][Respeto]);
    
INI_WriteInt(File,"Nivel",PlayerInfo[playerid][Nivel]);
    
INI_WriteFloat(File,"Pos_x",PlayerInfo[playerid][pPos_x]);
    
INI_WriteFloat(File,"Pos_y",PlayerInfo[playerid][pPos_y]);
    
INI_WriteFloat(File,"Pos_z",PlayerInfo[playerid][pPos_z]);
    
INI_WriteInt(File,"Accent",PlayerInfo[playerid][pAccent]);
    
INI_WriteInt(File,"Sexo",PlayerInfo[playerid][Sexo]);
    
INI_WriteInt(File,"Edad",PlayerInfo[playerid][Edad]);
    
INI_WriteInt(File,"Skin",PlayerInfo[playerid][Skin]);
    
INI_WriteInt(File,"Cartera",PlayerInfo[playerid][Cartera]);
    
    
INI_Close(File);
}
stock SaveAccountCars(playerid)
{
    new 
INI:File INI_Open(UserCars(playerid));
    
INI_SetTag(File"Vehicles");
    
    new 
field[48];
    for(new 
0MAX_PLAYER_VEHICLESi++)
    {
        
format(fieldsizeof(field), "Vehicle[%d]"i);
        
INI_WriteInt(FilefieldPlayerCars[playerid][i][pVehicle]);
        
format(fieldsizeof(field), "VehicleModel[%d]"i);
        
INI_WriteInt(FilefieldPlayerCars[playerid][i][pVehicleModel]);
        
        
format(fieldsizeof(field), "VehicleX[%d]"i);
        
INI_WriteFloat(FilefieldPlayerCars[playerid][i][pVehicleX]);
        
format(fieldsizeof(field), "VehicleY[%d]"i);
        
INI_WriteFloat(FilefieldPlayerCars[playerid][i][pVehicleY]);
        
format(fieldsizeof(field), "VehicleZ[%d]"i);
        
INI_WriteFloat(FilefieldPlayerCars[playerid][i][pVehicleZ]);
        
format(fieldsizeof(field), "VehicleC[%d]"i);
        
INI_WriteFloat(FilefieldPlayerCars[playerid][i][pVehicleC]);
        
        
format(fieldsizeof(field), "VehicleColor1[%d]"i);
        
INI_WriteInt(FilefieldPlayerCars[playerid][i][pVehicleColor1]);
        
format(fieldsizeof(field), "VehicleColor2[%d]"i);
        
INI_WriteInt(FilefieldPlayerCars[playerid][i][pVehicleColor2]);
        
format(fieldsizeof(field), "VehicleValue[%d]"i);
        
INI_WriteInt(FilefieldPlayerCars[playerid][i][pVehicleValue]);
        
format(fieldsizeof(field), "VehicleLock[%d]"i);
        
INI_WriteInt(FilefieldPlayerCars[playerid][i][pVehicleLock]);
        
format(fieldsizeof(field), "VehiclePlate[%d]"i);
        
INI_WriteString(FilefieldPlayerCars[playerid][i][pVehiclePlate]);
    }
    
INI_Close(File);
}
//Load functions
forward LoadUser_data(playerid,name[],value[]);
public 
LoadUser_data(playerid,name[],value[])
{
    
INI_Int("Password",PlayerInfo[playerid][pPass]);
    
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    
INI_Int("Faccion",PlayerInfo[playerid][Faccion]);
    
INI_Int("Rango",PlayerInfo[playerid][Rango]);
    
INI_Int("Payday",PlayerInfo[playerid][Payday]);
    
INI_Int("Respeto",PlayerInfo[playerid][Respeto]);
    
INI_Int("Nivel",PlayerInfo[playerid][Nivel]);
    
INI_Float("Pos_x",PlayerInfo[playerid][pPos_x]);
    
INI_Float("Pos_y",PlayerInfo[playerid][pPos_y]);
    
INI_Float("Pos_z",PlayerInfo[playerid][pPos_z]);
    
INI_Int("Accent",PlayerInfo[playerid][pAccent]);
    
INI_Int("Sexo",PlayerInfo[playerid][Sexo]);
    
INI_Int("Edad",PlayerInfo[playerid][Edad]);
    
INI_Int("Skin",PlayerInfo[playerid][Skin]);
    
INI_Int("Cartera",PlayerInfo[playerid][Cartera]);
    
    return 
1;
}
forward LoadCars_Vehicles(playerid,name[],value[]);
public 
LoadCars_Vehicles(playerid,name[],value[])
{
    new 
field[48];
    for(new 
0MAX_PLAYER_VEHICLESi++)
    {
        
format(fieldsizeof(field), "Vehicle[%d]"i);
        
INI_Int(fieldPlayerCars[playerid][i][pVehicle]);
        
format(fieldsizeof(field), "VehicleModel[%d]"i);
        
INI_Int(fieldPlayerCars[playerid][i][pVehicleModel]);
        
        
format(fieldsizeof(field), "VehicleX[%d]"i);
        
INI_Float(fieldPlayerCars[playerid][i][pVehicleX]);
        
format(fieldsizeof(field), "VehicleY[%d]"i);
        
INI_Float(fieldPlayerCars[playerid][i][pVehicleY]);
        
format(fieldsizeof(field), "VehicleZ[%d]"i);
        
INI_Float(fieldPlayerCars[playerid][i][pVehicleZ]);
        
format(fieldsizeof(field), "VehicleC[%d]"i);
        
INI_Float(fieldPlayerCars[playerid][i][pVehicleC]);
        
        
format(fieldsizeof(field), "VehicleColor1[%d]"i);
        
INI_Int(fieldPlayerCars[playerid][i][pVehicleColor1]);
        
format(fieldsizeof(field), "VehicleColor2[%d]"i);
        
INI_Int(fieldPlayerCars[playerid][i][pVehicleColor2]);
        
format(fieldsizeof(field), "VehicleValue[%d]"i);
        
INI_Int(fieldPlayerCars[playerid][i][pVehicleValue]);
        
format(fieldsizeof(field), "VehicleLock[%d]"i);
        
INI_Int(fieldPlayerCars[playerid][i][pVehicleLock]);
        
format(fieldsizeof(field), "VehiclePlate[%d]"i);
        
INI_String(fieldPlayerCars[playerid][i][pVehiclePlate], 32); //32 is the size of pVehiclePlate in enum
    
}
    
    return 
1;
}
//Path stocks
stock UserCars(playerid)
{
    new 
string[128], playername[MAX_PLAYER_NAME];
    
GetPlayerName(playeridplayernamesizeof(playername));
    
format(stringsizeof(string), VEHICLE_PATHplayername);
    return 
string;
}
stock UserPath(playerid)
{
    new 
string[64], playerName[MAX_PLAYER_NAME];
    
GetPlayerName(playeridplayerNamesizeof(playerName));
    
format(stringsizeof(string), USER_PATHplayerName);
    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;
}
stock RPName(playerid)
{
    new 
playerName[MAX_PLAYER_NAME];
    
GetPlayerName(playeridplayerNamesizeof(playerName));
    return 
playerName;

Also, in your code you were using INI_ParseFile to read a string from the file
Код:
INI_ParseFile("Vehicle2Plate",PlayerCars[playerid][pVehicle2Plate]);
That should be
Код:
INI_String("Vehicle2Plate", PlayerCars[playerid][pVehicle2Plate], 32); //Replace 32 with the size of pVehicle2Plate
Reply
#8

Quote:
Originally Posted by Aly
Посмотреть сообщение
I tried to rewrite your code a little bit.Here's what I did:

PHP код:
#include <a_samp>
#include <YSI\y_ini>
#define DIALOG_REGISTER 2
#define DIALOG_LOGIN 3
#define DIALOG_SEX 4
#define VEHICLE_PATH "Vehicles/%s.ini"
#define USER_PATH "Players/%s.ini"
#define MAX_PLAYER_VEHICLES 3
enum CarInfo
{
    
pVehicle,
    
pVehicleModel,
    
Float:pVehicleX,
    
Float:pVehicleY,
    
Float:pVehicleZ,
    
Float:pVehicleC,
    
pVehicleColor1,
    
pVehicleColor2,
    
pVehicleValue,
    
pVehiclePlate[32],
    
pVehicleLock
}
new 
PlayerCars[MAX_PLAYERS][MAX_PLAYER_VEHICLES][CarInfo];
enum pInfo
{
    
pPass,
    
pAdmin,
    
Faccion,
    
Rango,
    
Payday,
    
Respeto,
    
Nivel,
    
pAccent,
    
Sexo,
    
Edad,
    
Skin,
    
Cartera,
    
Float:pPos_x,
    
Float:pPos_y,
    
Float:pPos_z
};
new 
PlayerInfo[MAX_PLAYERS][pInfo];
public 
OnPlayerConnect(playerid)
{
    if(
fexist(UserPath(playerid)))
    {
        new 
string[128];
        
format(stringsizeof(string), "{FFFFFF}Welcome {00CF00}%s{FFFFFF}. \nEnter your password below:"RPName(playerid));
        
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
        
INI_ParseFile(UserCars(playerid), "LoadCars_%s", .bExtra true, .extra playerid);
        
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_PASSWORD"Server - Login"string"Login""Exit");
    }
    else
        
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT"Server - Register","Enter a new password to create a new account:""Register""Exit");
    return 
1;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        case 
DIALOG_REGISTER:
        {
            if(!
response)
                return 
Kick(playerid);
            else
            {
                if(!
strlen(inputtext))
                    return 
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT"Registering...","You've entered an invalid password.\nEnter a new password to create a new account.","Register","Exit");
                
PlayerInfo[playerid][pPass] = udb_hash(inputtext);
                
/*
                Code to init your variables like:
                PlayerInfo[playerid][Admin] = 0;
                Just if it's needed
                */
                
SaveAccountStats(playerid); //Saves the stats from pInfo enum
                
SaveAccountCars(playerid); //Saves the account's cars stats from CarInfo enum
                
ShowPlayerDialog(playeridDIALOG_SEXDIALOG_STYLE_MSGBOX"- Sex -","Put your gender","Male","Female");
            }
        }
    }
    return 
1;
}
//Save Functions
stock SaveAccountStats(playerid)
{
    new 
INI:File INI_Open(UserPath(playerid));
    
INI_SetTag(File"data");
    
    
GetPlayerPos(playeridPlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z]);
    
PlayerInfo[playerid][Cartera] = GetPlayerMoney(playerid);
    
PlayerInfo[playerid][Skin] = GetPlayerSkin(playerid);
    
    
INI_WriteInt(File,"Password"udb_hash(PlayerInfo[playerid][pPass]));
    
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    
INI_WriteInt(File,"Faccion",PlayerInfo[playerid][Faccion]);
    
INI_WriteInt(File,"Rango",PlayerInfo[playerid][Rango]);
    
INI_WriteInt(File,"Payday",PlayerInfo[playerid][Payday]);
    
INI_WriteInt(File,"Respeto",PlayerInfo[playerid][Respeto]);
    
INI_WriteInt(File,"Nivel",PlayerInfo[playerid][Nivel]);
    
INI_WriteFloat(File,"Pos_x",PlayerInfo[playerid][pPos_x]);
    
INI_WriteFloat(File,"Pos_y",PlayerInfo[playerid][pPos_y]);
    
INI_WriteFloat(File,"Pos_z",PlayerInfo[playerid][pPos_z]);
    
INI_WriteInt(File,"Accent",PlayerInfo[playerid][pAccent]);
    
INI_WriteInt(File,"Sexo",PlayerInfo[playerid][Sexo]);
    
INI_WriteInt(File,"Edad",PlayerInfo[playerid][Edad]);
    
INI_WriteInt(File,"Skin",PlayerInfo[playerid][Skin]);
    
INI_WriteInt(File,"Cartera",PlayerInfo[playerid][Cartera]);
    
    
INI_Close(File);
}
stock SaveAccountCars(playerid)
{
    new 
INI:File INI_Open(UserCars(playerid));
    
INI_SetTag(File"Vehicles");
    
    new 
field[48];
    for(new 
0MAX_PLAYER_VEHICLESi++)
    {
        
format(fieldsizeof(field), "Vehicle[%d]"i);
        
INI_WriteInt(FilefieldPlayerCars[playerid][i][pVehicle]);
        
format(fieldsizeof(field), "VehicleModel[%d]"i);
        
INI_WriteInt(FilefieldPlayerCars[playerid][i][pVehicleModel]);
        
        
format(fieldsizeof(field), "VehicleX[%d]"i);
        
INI_WriteFloat(FilefieldPlayerCars[playerid][i][pVehicleX]);
        
format(fieldsizeof(field), "VehicleY[%d]"i);
        
INI_WriteFloat(FilefieldPlayerCars[playerid][i][pVehicleY]);
        
format(fieldsizeof(field), "VehicleZ[%d]"i);
        
INI_WriteFloat(FilefieldPlayerCars[playerid][i][pVehicleZ]);
        
format(fieldsizeof(field), "VehicleC[%d]"i);
        
INI_WriteFloat(FilefieldPlayerCars[playerid][i][pVehicleC]);
        
        
format(fieldsizeof(field), "VehicleColor1[%d]"i);
        
INI_WriteInt(FilefieldPlayerCars[playerid][i][pVehicleColor1]);
        
format(fieldsizeof(field), "VehicleColor2[%d]"i);
        
INI_WriteInt(FilefieldPlayerCars[playerid][i][pVehicleColor2]);
        
format(fieldsizeof(field), "VehicleValue[%d]"i);
        
INI_WriteInt(FilefieldPlayerCars[playerid][i][pVehicleValue]);
        
format(fieldsizeof(field), "VehicleLock[%d]"i);
        
INI_WriteInt(FilefieldPlayerCars[playerid][i][pVehicleLock]);
        
format(fieldsizeof(field), "VehiclePlate[%d]"i);
        
INI_WriteString(FilefieldPlayerCars[playerid][i][pVehiclePlate]);
    }
    
INI_Close(File);
}
//Load functions
forward LoadUser_data(playerid,name[],value[]);
public 
LoadUser_data(playerid,name[],value[])
{
    
INI_Int("Password",PlayerInfo[playerid][pPass]);
    
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    
INI_Int("Faccion",PlayerInfo[playerid][Faccion]);
    
INI_Int("Rango",PlayerInfo[playerid][Rango]);
    
INI_Int("Payday",PlayerInfo[playerid][Payday]);
    
INI_Int("Respeto",PlayerInfo[playerid][Respeto]);
    
INI_Int("Nivel",PlayerInfo[playerid][Nivel]);
    
INI_Float("Pos_x",PlayerInfo[playerid][pPos_x]);
    
INI_Float("Pos_y",PlayerInfo[playerid][pPos_y]);
    
INI_Float("Pos_z",PlayerInfo[playerid][pPos_z]);
    
INI_Int("Accent",PlayerInfo[playerid][pAccent]);
    
INI_Int("Sexo",PlayerInfo[playerid][Sexo]);
    
INI_Int("Edad",PlayerInfo[playerid][Edad]);
    
INI_Int("Skin",PlayerInfo[playerid][Skin]);
    
INI_Int("Cartera",PlayerInfo[playerid][Cartera]);
    
    return 
1;
}
forward LoadCars_Vehicles(playerid,name[],value[]);
public 
LoadCars_Vehicles(playerid,name[],value[])
{
    new 
field[48];
    for(new 
0MAX_PLAYER_VEHICLESi++)
    {
        
format(fieldsizeof(field), "Vehicle[%d]"i);
        
INI_Int(fieldPlayerCars[playerid][i][pVehicle]);
        
format(fieldsizeof(field), "VehicleModel[%d]"i);
        
INI_Int(fieldPlayerCars[playerid][i][pVehicleModel]);
        
        
format(fieldsizeof(field), "VehicleX[%d]"i);
        
INI_Float(fieldPlayerCars[playerid][i][pVehicleX]);
        
format(fieldsizeof(field), "VehicleY[%d]"i);
        
INI_Float(fieldPlayerCars[playerid][i][pVehicleY]);
        
format(fieldsizeof(field), "VehicleZ[%d]"i);
        
INI_Float(fieldPlayerCars[playerid][i][pVehicleZ]);
        
format(fieldsizeof(field), "VehicleC[%d]"i);
        
INI_Float(fieldPlayerCars[playerid][i][pVehicleC]);
        
        
format(fieldsizeof(field), "VehicleColor1[%d]"i);
        
INI_Int(fieldPlayerCars[playerid][i][pVehicleColor1]);
        
format(fieldsizeof(field), "VehicleColor2[%d]"i);
        
INI_Int(fieldPlayerCars[playerid][i][pVehicleColor2]);
        
format(fieldsizeof(field), "VehicleValue[%d]"i);
        
INI_Int(fieldPlayerCars[playerid][i][pVehicleValue]);
        
format(fieldsizeof(field), "VehicleLock[%d]"i);
        
INI_Int(fieldPlayerCars[playerid][i][pVehicleLock]);
        
format(fieldsizeof(field), "VehiclePlate[%d]"i);
        
INI_String(fieldPlayerCars[playerid][i][pVehiclePlate], 32); //32 is the size of pVehiclePlate in enum
    
}
    
    return 
1;
}
//Path stocks
stock UserCars(playerid)
{
    new 
string[128], playername[MAX_PLAYER_NAME];
    
GetPlayerName(playeridplayernamesizeof(playername));
    
format(stringsizeof(string), VEHICLE_PATHplayername);
    return 
string;
}
stock UserPath(playerid)
{
    new 
string[64], playerName[MAX_PLAYER_NAME];
    
GetPlayerName(playeridplayerNamesizeof(playerName));
    
format(stringsizeof(string), USER_PATHplayerName);
    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;
}
stock RPName(playerid)
{
    new 
playerName[MAX_PLAYER_NAME];
    
GetPlayerName(playeridplayerNamesizeof(playerName));
    return 
playerName;

Also, in your code you were using INI_ParseFile to read a string from the file
Код:
INI_ParseFile("Vehicle2Plate",PlayerCars[playerid][pVehicle2Plate]);
That should be
Код:
INI_String("Vehicle2Plate", PlayerCars[playerid][pVehicle2Plate], 32); //Replace 32 with the size of pVehicle2Plate
WOW! Thank you a lot!! The vehicles are saving and loading right, but the skin and money keeps not loading... But you're awesome man, really really thank you!! There you have your REP
Reply
#9

Now about the money and the skin, you'll have to set them after you confirm that the password is correct.
Something like:
Код:
case DIALOG_LOGIN:
		{
			if(!response)
				return Kick(playerid);
			else
			{
				if(!strlen(inputtext))
					return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Server - Login", "Wrong password\nTry again!", "Login", "Exit");
				if(PlayerInfo[playerid][pPass] == udb_hash(inputtext))
				{
					GivePlayerMoney(playerid, PlayerInfo[playerid][Cartera]);
					SetPlayerSkin(playerid, PlayerInfo[playerid][Skin]);
					//Other part of your code
				}
				else
					return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Server - Login", "Wrong password\nTry again!", "Login", "Exit");
			}
		}
Reply
#10

Quote:
Originally Posted by Aly
Посмотреть сообщение
Now about the money and the skin, you'll have to set them after you confirm that the password is correct.
Something like:
Код:
case DIALOG_LOGIN:
		{
			if(!response)
				return Kick(playerid);
			else
			{
				if(!strlen(inputtext))
					return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Server - Login", "Wrong password\nTry again!", "Login", "Exit");
				if(PlayerInfo[playerid][pPass] == udb_hash(inputtext))
				{
					GivePlayerMoney(playerid, PlayerInfo[playerid][Cartera]);
					SetPlayerSkin(playerid, PlayerInfo[playerid][Skin]);
					//Other part of your code
				}
				else
					return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Server - Login", "Wrong password\nTry again!", "Login", "Exit");
			}
		}
I have them like this:
Код:
case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    new Float:x, Float:y, Float:z, skin;
			 		skin = PlayerInfo[playerid][Skin];
			 		x = PlayerInfo[playerid][pPos_x];
			 		y = PlayerInfo[playerid][pPos_y];
			 		z = PlayerInfo[playerid][pPos_z];

					SetSpawnInfo(playerid, 0, skin, x, y, z, 0, 0, 0, 0, 0, 0, 0);
					StopAudioStreamForPlayer(playerid);
                    PlayerInfo[playerid][logged] = 1;
                    TogglePlayerSpectating(playerid, false);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][Cartera]);

				}
                else
                {
                    return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Server - Login", "Wrong password\nTry again!", "Login", "Exit");
                }
                return 1;
            }
        }
Код:
public OnPlayerSpawn(playerid)
{
    if(PlayerInfo[playerid][logged]==1)
	{
		SetPlayerScore(playerid, PlayerInfo[playerid][Nivel]);
		SetPlayerSkin(playerid, PlayerInfo[playerid][Skin]);
		GivePlayerMoney(playerid, PlayerInfo[playerid][Cartera]);
		StopAudioStreamForPlayer(playerid);
		SetPlayerPos(playerid, 1271.3654,181.0756,19.4705);
		SetCameraBehindPlayer(playerid);
    	PlayerInfo[playerid][logged] = 0;
	}
   	if(IsPlayerConnected(playerid))
	{
    	SetPlayerSkin(playerid, PlayerInfo[playerid][Skin]);
    	SetPlayerToTeamColor(playerid);
    	TogglePlayerSpectating(playerid, 0);
        StopAudioStreamForPlayer(playerid);
     	SetCameraBehindPlayer(playerid);
     	SetTimerEx("payday", 60000, false, "f", playerid);
	}
	if(PlayerInfo[playerid][pPos_x] == 0 && PlayerInfo[playerid][pPos_y] == 0)
    {
        SetPlayerPos(playerid, 1271.3654,181.0756,19.4705);
    }
    else
	{
		SetPlayerPos(playerid, PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z]);
 	}
    return 1;
}
Also, the PJ appears in the air, flying, where the cinematic has ended.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)