/*
2014, 18th of June.
Credits:
GiGi / d3ll / Brandon_More - Coder (Edited)
Kalcor - a_samp.inc (functions)
Mmartin - Original coder.
*/
#include <a_samp>
stock GetRepairPrice(vehicleid, &price)
{
new panels,
doors,
lights,
tires;
GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
// Vehicle perhiferals
new front_left_panel = 0xf & panels;
new front_right_panel = ( ( 0xf << 4 ) & panels ) >> 4;
new rear_left_panel = ( ( 0xf << 8 ) & panels ) >> 8;
new rear_right_panel = ( ( 0xf << 12 ) & panels ) >> 12;
new wind_shield = ( ( 0xf << 16 ) & panels ) >> 16;
new front_bumper = ( ( 0xf << 20 ) & panels ) >> 20;
new rear_bumper = ( ( 0xf << 24 ) & panels ) >> 24;
new hood = 0xf & doors;
new trunk = ( ( 0xf << 8 ) & doors ) >> 8;
// Vehicle seats
new front_left_seat = ( ( 0xf << 16 ) & doors ) >> 16;
new front_right_seat = ( ( 0xf << 24 ) & doors ) >> 24;
new rear_left_seat = ( ( 0xf << 32 ) & doors ) >> 32;
new rear_right_seat = ( ( 0xf << 40 ) & doors ) >> 40;
// Tires
new tire_front_left = 1 & tires;
new tire_front_right = ( ( 1 << 1 ) & tires ) >> 1;
new tire_rear_left = ( ( 1 << 2 ) & tires ) >> 2;
new tire_rear_right = ( ( 1 << 3 ) & tires ) >> 3;
// Comparing the information together
new panel_add = floatround( ( front_left_panel +
front_right_panel +
rear_left_panel +
rear_right_panel +
wind_shield +
front_bumper +
rear_bumper ) / 0.21 );
new door_add = floatround( ( hood +
trunk +
front_left_seat +
front_right_seat +
rear_left_seat +
rear_right_seat ) / 0.24 );
new tire_add = floatround( ( tire_front_left +
tire_front_right +
tire_rear_left +
tire_rear_right ) / 0.04 );
new pprice = 1 * panel_add;
new dprice = 1 * door_add;
new tprice = 2 * tire_add;
new Float:iHealth;
GetVehicleHealth(vehicleid, iHealth);
new engineprice = floatround( ( floatround ( iHealth - 1000 ) * ( -1 ) ) * 0.75 );
price = engineprice + tprice + dprice + pprice;
}
#include <GetRepairPrice> // Or whatever you saved the file as.
GetRepairPrice(vehicleid, price);
COMMAND:fixcar(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid) == 1)
{
new vehicleid = GetPlayerVehicleID(playerid);
new iPrice;
GetRepairPrice(vehicleid, iPrice);
if(GetPlayerMoney(playerid) >= iPrice)
{
return RepairVehicle(vehicleid);
}
else return SendClientMessage(playerid, -1, "You do not have enough money to repair this vehicle.");
}
else return SendClientMessage(playerid, -1, "You are not inside any vehicle.");
}
http://forum.ls-rp.com/viewtopic.php?f=592&t=242039
I'm quite sure most of it is copied from this thread. If you don't have an account: http://pastebin.com/65ysmcLB |