01.02.2014, 17:31
with OnPlayerWeaponShot you can detect it and can do, for example, allow players to destroy vehicles without drivers.
pawn Код:
new Float:armaDano;
// Weapons damage, taken from sa-mp wiki.
armasDano[22] = 25;
armasDano[23] = 40;
armasDano[24] = 70;
armasDano[25] = 30;
armasDano[26] = 30;
armasDano[27] = 25;
armasDano[28] = 20;
armasDano[29] = 25;
armasDano[30] = 30;
armasDano[31] = 30;
armasDano[32] = 20;
armasDano[33] = 75;
armasDano[34] = 125;
armasDano[38] = 140;
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
switch(hittype) {
case 2: { // When a vehicle hit happens
new Float:veiculoHp;
GetVehicleHealth(hitid, veiculoHp);
if(armasDano[weaponid] > 0 && IsVehicleEmpty(hitid)) {
new Float:novoHp = veiculoHp - armasDano[weaponid];
// It is not good to let vehicles explode with nobody driving it because of desync problems.
if(novoHp > 251) {
SetVehicleHealth(hitid, novoHp);
}
}
}
}
}
stock IsVehicleEmpty(vehicleid)
{
for(new i; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && GetPlayerVehicleID(i) == vehicleid) return 0;
}
return 1;
}