Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***************************************************************
- * *
- * Mechanic System v1.0 *
- * (c) 2013. B-Matt *
- * WEB: https://gas-locator.com *
- * *
- ****************************************************************/
- /* Includes */
- #include <a_samp>
- #include <sscanf2>
- #include <ZCMD>
- /* Colors */
- #define COLOR_LIGHTBLUE 0x468CFFFF
- #define COLOR_GREEN 0x1E8200FF
- #define COLOR_RED 0xFF1414FF
- /* Timers for mechanic */
- new SprayT;
- /* Spray system*/
- new Spray[MAX_PLAYERS];
- new pick, color;
- new Service[MAX_PLAYERS][3];
- new vehid; //Var for vehicle for mechanic service
- new Float:Car[4]; //Array for vehicle position (used in spray system)
- /* Encodes */
- encode_tires(tire1, tire2, tire3, tire4) return tire1 | (tire2 << 1) | (tire3 << 2) | (tire4 << 3);
- encode_panels(flp, frp, rlp, rrp, windshield, front_bumper, rear_bumper)
- {
- return flp | (frp << 4) | (rlp << 8) | (rrp << 12) | (windshield << 16) | (front_bumper << 20) | (rear_bumper << 24);
- }
- encode_doors(bonnet, boot, driver_door, passenger_door, behind_driver_door, behind_passenger_door)
- {
- #pragma unused behind_driver_door
- #pragma unused behind_passenger_door
- return bonnet | (boot << 8) | (driver_door << 16) | (passenger_door << 24);
- }
- encode_lights(light1, light2, light3, light4)
- {
- return light1 | (light2 << 1) | (light3 << 2) | (light4 << 3);
- }
- /* SA-MP Callbacks */
- public OnFilterScriptInit()
- {
- print("\n ===========================");
- print(" Mechanic System v1.0");
- print(" (c) B-Matt, 2013.");
- print(" ===========================\n");
- /* OPTIONAL - Mechanic garage */
- CreateObject(11387, 2187.78, -2000.54, 15.92, 0.00, 0.00, 0.00);
- CreateObject(11389, 2178.43, -1984.54, 15.70, 0.00, 0.00, 0.00);
- CreateObject(11388, 2178.43, -1984.49, 19.30, 0.00, 0.00, 0.00);
- CreateObject(11390, 2178.25, -1984.50, 16.99, 0.00, 0.00, 0.00);
- CreateObject(11391, 2170.19, -1992.65, 13.85, 0.00, 0.00, 0.00);
- CreateObject(11393, 2182.99, -1989.86, 14.00, 0.00, 0.00, 0.00);
- CreateObject(11359, 2173.93, -2000.64, 14.64, 0.00, 0.00, 0.00);
- CreateObject(11359, 2187.40, -1980.91, 14.70, 0.00, 0.00, 90.00);
- CreateObject(1676, 2199.84, -1994.45, 14.26, 0.00, 0.00, 90.00);
- AddStaticVehicle(562, Car[1], Car[2], Car[3], 90.0, 0, 0); //Optional - vehicle
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(newkeys & KEY_FIRE)
- {
- if(IsPlayerInRangeOfPoint(playerid, 3.0, Car[1], Car[2], Car[3]))
- {
- if(Spray[playerid] == 1)
- {
- SprayT = SetTimer("OnPlayerSpray", 5000, false);
- }
- }
- }
- else return KillTimer(SprayT);
- return 1;
- }
- /* Custom Callbacks */
- forward OnPlayerSpray(playerid);
- public OnPlayerSpray(playerid)
- {
- if(pick == 1) {
- ChangeVehicleColor(vehid, color, 0); }
- else {
- ChangeVehicleColor(vehid, 0, color); }
- KillTimer(SprayT);
- Spray[playerid] = 0;
- Service[playerid][0] = 0;
- SendClientMessage(playerid, COLOR_GREEN, "You successfully paint this vehicle!");
- return 1;
- }
- /* Commands */
- CMD:meh(playerid, params[]) //Optional - Mechanic garage port cmd
- {
- SetPlayerPos(playerid, 2190.9937+4, -1980.8362, 13.2);
- return 1;
- }
- CMD:spray(playerid, params[])
- {
- if(IsPlayerInRangeOfPoint(playerid, 20.0, 2180.9875,-1979.7583,13.5606)) //Optional - CHANGE
- {
- new string[128], pName[MAX_PLAYER_NAME], mName[MAX_PLAYER_NAME], pID;
- GetPlayerName(pID, pName, sizeof(pName));
- GetPlayerName(playerid, mName, sizeof(mName));
- if(sscanf(params, "uii", pID, pick, color)) return SendClientMessage(playerid, -1, "USAGE: /spray [ID/Name][Color pick (1/2)][Color]");
- if(pick > 2 || pick < 1) return SendClientMessage(playerid, COLOR_RED,"Colorpick can't be lower than 1 and higher than 2.");
- if(color > 126 || color < 0) return SendClientMessage(playerid, COLOR_RED,"Color ID can't be lower than 0 and higher than 126.");
- vehid = GetPlayerVehicleID(pID);
- format(string, sizeof(string), "%s has offered you spray service for your vehicle. Colorpick: {FFFFFF}%d{468CFF}, ColorID: {FFFFFF}%d", mName, pick, color);
- SendClientMessage(pID, COLOR_LIGHTBLUE, string);
- SendClientMessage(pID, COLOR_LIGHTBLUE, "Use /acceptmeh for accepting that offer.");
- Service[pID][0] = 1;
- }
- else return SendClientMessage(playerid, COLOR_RED, "You must be in the garage to repair vehicles!");
- return 1;
- }
- CMD:repair(playerid, params[])
- {
- if(IsPlayerInRangeOfPoint(playerid, 20.0, 2180.9875,-1979.7583,13.5606)) //Optional - CHANGE
- {
- new string[128], item[32], pID, mName[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME];
- if(sscanf(params, "s[32] ", item)) {
- SendClientMessage(playerid, -1, "USAGE: /repair [option]");
- SendClientMessage(playerid, -1, "Options: bodykit, engine");
- return 1;
- }
- if(strcmp(item,"bodykit",true) == 0) {
- if (sscanf(params, "s[32]u", item, pID)) return SendClientMessage(playerid, -1, "USAGE: /repair bodykit [ID/Name]");
- GetPlayerName(playerid, mName, sizeof(mName));
- GetPlayerName(pID, pName, sizeof(pName));
- format(string, sizeof(string), "%s has offered you a repair of bodykit on your car!", mName);
- SendClientMessage(pID, COLOR_LIGHTBLUE, string);
- SendClientMessage(pID, COLOR_LIGHTBLUE, "Use: /acceptmeh to accept that offer!");
- format(string, sizeof(string), "You offered %s to repair bodykit on his vehicle.", pName);
- SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
- Service[pID][1] = 1;
- }
- else if(strcmp(item,"engine",true) == 0) {
- if(sscanf(params, "s[32]u",item, pID)) return SendClientMessage(playerid, -1, "USAGE: /repair engine [ID/Name]");
- GetPlayerName(playerid, mName, sizeof(mName));
- GetPlayerName(pID, pName, sizeof(pName));
- format(string, sizeof(string), "%s has offered you a repair of engine on your vehicle!", mName);
- SendClientMessage(pID, COLOR_LIGHTBLUE, string);
- SendClientMessage(pID, COLOR_LIGHTBLUE, "Use: /acceptmeh to accept that offer!");
- format(string, sizeof(string), "You offered %s to repair engine on his vehicle.", pName);
- SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
- Service[pID][2] = 1;
- }
- }
- else return SendClientMessage(playerid, COLOR_RED, "You must be in the garage to repair vehicles!");
- return 1;
- }
- CMD:acceptmeh(playerid, params[])
- {
- new Float: X, Float: Y, Float: Z, pID;
- if(Service[playerid][0] == 1)
- {
- SendClientMessage(playerid, -1, "You accepted mechanic service. Please wait!");
- GetVehiclePos(vehid, X, Y, Z);
- Car[1] = X;
- Car[2] = Y;
- Car[3] = Z;
- Spray[pID] = 1;
- GivePlayerWeapon(pID, 41, 500);
- }
- else if(Service[playerid][1] == 1)
- {
- new panels,doors,lights,tires;
- SendClientMessage(playerid, COLOR_LIGHTBLUE, "You accepted mechanic service. Please wait!");
- vehid = GetPlayerVehicleID(playerid);
- tires = encode_tires(0, 0, 0, 0); // fix all tires
- panels = encode_panels(0, 0, 0, 0, 0, 0, 0); // fix all panels
- doors = encode_doors(0, 0, 0, 0, 0, 0); // fix all doors
- lights = encode_lights(0, 0, 0, 0); // fix all lights
- UpdateVehicleDamageStatus(vehid, panels, doors, lights, tires);
- Service[playerid][1] = 0;
- SendClientMessage(playerid, COLOR_GREEN, "Bodykit on your vehicle has been fully repaired!");
- }
- else if(Service[playerid][2] == 1)
- {
- SendClientMessage(playerid, COLOR_LIGHTBLUE, "You accepted mechanic service. Please wait!");
- vehid = GetPlayerVehicleID(playerid);
- SetVehicleHealth(vehid, 1000.0);
- Service[playerid][2] = 0;
- SendClientMessage(playerid, COLOR_GREEN, "Your vehicle's engine has been fully repaired!");
- }
- else return SendClientMessage(playerid, COLOR_RED, "No one has offered you mechanic service!");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement