Jump to content

disable deathmatch in some cities


ArcAngeL

Recommended Posts

I want disable PvP in Las Venturas, San Fierro,Los Santos and ı created some codes.but when ı burn or fall, ı dont lose health.ı just want disable player vs. player(pvp).someone help me ?  what is my wrong ?

 

cities = {
["Los Santos"] = true,
["San Fierro"] = true,
["Las Venturas"] = true,
}


addEventHandler ( "onClientPlayerDamage", root,function( attacker, weapon, bodypart )
	local x,y,z = getElementPosition(localPlayer)
	local city = getZoneName(x,y,z, true)
	if cities[city] then
		if getElementType(attacker) == "player" then
			cancelEvent()
		end
	end	
end)

 

 

 

Edited by ArcAngeL
Link to comment

I changed but still ı cant shot my friend in los santos :/

cities = {
["Los Santos"] = true,
["San Fierro"] = true,
["Las Venturas"] = true,

}


addEventHandler ( "onClientPlayerDamage", localPlayer,
function( attacker, weapon, bodypart )
	local x,y,z = getElementPosition(localPlayer)
	local city = getZoneName(x,y,z, true)
	if cities[city] then
		if attacker and attacker ~= localPlayer and getElementType(attacker) == "player" then
			cancelEvent()
		end
	end	
end)

 

 

Link to comment
  • Moderators
27 minutes ago, ArcAngeL said:

I changed but still ı cant shot my friend in los santos :/

Yea you can't, OBVIOUS!!!!!, because that is goal of your first iteration of YOUR code. -_-

 

\/

1 hour ago, ArcAngeL said:

disable player vs. player(pvp)

Edited by IIYAMA
Link to comment

My all codes :

 

cities = {
["Los Santos"] = true,
["San Fierro"] = true,
["Las Venturas"] = true,

}


addEventHandler ( "onClientPlayerDamage", localPlayer,
function( attacker, weapon, bodypart )
	local x,y,z = getElementPosition(localPlayer)
	local city = getZoneName(x,y,z, true)
	if cities[city] then
		if attacker and attacker ~= localPlayer and getElementType(attacker) == "player" then
			cancelEvent()
		end
	end	
end)

 

Link to comment
  • Moderators
1 minute ago, ArcAngeL said:

My all codes :

 


cities = {
["Los Santos"] = true,
["San Fierro"] = true,
["Las Venturas"] = true,

}


addEventHandler ( "onClientPlayerDamage", localPlayer,
function( attacker, weapon, bodypart )
	local x,y,z = getElementPosition(localPlayer)
	local city = getZoneName(x,y,z, true)
	if cities[city] then
		if attacker and attacker ~= localPlayer and getElementType(attacker) == "player" then
			cancelEvent()
		end
	end	
end)

 

How can you start this without a meta.xml?

Link to comment
  • Moderators
3 minutes ago, ArcAngeL said:

Hey ı have meta xD 


<meta>
	<script src="disablepvp.lua" type="client"/>
</meta>

 

Good.

No visible issues here except for some missing resource information, which are not required to run code.

 

 

Now please debug your code

Use this tutorial:

 

 

Link to comment

its working with these codes but disabling all damage types.ı dont know what must ı do for just PvP damages.nvm topic can close :/

 

cities = {
["Los Santos"] = true,
["San Fierro"] = true,
["Las Venturas"] = true,
}


addEventHandler ( "onClientPlayerDamage", root,function( attacker, weapon, bodypart )
	local x,y,z = getElementPosition(localPlayer)
	local city = getZoneName(x,y,z, true)
	if cities[city] then
		if getElementType(attacker) == "player" then
			cancelEvent()
		end
	end	
end)

 

Link to comment

Removing the check that checks if the attacker is an element before checking if the attacker is a player will cause errors because taking fall damage will call this event which does not have an attacker.

 

Edit: It will work as intended but will leave your debug very messy.

Edited by Mr.Loki
additional note
  • Like 1
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...