ArcAngeL Posted March 16, 2019 Share Posted March 16, 2019 (edited) 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 March 16, 2019 by ArcAngeL Link to comment
Moderators IIYAMA Posted March 16, 2019 Moderators Share Posted March 16, 2019 @ArcAngeL Changed root to localPlayer. addEventHandler ( "onClientPlayerDamage", localPlayer, function( attacker, weapon, bodypart ) And attacker exist + attacker isn't the same as the localPlayer. if attacker and attacker ~= localPlayer and getElementType(attacker) == "player" then Link to comment
ArcAngeL Posted March 16, 2019 Author Share Posted March 16, 2019 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 IIYAMA Posted March 16, 2019 Moderators Share Posted March 16, 2019 (edited) 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 March 16, 2019 by IIYAMA Link to comment
ArcAngeL Posted March 16, 2019 Author Share Posted March 16, 2019 3 minutes ago, IIYAMA said: Yea you can't, OBVIOUS!!!!!, because that is goal of your first iteration of YOUR code. \/ LOOOOOL still I CAN SHOT sorry for my bad Link to comment
Moderators IIYAMA Posted March 16, 2019 Moderators Share Posted March 16, 2019 Just now, ArcAngeL said: LOOOOOL still I CAN SHOT sorry for my bad show all files. Link to comment
ArcAngeL Posted March 16, 2019 Author Share Posted March 16, 2019 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 IIYAMA Posted March 16, 2019 Moderators Share Posted March 16, 2019 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
ArcAngeL Posted March 16, 2019 Author Share Posted March 16, 2019 1 minute ago, IIYAMA said: How can you start this without a meta.xml? Hey ı have meta <meta> <script src="disablepvp.lua" type="client"/> </meta> Link to comment
Moderators IIYAMA Posted March 16, 2019 Moderators Share Posted March 16, 2019 3 minutes ago, ArcAngeL said: Hey ı have meta <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
ArcAngeL Posted March 16, 2019 Author Share Posted March 16, 2019 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
Mr.Loki Posted March 16, 2019 Share Posted March 16, 2019 (edited) 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 March 16, 2019 by Mr.Loki additional note 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now