Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <sscanf2>
- enum ENUM_VEHICLE_DATA
- {
- v_color[2],
- v_delay,
- };
- new VData[MAX_VEHICLES][ENUM_VEHICLE_DATA];
- stock _AddStaticVehicle(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:angle, color1, color2, respawn_delay=65535)
- {
- new
- id;
- if(respawn_delay == 65535)
- id = AddStaticVehicle(modelid, spawn_x, spawn_y, spawn_z, angle, color1, color2);
- else
- id = AddStaticVehicleEx(modelid, spawn_x, spawn_y, spawn_z, angle, color1, color2, respawn_delay);
- if(id < 1 || id > 2000)
- return id;
- VData[id][v_color][0] = color1;
- VData[id][v_color][1] = color2;
- VData[id][v_delay] = respawn_delay;
- return id;
- }
- #if defined _ALS_AddStaticVehicle
- #undef AddStaticVehicle
- #else
- #define _ALS_AddStaticVehicle
- #endif
- #define AddStaticVehicle _AddStaticVehicle
- #if defined _ALS_AddStaticVehicleEx
- #undef AddStaticVehicleEx
- #else
- #define _ALS_AddStaticVehicleEx
- #endif
- #define AddStaticVehicleEx _AddStaticVehicle
- stock _CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay)
- {
- new
- id;
- id = CreateVehicle(modelid, x, y, z, angle, color1, color2, respawn_delay);
- if(id < 1 || id > 2000)
- return id;
- VData[id][v_color][0] = color1;
- VData[id][v_color][1] = color2;
- VData[id][v_delay] = respawn_delay;
- return id;
- }
- #if defined _ALS_CreateVehicle
- #undef CreateVehicle
- #else
- #define _ALS_CreateVehicle
- #endif
- #define CreateVehicle _CreateVehicle
- stock SaveVehicle(const path[], vehicleid)
- {
- new
- model;
- if(!(model = GetVehicleModel(vehicleid)))
- return 0;
- new
- File:fhnd,
- Float:P[4],
- color[2],
- delay,
- buffer[64];
- fhnd = fopen(path, ((!fexist(path)) ? (io_write) : (io_append)));
- GetVehiclePos(vehicleid, P[0], P[1], P[2]);
- GetVehicleZAngle(vehicleid, P[3]);
- GetVehicleColor(vehicleid, color[0], color[1]);
- GetVehicleDelay(vehicleid, delay);
- format(buffer, 64, "%i %f %f %f %f %i %i %i\r\n", model, P[0], P[1], P[2], P[3], color[0], color[1], delay);
- fwrite(fhnd, buffer);
- fclose(fhnd);
- return 1;
- }
- stock LoadVehicles(const path[])
- {
- if(!fexist(path))
- return 0;
- new
- File:fhnd,
- buffer[64],
- model,
- Float:P[4],
- color[2],
- delay;
- fhnd = fopen(path, io_read);
- while(fread(fhnd, buffer))
- {
- if(buffer[0] == '#')
- continue;
- sscanf(buffer, "iffffiii", model, P[0], P[1], P[2], P[3], color[0], color[1], delay);
- AddStaticVehicleEx(model, P[0], P[1], P[2], P[3], color[0], color[1], delay);
- }
- fclose(fhnd);
- return 1;
- }
- stock GetVehicleColor(vehicleid, &color1, &color2)
- {
- if(vehicleid < 1 || vehicleid > MAX_VEHICLES)
- return 0;
- color1 = VData[vehicleid][v_color][0];
- color2 = VData[vehicleid][v_color][1];
- return 1;
- }
- stock GetVehicleDelay(vehicleid, &delay)
- {
- if(vehicleid < 1 || vehicleid > MAX_VEHICLES)
- return 0;
- delay = VData[vehicleid][v_delay];
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement