Your going to:
A. Hook an event with 'player_hurt'
B. On the callback for that, you will want to check for the weapon and then add some more damage by removing it from the health.
C. You can either prethink real quick to not kill them with the extra damage so it won't appear as a suicide, or you can go to a thread I few weeks ago in this subthread on creating custom death messages.
Here we go:
Code:
//Initation, this is a 'callback' it will be called one time in a plugin's life:
public OnPluginStart()
{
//Hook the event, this makes it so the function 'EventDamage' will be called at the same time (or about the same time) as 'player_hurt' event.
HookEvent("player_hurt", EventDamage);
}
//Now we write the hook, it has to be formatted like this for events:
public EventDamage(Handle:Event, const String:Name[], bool:Broadcast)
{
//Notice EventDamage is the same thing we wrote in HookEvent, it creates this function as a hook. 'public' infront of it is used for call backs. Otherwise it is not neccessary.
//Declare the variables we want to use:
decl Client, Attacker; //Client & Attacker ID we need to find
decl ClientHealth; //No functags it is an integer, meaning a number with no decimals.
decl String:WeaponName[32]; //String means it is a sentence of standard ANSI characters. 32 in brackets is how many characters it can have, including a null terminator.
//Now we initiliaze the variables:
Client = GetClientOfUserId(GetEventInt(Event, "userid")); //These are parameters returned in the event player_hurt
Attacker = GetClientOfUserId(GetEventInt(Event, "attacker"));
ClientHealth = GetClientHealth(Client); //Gets the clients HP, integer.
GetClientWeapon(Client, WeaponName, sizeof(WeaponName)); //Get's Weapon Name as a string.
//Add Damage:
if(StrContains(WeaponName, "scatter", false)) //This checks to see if their weapon name contains 'scatter', false is a parameter which means it is not case-sensative.
{
//So if it is a scatter gun:
//We want to modify the damage...
if(Health - 10 >= 1) //This makes sure they wont die from the extra damage to avoid death message interuption.
SetEntityHealth(Client, Health - 10); //10 is the extra damage we want to add.
}
//Close & Return:
CloseHandle(Event); //Always close handles
return Plugin_Handled;
}
__________________