OnPlayerShotTeamVeh - Detects if player shoots team mate's vehicle -
Maximus0 - 13.02.2015
OnPlayerShotTeamVeh
Introduction
This include can check if a player is shooting his team mate's vehicle. Easy and simple but will be useful in RP servers.
Functions
Код:
forward OnPlayerShotTeamVeh(playerid, targetid, weaponid, vehid);
Where to use it
On many RP servers, you don't want a player to shoot his team player's tire/vehicle. On that case you can return 0 to apply no effect.
Example code
pawn Код:
public OnPlayerShotTeamVeh(playerid, targetid, weaponid, vehid)
{
new String[400];
new name[MAX_PLAYER_NAME];
new tname[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(playerid, tname, sizeof(tname));
format(String, sizeof( String ), "%s has shoted %s who is in vehicleid %i with weaponid %i", name, tname, vehid, weaponid);
SendClientMessageToAll(0xFF0000FF, String);
}
pawn Код:
public OnPlayerShotTeamVeh(playerid, targetid, weaponid, vehid)
{
new vehicle;
new Float:health;
vehicle = GetPlayerVehicleID(targetid);
GetVehicleHealth(vehicle, health);
SetVehicleHealth(vehicle, health);
}
Download
Maximus
MediaFire
PasteBin
Re: OnPlayerShotTeamVeh - Detects if player shoots team mate's vehicle -
kristo - 13.02.2015
Your hooks won't work. You have to add this kind of code to the end of your callbacks:
pawn Код:
#if defined Max_OnGameModeInit
return Max_OnGameModeInit();
#else
return 1;
#endif
Re: OnPlayerShotTeamVeh - Detects if player shoots team mate's vehicle -
Maximus0 - 13.02.2015
Try the script first!
Re: OnPlayerShotTeamVeh - Detects if player shoots team mate's vehicle -
kristo - 13.02.2015
Try if OnPlayerWeaponShot gets called in your gamemode when using this include.
Re: OnPlayerShotTeamVeh - Detects if player shoots team mate's vehicle -
Maximus0 - 13.02.2015
Those 5 warnings from default gamemode!
Re: OnPlayerShotTeamVeh - Detects if player shoots team mate's vehicle -
kristo - 13.02.2015
Run the gamemode on localhost and see if "kk" gets sent to you.
Re: OnPlayerShotTeamVeh - Detects if player shoots team mate's vehicle -
Maximus0 - 13.02.2015
Actually, you know what? My bad!
Anyway, now the script using y_hooks.
Re: OnPlayerShotTeamVeh - Detects if player shoots team mate's vehicle -
Puppy - 14.02.2015
I'd recommend making it so returning 0 has the effect of stopping / reversing the damage to the vehicle.