19.05.2017, 17:33
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:
Dialog register:
The UserCars stock used:
OnPlayerSpawn:
SaveAccountStats function:
And LoadUserData:
And that's a command I've created to test:
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.
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];
Код:
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"); } }
Код:
#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; }
Код:
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); } }
Код:
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; }
Код:
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; }
Код:
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; }