Jump to content

onPlayerWeaponFire


RekZ

Recommended Posts

function onPlayerWeaponFire (weapon, endX, endY, endZ, hitElement, startX, startY, startZ)
	if isElement(hitElement) and getElementType(hitElement) == "player" then
		if weapon == 34 then
			outputChatBox( "* Damage" )
		end
	end
end
addEventHandler("onPlayerWeaponFire",  getRootElement(), onPlayerWeaponFire)

When i use the sniper and i shot it dont give me the chatbox but if i remove the second line ( isElement(....) ) it work why ?

Link to comment
59 minutes ago, RekZ said:

function onPlayerWeaponFire (weapon, endX, endY, endZ, hitElement, startX, startY, startZ)
	if isElement(hitElement) and getElementType(hitElement) == "player" then
		if weapon == 34 then
			outputChatBox( "* Damage" )
		end
	end
end
addEventHandler("onPlayerWeaponFire",  getRootElement(), onPlayerWeaponFire)

When i use the sniper and i shot it dont give me the chatbox but if i remove the second line ( isElement(....) ) it work why ?


Check returning value a function "isElement"
 

outputChatBox("Return: "..tostring(isElement(hitElement))

 

  • hitElement: an element which was hit by a shot. Currently this can be only another player.
Edited by XaskeL
Link to comment
19 minutes ago, RekZ said:

false it seems that there is no element, but whit others weapons return true

maybe this is a bug? I would check, but there's no way. The lock in the MTA forever. haha.

Don't use "isElement" otherwise the damage would not have passed if there was no element

Edited by XaskeL
Link to comment

For freeroam its eassy press p panel then double click freeroam settings /disable weapon add here the weapon id save then restart free roam

If you want in  script type give function of take weapon !

In damage purpose(body parts) use cancel event !

Go through MTA sa wiki you will get all 

Edited by Khadeer143
  • Thanks 1
Link to comment
1 hour ago, Khadeer143 said:

For freeroam its eassy press p panel then double click freeroam settings /disable weapon add here the weapon id save then restart free roam

If you want in  script type give function of take weapon !

In damage purpose(body parts) use cancel event !

Go through MTA sa wiki you will get all 

You only comment the post and dont see what is the problem right... the problem is the function not the gamemode ._. ?

Link to comment
23 hours ago, RekZ said:

Sorry for the double post, but what i can do >-< the players in my server cant use the sniper now

you asked this and i replied the easiest way to do yes it depends on gamemode to if it is freeroam then you can forbid weapons and if want to not use sniper

 i suggest you how to do also use function forbidWeapons( previousWeaponID, currentWeaponID ) then if weapon - weapon ID

then then take the weapon by setting timer 

setTimer(takeWeapon,50,1,source,currentWeaponID)

 

Link to comment

I have a custom damage system for weapons and the event dont detect any element whit sniper so if no exist element player cant be hit by other players because the function i think dont work whit this weapon.. this is the problem.

onPlayerWeaponFire

PD : You only read one comment no the post :v

Edited by RekZ
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...