Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* SA-MP Include Vehicle Damage Control
- *
- * (c) by Kaliber, 2014
- *
- */
- #if !defined _samp_included
- #include <a_samp>
- #endif
- #if defined _vehicle_control
- #endinput
- #endif
- #define _vehicle_control
- #define INVALID -1
- stock DestroyWheel(vehicleid, wheel) {
- static tmp[4];
- GetVehicleDamageStatus(vehicleid, tmp[0], tmp[1], tmp[2], tmp[3]);
- if(inc_IsABike(vehicleid)) {
- if(wheel <= 0 || wheel > 2) return INVALID;
- tmp[3] = (tmp[3] == 1) ? 0b0010 : 0b0001;
- } else {
- if(wheel <= 0 || wheel > 4) return INVALID;
- switch(wheel) {
- case 1: tmp[3] = 0b1000;
- case 2: tmp[3] = 0b0010;
- case 3: tmp[3] = 0b0100;
- case 4: tmp[3] = 0b0001;
- }
- }
- return UpdateVehicleDamageStatus(vehicleid, tmp[0], tmp[1], tmp[2], tmp[3]);
- }
- stock RepairWheels(vehicleid) {
- static tmp[4];
- return GetVehicleDamageStatus(vehicleid, tmp[0], tmp[1], tmp[2], tmp[3]),UpdateVehicleDamageStatus(vehicleid, tmp[0], tmp[1], tmp[2], 0);
- }
- stock DestroyAllWheels(vehicleid) {
- static tmp[4];
- return GetVehicleDamageStatus(vehicleid, tmp[0], tmp[1], tmp[2], tmp[3]),UpdateVehicleDamageStatus(vehicleid, tmp[0], tmp[1], tmp[2], (inc_IsABike(vehicleid)) ? 3 : 15);
- }
- stock DestroyPanel(vehicleid, idx) {
- if(inc_IsABike(vehicleid) || idx <= 0 || idx > 4) return INVALID;
- static tmp[4],buffer[33],whise[4][9];
- GetVehicleDamageStatus(vehicleid, tmp[0], tmp[1], tmp[2], tmp[3]);
- format(buffer,sizeof buffer,"%032b",tmp[0]),idx--;
- strmid(whise[0],buffer,0,8,9),strmid(whise[1],buffer,8,16,9);
- strmid(whise[2],buffer,16,24,9),strmid(whise[3],buffer,24,32,9);
- strdel(whise[idx],strlen(whise[idx])-1,strlen(whise[idx]));
- strins(whise[idx],"1",strlen(whise[idx]),8);
- format(buffer,sizeof buffer,"%s%s%s%s",whise[0],whise[1],whise[2],whise[3]);
- return UpdateVehicleDamageStatus(vehicleid, BinaryToDecimal(buffer), tmp[1], tmp[2], tmp[3]);
- }
- stock DestroyStuff(vehicleid, idx) {
- if(inc_IsABike(vehicleid) || idx <= 0 || idx > 4) return INVALID;
- static tmp[4],buffer[33],whise[4][9];
- GetVehicleDamageStatus(vehicleid, tmp[0], tmp[1], tmp[2], tmp[3]);
- format(buffer,sizeof buffer,"%032b",tmp[1]),idx--;
- strmid(whise[0],buffer,0,8,9),strmid(whise[1],buffer,8,16,9);
- strmid(whise[2],buffer,16,24,9),strmid(whise[3],buffer,24,32,9);
- strdel(whise[idx],strlen(whise[idx])-1,strlen(whise[idx]));
- strins(whise[idx],"1",strlen(whise[idx]),8);
- format(buffer,sizeof buffer,"%s%s%s%s",whise[0],whise[1],whise[2],whise[3]);
- return UpdateVehicleDamageStatus(vehicleid, tmp[0], BinaryToDecimal(buffer), tmp[2], tmp[3]);
- }
- stock inc_IsABike(vID) {
- new m = GetVehicleModel(vID);
- return (m==509||m==510||m==581||m==522||m==521||m==523||m==586||m==481||m==462||m==448||m==461||m==463||m==468||m==471) ? 1 : 0;
- }
- stock BinaryToDecimal(const binary[]) {
- new num=0;
- for(new i,cPos[2],l=strlen(binary); i<l; i++) {
- strmid(cPos, binary, (l-(i+1)),(l-i),2);
- num += (strval(cPos)*floatround(floatpower(float(2),float(i)),floatround_floor));
- }
- return num;
- }
- #undef INVALID
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement