How can I increase weapons damage?
#1

I got OPSP include:
Код:
/*******************************************
* OnPlayerShootPlayer! V:1.0               *
* Credits: wups                            *
********************************************/

// include
#include <a_samp>
#tryinclude <foreach>

#if defined OPSP
	#endinput
#endif
#define OPSP
// variables

new phealth[MAX_PLAYERS];

// forwards
forward OnPlayerShootPlayer(shooter,target,damage);

public OnPlayerUpdate(playerid)
{
	static  Float:HP,
			Float:Armour;
	GetPlayerHealth(playerid,HP);
	GetPlayerArmour(playerid,Armour);
	if(HP+Armour < phealth[playerid])
	{
		#if defined _foreach_included
		foreach(Player, i)
		#else
	    for(new i;i<MAX_PLAYERS;i++)
	    #endif
	    {
	        if(i==playerid) continue;
	        if(IsPlayerAimingAtPlayer(i,playerid))
	        {
/*				new msg[40];
				format(msg,sizeof(msg),"Droped by: %iHP",floatround(phealth[playerid]-HP-Armour));
				SendClientMessage(i,0x33AA33AA,msg); */ // only testing
				CallLocalFunction("OnPlayerShootPlayer","iii",i,playerid,floatround(phealth[playerid]-HP-Armour));
				break;
	        }
	    }
	
	}
	phealth[playerid]=floatround(HP+Armour);
	return CallLocalFunction("RL_OnPlayerUpdate","i",playerid);
}


Float:DistanceCameraTargetToLocation(Float:CamX, Float:CamY, Float:CamZ,  Float:ObjX, Float:ObjY, Float:ObjZ,  Float:FrX, Float:FrY, Float:FrZ) {

	new Float:TGTDistance;

	TGTDistance = floatsqroot((CamX - ObjX) * (CamX - ObjX) + (CamY - ObjY) * (CamY - ObjY) + (CamZ - ObjZ) * (CamZ - ObjZ));

	new Float:tmpX, Float:tmpY, Float:tmpZ;

	tmpX = FrX * TGTDistance + CamX;
	tmpY = FrY * TGTDistance + CamY;
	tmpZ = FrZ * TGTDistance + CamZ;

	return floatsqroot((tmpX - ObjX) * (tmpX - ObjX) + (tmpY - ObjY) * (tmpY - ObjY) + (tmpZ - ObjZ) * (tmpZ - ObjZ));
}

stock IsPlayerAimingAt(playerid, Float:x, Float:y, Float:z, Float:radiusz)
{
	new Float:cx,Float:cy,Float:cz,Float:fx,Float:fy,Float:fz;
	GetPlayerCameraPos(playerid, cx, cy, cz);
	GetPlayerCameraFrontVector(playerid, fx, fy, fz);
	return (radiusz >= DistanceCameraTargetToLocation(cx, cy, cz, x, y, z, fx, fy, fz));
}

stock IsPlayerAimingAtPlayer(playerid, target) {
 new Float:x, Float:y, Float:z;
 GetPlayerPos(target, x, y, z);
 if (IsPlayerAimingAt(playerid, x, y, z-0.75, 1)) return true;
 if (IsPlayerAimingAt(playerid, x, y, z+0.25, 1)) return true;
 return false;
}

#if defined _ALS_OnPlayerUpdate
	#undef OnPlayerUpdate
#else
	#define _ALS_OnPlayerUpdate
#endif
#define OnPlayerUpdate RL_OnPlayerUpdate
forward RL_OnPlayerUpdate(playerid);
How can I increase weapons damage? when a player shots player. If is that possible, give me a example, that I bet be on OnPlayerUpdate, or on this include, OnPlayerShootPlayer. Thx.
Reply
#2

GetPlayerWeapon(shooter);
if == (weaponidhere)
GetPlayerHealth(target,health)
SetPlayerHealth(target,health-10)

You should be able to make something with this
Reply
#3

Quote:
Originally Posted by Bessensap
Посмотреть сообщение
GetPlayerWeapon(shooter);
if == (weaponidhere)
GetPlayerHealth(target,health)
SetPlayerHealth(target,health-10)

You should be able to make something with this
Код:
public OnPlayerShootPlayer(shooter,target,damage)
{
	new string[128];
	
    if(GetPlayerWeapon(shooter) == 22)
    {
    new Float:health;
    GetPlayerHealth(shooter,health);
    SetPlayerHealth(shooter,health-30);
    }
    return 1;
}
And I also added a message for confirm if did work or not
Код:
public OnPlayerShootPlayer(shooter,target,damage)
{
	new string[128];
	new arma = GetPlayerWeapon(shooter);
    if(arma == 22)
    {
    new Float:health;
    GetPlayerHealth(shooter,health);
    SetPlayerHealth(shooter,floatround(health-30));
    SendClientMessage(shooter, cinza, "tiro!");
    }
    return 1;
}
Someone?

This include I think isn't workin', cuz I did a selftest and didn't work. Can you give me an example on OnPlayerUpdate or OnPlayerStateChange?
Reply
#4

pawn Код:
public OnPlayerShootPlayer(shooter,target,damage)
{
    new string[128];
    new arma = GetPlayerWeapon(shooter);
    if(arma == 22)
    {
    new Float:health;
    GetPlayerHealth(target,health);
    SetPlayerHealth(target,floatround(health-30));
    SendClientMessage(target, cinza, "tiro!");
    }
    return 1;
}
Reply
#5

Can then you fix me this include? or put someway that changes weapons damage?
Reply
#6

Bump, sorry. Hours already
Reply
#7

what isn't working?
Reply
#8

Maybe because there's none else to test me with. So, I tried to put the target as: INVALID_PLAYER_ID, for if I shoot, shows a test message
Reply
#9

That won't work. Get someone to test with you, open a server, give the IP. I'll test if you open the server within 20 minutes from this post.
Reply
#10

Hi, the include is working ok. You need another player to test it.
pawn Код:
public OnPlayerShootPlayer(shooter,target,damage)
{
    if(GetPlayerWeapon(shooter)== 22)
    {
        new Float:health;
        GetPlayerHealth(target,health);
        if(health-30 > 0) // if health is set 0 or below onplayerdeath will be called for suicide
        {
             SetPlayerHealth(target,health-30);
             SendClientMessage(target, cinza, "Hurt!");
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)