18.09.2016, 22:33
Quote:
Here are a couple examples, I encourage you to read it as I have written them specifically for this post.
Код:
public OnPlayerDamage(&playerid, &Float:amount, &issuerid, &weapon, &bodypart) { /* * Explaining OnPlayerDamage a bit. * OnPlayerDamage is called whenever a player has been damaged, you can use this to modify the amount of damage. * OnPlayerDamage MUST return a value, if you return `1` it will issue the playerid the `amount` on behalf of the `issuerid`, if you return `0` no damage will be issued. * Parameters: * • `playerid`: The player that receives the damage. * • `amount`: The amount of damage that will be issued. * • `issuerid`: The player that issued the damage. * • `weapon`: The weaponid of the weapon that is used to issue the damage. * • `bodypart`: The bodypart that has been damaged/shot, you can use this to make a headshot system or increase/decrease damage depending on bodypart. */ if(issuerid != INVALID_PLAYER_ID && playerid != INVALID_PLAYER_ID) // Check if the issuer (issuerid) is a valid player and the receiver (playerid) is a valid player { if(IsBulletWeapon(weapon) && bodypart == BODY_PART_HEAD) // Check if the weapon can fire bullets, and if the shot bodypart is a head. amount *= 1.3; // Multiply the amount by 1.3 if(weapon == WEAPON_RIFLE && bodypart == BODY_PART_HEAD) // Check if the weapon is the cuntgun, and if the shot bodypart is a head. amount = 72; // Set the damage to 72 if(weapon == WEAPON_SNIPER && bodypart == BODY_PART_HEAD) // Check if the weapon is a sniper rifle, and if the shot bodypart is a head. amount = 99.90; // Set the damage to 99.90 } /* * Another example below is how to make on-duty admins immune to all types of damage. * Replace the examples with the equivalent of your admin system. */ if(playerAdminLevel(playerid) > 2) // Checking if the player is above a specific admin level { if(InAdminMode[playerid] >= 1 || pInfo[playerid][pGodMode] == 1) // Check if the player is in either admin mode or godmode { return 0; // If you return 0, the damage will not be issued. } } return 1; // Return 1 to issue the damage } |