[Include] weapon-config.inc - Damage system with many features

Quote:
Originally Posted by FilipeSilvens
Посмотреть сообщение
You want the mysql code or my whole code? I'd rather not give my whole script out.
Try updating wepon-config from GitHub.
Reply

Quote:
Originally Posted by Slice
Посмотреть сообщение
Try updating wepon-config from GitHub.
Gonna compile now. Will edit back with results.

// Now I don't get errors with a_mysql, but instead I get errors with YSI

Код:
C:\-redacted for privacy--\pawno\include\YSI\y_hooks/impl.inc(2343) : error 021: symbol already defined: "OnPlayerTakeDamage"
C:\-redacted for privacy--\pawno\include\YSI\y_hooks/impl.inc(2390) : error 021: symbol already defined: "OnPlayerGiveDamage"
How do I make YSI compatible with weapon-config? Do I remove the OnPlayerGiveDamage and the OnPlayerTakeDamage lines from YSI?
Reply

Well, the reason you get this error is because I prevent people from accidentally using OnPlayerGiveDamage/OnPlayerTakeDamage.

Those should never be used.

Either you can remove the from YSI (ugly solution), or add this between weapon-config and the first YSI include:
pawn Код:
#if defined _ALS_OnPlayerGiveDamage
    #undef OnPlayerGiveDamage
#else
    #define _ALS_OnPlayerGiveDamage
#endif
#define OnPlayerGiveDamage NULL_OnPlayerGiveDamage
#if defined NULL_OnPlayerGiveDamage
    forward NULL_OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart);
#endif


#if defined _ALS_OnPlayerTakeDamage
    #undef OnPlayerTakeDamage
#else
    #define _ALS_OnPlayerTakeDamage
#endif
#define OnPlayerTakeDamage NULL_OnPlayerTakeDamage
#if defined NULL_OnPlayerTakeDamage
    forward NULL_OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart);
#endif
Reply

Quote:
Originally Posted by Slice
Посмотреть сообщение
Well, the reason you get this error is because I prevent people from accidentally using OnPlayerGiveDamage/OnPlayerTakeDamage.

Those should never be used.

Either you can remove the from YSI (ugly solution), or add this between weapon-config and the first YSI include:
pawn Код:
#if defined _ALS_OnPlayerGiveDamage
    #undef OnPlayerGiveDamage
#else
    #define _ALS_OnPlayerGiveDamage
#endif
#define OnPlayerGiveDamage NULL_OnPlayerGiveDamage
#if defined NULL_OnPlayerGiveDamage
    forward NULL_OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart);
#endif


#if defined _ALS_OnPlayerTakeDamage
    #undef OnPlayerTakeDamage
#else
    #define _ALS_OnPlayerTakeDamage
#endif
#define OnPlayerTakeDamage NULL_OnPlayerTakeDamage
#if defined NULL_OnPlayerTakeDamage
    forward NULL_OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart);
#endif
how do I transfer everything from my OnPlayerTakeDamage and OnPlayerGiveDamage to OnPlayerDamage lol

// edit: just noticed i need to adapt my whole script to this include, this is more complicated than i thought
Reply

Look at the documentation on GitHub. Use OnPlayerDamage.
Reply

Actually it wasnt that hard. I figured it out. Now it works. But I have two issues. When I set a player's HP to 0, they don't die, any way to fix that? Second issue: The linux version of sky (.so) doesn't work (people don't lose health) but it works perfectly with the windows version (.dll), do you have a download link for the updated .so? I would really like to use this include on my server, because it's amazing and would cut off the health hackers. I would compile it myself but I can only compile the DLL version, I have no idea how to compile the .so version on windows.
Reply

I'm using this SKY Linux version

http://www.mediafire.com/download/fa...54m1ocq/SKY.so

By the way, are you using YSF? If yes, that could cause the problem with the "not losing health".
Reply

Quote:
Originally Posted by JustMe.77
Посмотреть сообщение
I'm using this SKY Linux version

http://www.mediafire.com/download/fa...54m1ocq/SKY.so

By the way, are you using YSF? If yes, that could cause the problem with the "not losing health".
No I don't have YSF. I'm going to try to re-compile the script with a new weapon-config and use your version of SKY. Editing back with results.

//Working perfectly, looks like I had an old version of SKY. thanks!
Reply

Quote:
Originally Posted by FilipeSilvens
Посмотреть сообщение
Actually it wasnt that hard. I figured it out. Now it works. But I have two issues. When I set a player's HP to 0, they don't die, any way to fix that? Second issue: The linux version of sky (.so) doesn't work (people don't lose health) but it works perfectly with the windows version (.dll), do you have a download link for the updated .so? I would really like to use this include on my server, because it's amazing and would cut off the health hackers. I would compile it myself but I can only compile the DLL version, I have no idea how to compile the .so version on windows.
Where do you set their HP to 0?
Reply

Quote:
Originally Posted by Slice
Посмотреть сообщение
Where do you set their HP to 0?
For example:

Код:
 // OnPlayerDamage

