Map Icon/Car damage help -
Thoma - 13.01.2015
How would i go about making icons for the full SA map as i have tried the ingame icon makers yet they only allow 1 icon at an time... and adding an script into the gm that allows flat tires and no driver car damage...?
Re: Map Icon/Car damage help -
ATGOggy - 13.01.2015
For map icon, use streamer plugin and this function:
PHP код:
CreateDynamicMapIcon(Float:x, Float:y, Float:z, type, color, worldid = -1, interiorid = -1, playerid = -1, Float:streamdistance = 100.0, style = MAPICON_LOCAL);
For no car damage, add this code under OnPlayerUpdate
PHP код:
if(IsPlayerInAnyVehicle(playerid))
{
SetVehicleHealth(GetPlayerVehicleID(playerid), 1000);
}
Re: Map Icon/Car damage help -
Thoma - 13.01.2015
ah thanks ++rep but for the car damage i meant if noone is driving the car and it gets shot etc it can still get blown up
Re: Map Icon/Car damage help -
ATGOggy - 13.01.2015
Can you explain more about the car damage?
Re: Map Icon/Car damage help -
Thoma - 13.01.2015
ok like you are driving an car.... and you decide to get out and shoot it..... it will blow up and wont be blow up proof when no driver is in it
Re: Map Icon/Car damage help -
ATGOggy - 13.01.2015
So, when there are no player or players are in car, will it blow up?
Re: Map Icon/Car damage help -
Thoma - 13.01.2015
yes like that if the car has no driver it can still be blown up
Re: Map Icon/Car damage help -
Threshold - 13.01.2015
You can use the callback 'OnPlayerWeaponShot' for that. Although take note that weapons such as baseball bats and chainsaws and weapons that aren't necessarily "Shot" will not be valid for use in this callback.
An example:
pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if(hittype == BULLET_HIT_TYPE_VEHICLE) //If the player's shot hit a vehicle
{
new bool:occupied = false, Float:HIT_DAMAGE = 25.0; //Vehicle is NOT occupied by default. If we do hit the vehicle, hit damage will do 25.0 damage.
for(new i = 0; i < MAX_PLAYERS; i++) //Loop through all players.
{
if(!IsPlayerConnected(i)) continue; //Skip players that aren't connected.
if(IsPlayerInVehicle(i, hitid) && GetPlayerState(i) == PLAYER_STATE_DRIVER) //If the player is driving the vehicle we shot.
{
occupied = true; //The vehicle we shot was occupied by a driver.
break; //Break the loop, as we already know someone was driving.
}
}
if(!occupied) //If the vehicle was not occupied by a driver...
{
new Float:CarHealth; //A variable to store the vehicle's original health.
GetVehicleHealth(hitid, CarHealth); //Get the vehicle's current health.
if((CarHealth - HIT_DAMAGE) > 0) SetVehicleHealth(hitid, CarHealth - HIT_DAMAGE); //Apply the hit damage to the vehicle to reduce its health.
}
}
return 1;
}
Note that 'HIT_DAMAGE' is the amount of damage that each bullet will do to the vehicle. Feel free to change this as you wish, as you can also do variable damages depending on what weapon the player is using.
References:
https://sampwiki.blast.hk/wiki/OnPlayerWeaponShot
Re: Map Icon/Car damage help -
Thoma - 13.01.2015
Quote:
Originally Posted by Threshold
You can use the callback 'OnPlayerWeaponShot' for that. Although take note that weapons such as baseball bats and chainsaws and weapons that aren't necessarily "Shot" will not be valid for use in this callback.
An example:
pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ) { if(hittype == BULLET_HIT_TYPE_VEHICLE) //If the player's shot hit a vehicle { new bool:occupied = false, Float:HIT_DAMAGE = 25.0; //Vehicle is NOT occupied by default. If we do hit the vehicle, hit damage will do 25.0 damage. for(new i = 0; i < MAX_PLAYERS; i++) //Loop through all players. { if(!IsPlayerConnected(i)) continue; //Skip players that aren't connected. if(IsPlayerInVehicle(i, hitid) && GetPlayerState(i) == PLAYER_STATE_DRIVER) //If the player is driving the vehicle we shot. { occupied = true; //The vehicle we shot was occupied by a driver. break; //Break the loop, as we already know someone was driving. } } if(!occupied) //If the vehicle was not occupied by a driver... { new Float:CarHealth; //A variable to store the vehicle's original health. GetVehicleHealth(hitid, CarHealth); //Get the vehicle's current health. if((CarHealth - HIT_DAMAGE) > 0) SetVehicleHealth(hitid, CarHealth - HIT_DAMAGE); //Apply the hit damage to the vehicle to reduce its health. } } return 1; }
Note that 'HIT_DAMAGE' is the amount of damage that each bullet will do to the vehicle. Feel free to change this as you wish, as you can also do variable damages depending on what weapon the player is using.
References:
https://sampwiki.blast.hk/wiki/OnPlayerWeaponShot
|
THANKS!