• How to I setup a PVP and Non-PVP mode type system to prevent killing
    5 replies, posted
How to I setup a PVP and Non-PVP mode type system to prevent killing when others don't want to fight. Like a command where you do pvp for pvp mode and peace for a peace mode. Also a way to make it so people in "peace mode" cant get killed from people in "pvp mode". Are there any lua tutorials that could help with this, thanks!
There is a plugin called SafeZones I think which does what you wants but in certain areas.
GM:ScalePlayerDamage should work, just check if the player qualifies as non-pvp and scale the damage by 0.
[lua]hook.Add("PlayerInitialSpawn", "pvpSetup", function(ply) ply:SetNWBool("pvpEnabled", false); -- you can simply use "ply.pvpEnabled = false" if you only need it serverside end); hook.Add("EntityTakeDamage", "pvpHandleDamage", function(ply, dmg) if (IsValid(ply) and ply:IsPlayer() and ply:GetNWBool("pvpEnabled")) then -- you can add additional checks here if you don't want to disable all damage dmginfo:ScaleDamage(0); end end);[/lua] It should work without any changes if you add a way to toggle it on/off, and you can get whether it's enabled on the client the same way as on the server. [editline]8th June 2016[/editline] Ninja'd, but his doesn't provide a working example and ScalePlayerDamage doesn't work for all damage as it says on the wiki.
I thought he just wanted it for pvp damage, my bad.
[QUOTE=RonanZer0;50480004][lua]hook.Add("PlayerInitialSpawn", "pvpSetup", function(ply) ply:SetNWBool("pvpEnabled", false); -- you can simply use "ply.pvpEnabled = false" if you only need it serverside end); hook.Add("EntityTakeDamage", "pvpHandleDamage", function(ply, dmg) if (IsValid(ply) and ply:IsPlayer() and ply:GetNWBool("pvpEnabled")) then -- you can add additional checks here if you don't want to disable all damage dmginfo:ScaleDamage(0); end end);[/lua] It should work without any changes if you add a way to toggle it on/off, and you can get whether it's enabled on the client the same way as on the server. [editline]8th June 2016[/editline] Ninja'd, but his doesn't provide a working example and ScalePlayerDamage doesn't work for all damage as it says on the wiki.[/QUOTE] Thanks!
Sorry, you need to Log In to post a reply to this thread.