if(issuerid != playerid && weapon == 34 && bodypart == 9 && IsAHitman(issuerid) && GoChase[issuerid] == playerid)
    {
  		new szMessage[64 + MAX_PLAYER_NAME];
		new takemoney = floatround((PINFO[playerid][Bounty] / 4) * 2);
		GivePlayerCash(issuerid, takemoney);
		GivePlayerCash(playerid, -takemoney);
		format(szMessage, sizeof(szMessage),"Hitman %s has executed %s with a Sniper Rifle and collected $%d.",GetPlayerNameEx(issuerid),GetPlayerNameEx(playerid),takemoney);
		SendMessageToAllEx(COLOR_YELLOW, szMessage);
		format(szMessage, sizeof(szMessage),"You have been executed.");
		SendClientMessageEx(playerid, COLOR_YELLOW, szMessage);
		SetPlayerHealth(playerid, 0.0); // < Right here
    }
and also:

Код:
CMD:killplayer(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 4)
	{
	    {
    		new giveplayerid;
			if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /killplayer [player]");
			SetPlayerHealth(giveplayerid, 0.0); // Also here
	    }
	}
        return 1;
}
The code looks messy cuz it's just an example.
Reply

I've had a small problem with weapon-config, I'm not sure what's wrong.

PHP код:
public OnPlayerDamage(&playerid, &Float:amount, &issuerid, &weapon, &bodypart)
{
    new 
Float:hp;
    if(
team[playerid] == 1)
    {
        if(
weapon == 34)
        {
            
GetPlayerHealth(playeridhp);
            
SetPlayerHealth(playeridhp -34);
        }
    }
    return 
1;

The problem is, Once The player hits 0 or less than 0, The player stops taking damage and doesn't die.
Reply

slice Please help
i use fcnpc plugin for my gamemod but when npc attacks player that player doesn't take any damage
please help
Reply

This include seems to cause FPS drops. I have tested both the Linux and Windows versions of SKY plugin.
Without this include and without SKY plugin I get ~90 FPS.

With them both, I get drops down to ~45 FPS but this only happens strangely when looking at a certain area around the 0.0 0.0 0.0 location.

Код:
#include <a_samp>
#undef MAX_PLAYERS
#define MAX_PLAYERS (5)

#define FIXES_Single 1
#define FIX_GetWeaponName 0
#define FIX_GetPlayerWeapon 0
#define FIX_AllowTeleport 0
#define FIX_OnPlayerDeath 0
#define FIX_Kick 0
#define FIX_BODYPARTS 0
#include <fixes>

#include <weapon-config>
#include <a_mysql>
#include <streamer>
#include <sscanf2>
#include <YSI\y_timers>
#include <YSI\y_iterate>
#include <Pawn.CMD>
#include <easyDialog>
#include <VehModEx>
Reply

Quote:
Originally Posted by Dodo9655
Посмотреть сообщение
This include seems to cause FPS drops. I have tested both the Linux and Windows versions of SKY plugin.
Without this include and without SKY plugin I get ~90 FPS.

With them both, I get drops down to ~45 FPS but this only happens strangely when looking at a certain area around the 0.0 0.0 0.0 location.

Код:
#include <a_samp>
#undef MAX_PLAYERS
#define MAX_PLAYERS (5)

#define FIXES_Single 1
#define FIX_GetWeaponName 0
#define FIX_GetPlayerWeapon 0
#define FIX_AllowTeleport 0
#define FIX_OnPlayerDeath 0
#define FIX_Kick 0
#define FIX_BODYPARTS 0
#include <fixes>

#include <weapon-config>
#include <a_mysql>
#include <streamer>
#include <sscanf2>
#include <YSI\y_timers>
#include <YSI\y_iterate>
#include <Pawn.CMD>
#include <easyDialog>
#include <VehModEx>
That is because RemoveBuilding causes lag at 0, 0, 0. This include uses RemoveBuilding to remove vending machines. If you do not wish to have that functionality, you can so this:
pawn Код:
#define WC_CUSTOM_VENDING_MACHINES false
#include <weapon-config>
Reply

Quote:
Originally Posted by hossa
Посмотреть сообщение
I've had a small problem with weapon-config, I'm not sure what's wrong.

PHP код:
public OnPlayerDamage(&playerid, &Float:amount, &issuerid, &weapon, &bodypart)
{
    new 
Float:hp;
    if(
team[playerid] == 1)
    {
        if(
weapon == 34)
        {
            
GetPlayerHealth(playeridhp);
            
SetPlayerHealth(playeridhp -34);
        }
    }
    return 
1;

The problem is, Once The player hits 0 or less than 0, The player stops taking damage and doesn't die.
What are you trying to accomplish?
Reply

How do I add headshot system,can someone give me an example?
And also,How do I set damage for specific weapons?
Reply

Quote:
Originally Posted by Dice_
Посмотреть сообщение
How do I add headshot system,can someone give me an example?
And also,How do I set damage for specific weapons?
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
}
Reply

Quote:
Originally Posted by Jeroen52
Посмотреть сообщение
What are you trying to accomplish?
Modify sniper damage to 34 instead of default damage.
Reply

Quote:
Originally Posted by hossa
Посмотреть сообщение
Modify sniper damage to 34 instead of default damage.
I have just posted this reply, this should answer your question.

http://forum.sa-mp.com/showpost.php?...&postcount=577

If you have more questions or are stuck on something, do ask.
Reply

Quote:
Originally Posted by Jeroen52
Посмотреть сообщение
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
}
Ah thanks a lot!
Reply


Forum Jump:


Users browsing this thread: 25 Guest(s)