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; }
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"); }
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; }
UserPath(playerid)
UserCars(playerid)
public LoadUser_data(playerid,name[],value[])
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
UserCars(playerid)
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"); } }
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; }
The enum:
Код:
enum CarInfo { pVehicle1, // ... pVehicle2, // ... pVehicle3, // ... } new PlayerCars[MAX_PLAYERS][CarInfo]; |
enum CarInfo
{
pVehicle,
pVehicleModel,
Float:pVehicleX,
Float:pVehicleY,
Float:pVehicleZ,
Float:pVehicleC,
pVehicleColor1,
pVehicleColor2,
pVehicleValue,
pVehiclePlate,
pVehicleLock
}
new PlayerCars[MAX_PLAYERS][3][CarInfo];
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; } Код:
UserPath(playerid) Код:
UserCars(playerid) Код:
public LoadUser_data(playerid,name[],value[]) Код:
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid); Код:
UserCars(playerid) 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"); } } Код:
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; } |
#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(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);
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");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_REGISTER:
{
if(!response)
return Kick(playerid);
else
{
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");
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(playerid, DIALOG_SEX, DIALOG_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(playerid, PlayerInfo[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 i = 0; i < MAX_PLAYER_VEHICLES; i++)
{
format(field, sizeof(field), "Vehicle[%d]", i);
INI_WriteInt(File, field, PlayerCars[playerid][i][pVehicle]);
format(field, sizeof(field), "VehicleModel[%d]", i);
INI_WriteInt(File, field, PlayerCars[playerid][i][pVehicleModel]);
format(field, sizeof(field), "VehicleX[%d]", i);
INI_WriteFloat(File, field, PlayerCars[playerid][i][pVehicleX]);
format(field, sizeof(field), "VehicleY[%d]", i);
INI_WriteFloat(File, field, PlayerCars[playerid][i][pVehicleY]);
format(field, sizeof(field), "VehicleZ[%d]", i);
INI_WriteFloat(File, field, PlayerCars[playerid][i][pVehicleZ]);
format(field, sizeof(field), "VehicleC[%d]", i);
INI_WriteFloat(File, field, PlayerCars[playerid][i][pVehicleC]);
format(field, sizeof(field), "VehicleColor1[%d]", i);
INI_WriteInt(File, field, PlayerCars[playerid][i][pVehicleColor1]);
format(field, sizeof(field), "VehicleColor2[%d]", i);
INI_WriteInt(File, field, PlayerCars[playerid][i][pVehicleColor2]);
format(field, sizeof(field), "VehicleValue[%d]", i);
INI_WriteInt(File, field, PlayerCars[playerid][i][pVehicleValue]);
format(field, sizeof(field), "VehicleLock[%d]", i);
INI_WriteInt(File, field, PlayerCars[playerid][i][pVehicleLock]);
format(field, sizeof(field), "VehiclePlate[%d]", i);
INI_WriteString(File, field, PlayerCars[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 i = 0; i < MAX_PLAYER_VEHICLES; i++)
{
format(field, sizeof(field), "Vehicle[%d]", i);
INI_Int(field, PlayerCars[playerid][i][pVehicle]);
format(field, sizeof(field), "VehicleModel[%d]", i);
INI_Int(field, PlayerCars[playerid][i][pVehicleModel]);
format(field, sizeof(field), "VehicleX[%d]", i);
INI_Float(field, PlayerCars[playerid][i][pVehicleX]);
format(field, sizeof(field), "VehicleY[%d]", i);
INI_Float(field, PlayerCars[playerid][i][pVehicleY]);
format(field, sizeof(field), "VehicleZ[%d]", i);
INI_Float(field, PlayerCars[playerid][i][pVehicleZ]);
format(field, sizeof(field), "VehicleC[%d]", i);
INI_Float(field, PlayerCars[playerid][i][pVehicleC]);
format(field, sizeof(field), "VehicleColor1[%d]", i);
INI_Int(field, PlayerCars[playerid][i][pVehicleColor1]);
format(field, sizeof(field), "VehicleColor2[%d]", i);
INI_Int(field, PlayerCars[playerid][i][pVehicleColor2]);
format(field, sizeof(field), "VehicleValue[%d]", i);
INI_Int(field, PlayerCars[playerid][i][pVehicleValue]);
format(field, sizeof(field), "VehicleLock[%d]", i);
INI_Int(field, PlayerCars[playerid][i][pVehicleLock]);
format(field, sizeof(field), "VehiclePlate[%d]", i);
INI_String(field, PlayerCars[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(playerid, playername, sizeof(playername));
format(string, sizeof(string), VEHICLE_PATH, playername);
return string;
}
stock UserPath(playerid)
{
new string[64], playerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, playerName, sizeof(playerName));
format(string, sizeof(string), USER_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;
}
stock RPName(playerid)
{
new playerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, playerName, sizeof(playerName));
return playerName;
}
INI_ParseFile("Vehicle2Plate",PlayerCars[playerid][pVehicle2Plate]);
INI_String("Vehicle2Plate", PlayerCars[playerid][pVehicle2Plate], 32); //Replace 32 with the size of pVehicle2Plate
I tried to rewrite your code a little bit.Here's what I did:
PHP код:
Код:
INI_ParseFile("Vehicle2Plate",PlayerCars[playerid][pVehicle2Plate]); Код:
INI_String("Vehicle2Plate", PlayerCars[playerid][pVehicle2Plate], 32); //Replace 32 with the size of pVehicle2Plate |
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"); } }
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"); } } |
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; }