PDA

View Full Version : How to improve this function


NinjaChicken
01/04/2013, 11:45 PM
ALright i have this

public OnEmptyVehicleDamage(vehicleid,playerid,exems)
{
ChangeVehicleColor(vehicleid,random(126),random(12 6));
return 1;
}

but i want to make it only a level 7 admin, with a desert eagle can shoot the car to make it change colours

i use pAdmin as the player saving thingy also

glbracer
01/04/2013, 11:59 PM
First, it shouldn't be a public function unless it's a timer, it's a waste of CPU.
Secondly, you'd require if() statements for that.

// Place under OnPlayerKeyStateChange
if(PlayerInfo[playerid][pAdmin] >= 7 && GetPlayerWeapon(playerid) == 24)
{
new vehicleid = GetVehiclePlayerIsAimingAt(playerid); // Find a stock function for this, should be pretty simple, try this (http://forum.sa-mp.com/showthread.php?t=140765).
ChangeVehicleColor(vehicleid, random(126), random(126);
}

MP2
02/04/2013, 12:03 AM
Do note that you can't damage un-occupied vehicles.

NinjaChicken
02/04/2013, 12:07 AM
http://forum.sa-mp.com/showthread.php?t=271903

MP2
02/04/2013, 12:36 AM
Okay, let me rephrase.

Do note that you can't accurately or reliably detect the damage of un-occupied vehicles.

glbracer
02/04/2013, 12:39 AM
Okay, let me rephrase.

Even at that, I don't think that's what he's looking for. I think he's just looking to make it so a level 7 admin and up can shoot a vehicle with a Desert Eagle and have it change the vehicle's color. For shits and giggles, as there's no logical reason to make it do that, oh well.