В этом уроке мы сможем сделать урон машины если даже в нем нет водителя.
Вверху мода где все #define вставим
Код
#define VEHICLE_DMG_DEFAULT 25.0
#define VEHICLE_DMG_COLT45 50.0
#define VEHICLE_DMG_SILENCED 50.0
#define VEHICLE_DMG_DEAGLE 75.0
#define VEHICLE_DMG_SHOTGUN 75.0
#define VEHICLE_DMG_SAWEDOFF 78.0
#define VEHICLE_DMG_SHOTGSPA 80.0
#define VEHICLE_DMG_UZI 35.0
#define VEHICLE_DMG_MP5 60.0
#define VEHICLE_DMG_AK47 80.0
#define VEHICLE_DMG_M4 80.0
#define VEHICLE_DMG_TEC9 40.0
#define VEHICLE_DMG_RIFLE 75.0
#define VEHICLE_DMG_ROCKETLAUNCHER 150.0
#define VEHICLE_DMG_HEATSEEKER 150.0
#define VEHICLE_DMG_MINIGUN 200.0
#define DecreaseVehHP(%1) if (vhp > %1) SetVehicleHealth(vehicleid, vhp - %1)
Потом в любое место вставить функцию public OnUnoccupiedVehicleUpdate
вот сам код
Код
public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat){
if (passenger_seat != 0) return;
new
cm = GetPlayerCameraMode(playerid);
if (cm != 53 && cm != 51) return;
new
keys, tmp;
GetPlayerKeys(playerid, keys, tmp, tmp);
if (!(keys & KEY_FIRE)) return;
new Float:vhp; GetVehicleHealth(vehicleid, vhp);
switch (GetPlayerWeapon(playerid)){
case WEAPON_COLT45: DecreaseVehHP(VEHICLE_DMG_COLT45);
case WEAPON_SILENCED: DecreaseVehHP(VEHICLE_DMG_SILENCED);
case WEAPON_DEAGLE: DecreaseVehHP(VEHICLE_DMG_DEAGLE);
case WEAPON_SHOTGUN: DecreaseVehHP(VEHICLE_DMG_SHOTGUN);
case WEAPON_SAWEDOFF: DecreaseVehHP(VEHICLE_DMG_SAWEDOFF);
case WEAPON_SHOTGSPA: DecreaseVehHP(VEHICLE_DMG_SHOTGSPA);
case WEAPON_UZI: DecreaseVehHP(VEHICLE_DMG_UZI);
case WEAPON_MP5: DecreaseVehHP(VEHICLE_DMG_MP5);
case WEAPON_AK47: DecreaseVehHP(VEHICLE_DMG_AK47);
case WEAPON_M4: DecreaseVehHP(VEHICLE_DMG_M4);
case WEAPON_TEC9: DecreaseVehHP(VEHICLE_DMG_TEC9);
case WEAPON_RIFLE: DecreaseVehHP(VEHICLE_DMG_RIFLE);
case WEAPON_ROCKETLAUNCHER: DecreaseVehHP(VEHICLE_DMG_ROCKETLAUNCHER);
case WEAPON_HEATSEEKER: DecreaseVehHP(VEHICLE_DMG_HEATSEEKER);
case WEAPON_MINIGUN: DecreaseVehHP(VEHICLE_DMG_MINIGUN);
default: DecreaseVehHP(VEHICLE_DMG_DEFAULT);
}
}
Автор урока: 26_RUSSS