[Include] OnPlayerShotTeamVeh - Detects if player shoots team mate's vehicle
#1

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
Reply
#2

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
Reply
#3

Try the script first!
Reply
#4

Try if OnPlayerWeaponShot gets called in your gamemode when using this include.
Reply
#5



Those 5 warnings from default gamemode!
Reply
#6

Run the gamemode on localhost and see if "kk" gets sent to you.
Reply
#7

Actually, you know what? My bad!
Anyway, now the script using y_hooks.
Reply
#8

I'd recommend making it so returning 0 has the effect of stopping / reversing the damage to the vehicle.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)