IsPlayerHitByVehicle: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 35: Line 35:


==Server==
==Server==
 
<syntaxhighlight lang="lua">
function isPlayerHitByVehicle (attacker)
function isPlayerHitByVehicle (attacker)
if not attacker then
if not attacker then
Line 45: Line 45:
end
end
addEventHandler("onPlayerDamage", root, isPlayerHitByVehicle)
addEventHandler("onPlayerDamage", root, isPlayerHitByVehicle)
</syntaxhighlight>


== Author ==
== Author ==


Lisek
Lisek

Revision as of 19:37, 9 June 2020

isPlayerHitByVehicle

Syntax

bool isPlayerHitByVehicle(attacker)

Required Arguments

  • attacker : The element that attacks .

Code

function isPlayerHitByVehicle (attacker)
	if not attacker then
		return
	end
	if getElementType(attacker) == 'vehicle' then
		cancelEvent()
	end
end

Client

function isPlayerHitByVehicle (attacker)
	if not attacker then
		return
	end
	if getElementType(attacker) == 'vehicle' then
		cancelEvent()
	end
end
addEventHandler("onClientPlayerDamage", getLocalPlayer(), isPlayerHitByVehicle)

Server

function isPlayerHitByVehicle (attacker)
	if not attacker then
		return
	end
	if getElementType(attacker) == 'vehicle' then
		cancelEvent()
	end
end
addEventHandler("onPlayerDamage", root, isPlayerHitByVehicle)

Author

Lisek