Check when one player attacks another

kennedyarz

  • Sr. Member
  • Making American Great Again
  • Posts: 334
Check when one player attacks another
« on March 7th, 2017, 04:24 PM »Last edited on March 7th, 2017, 04:35 PM
How to check when a player is attacking another? Is it possible to know this at the moment it attacks? Example.
Code: [Select]
Message("" + player.Name + "Is Attacking" + plr.Name + "", player)

KAKAN

  • Wiki Contributor
  • Posts: 3,346
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

kennedyarz

  • Sr. Member
  • Making American Great Again
  • Posts: 334

vito

  • Sr. Member
  • Posts: 406

kennedyarz

  • Sr. Member
  • Making American Great Again
  • Posts: 334

KAKAN

  • Wiki Contributor
  • Posts: 3,346
Re: Check when one player attacks another
« Reply #5, on March 8th, 2017, 04:57 AM »
Code: [Select]
function Player::PlayerShoot(player, weapon, hitEntity, hitPosition){
if( hitEntity == null ) return 1; // Don't use break, it may give weird errors in VCMP :x
if( hitEntity.rawget( "ID" ) == null ) return 1;
//hitEntity is a player :)
local stream = Stream();
stream.WriteInt( hitEntity.ID );
Server side:-
Code: [Select]
function onClientScriptData(player){
Message( player.Name + " is shooting " + FindPlayer( Stream.ReadInt() ).Name ); // Do some error checking before using theez
}
Theoretically it should work, but if
Quote from vito on March 7th, 2017, 06:11 PM
PlayerShoot wont work with fpv, shotgus, arms...
its true, then it wont :)
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN