Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <zcmd>
- #include <YSI\y_ini> // Y_LESS
- #define PATH "vehicle/%s.ini"
- forward LoadUser_data(playerid,name[],value[]);
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" LOADED SAVING CARs");
- print("--------------------------------------\n");
- return 1;
- }
- enum cInfo
- {
- Model,
- Float:cX,
- Float:cY,
- Float:cZ,
- Lock,
- Alarm,
- }
- new CarInformation[MAX_PLAYERS][cInfo];
- COMMAND:savec(playerid, params[])
- {
- if(IsPlayerInAnyVehicle(playerid))
- {
- new INI:File = INI_Open(UserPath(playerid));
- new vozidloID[MAX_PLAYERS];
- vozidloID[playerid] = GetPlayerVehicleID(playerid);
- //
- CarInformation[playerid][Model] = GetVehicleModel(vozidloID[playerid]);
- //
- GetVehiclePos(vozidloID[playerid], CarInformation[playerid][cX], CarInformation[playerid][cY], CarInformation[playerid][cZ]);
- new engine, lights, bonnet, boot, objective;
- GetVehicleParamsEx(vozidloID[playerid], engine, lights, CarInformation[playerid][Alarm], CarInformation[playerid][Lock], bonnet, boot, objective);
- //
- INI_SetTag(File,"Auto");
- INI_WriteInt(File,"Model",CarInformation[playerid][Model]);
- INI_WriteFloat(File,"PosX",CarInformation[playerid][cX]);
- INI_WriteFloat(File,"PosY",CarInformation[playerid][cY]);
- INI_WriteFloat(File,"PosZ",CarInformation[playerid][cZ]);
- INI_WriteInt(File,"Alarm",CarInformation[playerid][Alarm]);
- INI_WriteInt(File,"Lock",CarInformation[playerid][Lock]);
- INI_Close(File);
- }
- return 1;
- }
- COMMAND:loadc(playerid, params[])
- {
- if(fexist(UserPath(playerid)))
- {
- INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
- AddStaticVehicle(CarInformation[playerid][Model] , CarInformation[playerid][cX], CarInformation[playerid][cY], CarInformation[playerid][cZ], 0, random(250), random(250));
- printf("%d %d %d %d Here is pos and modelid",CarInformation[playerid][Model] , CarInformation[playerid][cX], CarInformation[playerid][cY], CarInformation[playerid][cZ]);
- }
- return 1;
- }
- public LoadUser_data(playerid,name[],value[])
- {
- INI_Int("Model",CarInformation[playerid][Model]);
- INI_Float("PoziceX",CarInformation[playerid][cX]);
- INI_Float("PoziceY",CarInformation[playerid][cY]);
- INI_Float("PoziceZ",CarInformation[playerid][cZ]);
- INI_Int("Lock",CarInformation[playerid][Lock]);
- INI_Int("Alarm",CarInformation[playerid][Alarm]);
- return 1;
- }
- stock UserPath(playerid)
- {
- new string[128],playername[MAX_PLAYER_NAME];
- GetPlayerName(playerid,playername,sizeof(playername));
- format(string,sizeof(string),PATH,playername);
- return string;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new INI:File = INI_Open(UserPath(playerid));
- new vozidloID[MAX_PLAYERS];
- vozidloID[playerid] = GetPlayerVehicleID(playerid);
- //
- CarInformation[playerid][Model] = GetVehicleModel(vozidloID[playerid]);
- //
- GetVehiclePos(vozidloID[playerid], CarInformation[playerid][cX], CarInformation[playerid][cY], CarInformation[playerid][cZ]);
- new engine, lights, bonnet, boot, objective;
- GetVehicleParamsEx(vozidloID[playerid], engine, lights, CarInformation[playerid][Alarm], CarInformation[playerid][Lock], bonnet, boot, objective);
- //
- INI_SetTag(File,"Auto");
- INI_WriteInt(File,"Model",CarInformation[playerid][Model]);
- INI_WriteFloat(File,"PosX",CarInformation[playerid][cX]);
- INI_WriteFloat(File,"PosY",CarInformation[playerid][cY]);
- INI_WriteFloat(File,"PosZ",CarInformation[playerid][cZ]);
- INI_WriteInt(File,"Alarm",CarInformation[playerid][Alarm]);
- INI_WriteInt(File,"Lock",CarInformation[playerid][Lock]);
- INI_Close(File);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement