View Full Version : [Share/Request] Anti-Pvp guard Lua
LJwow
05-15-2009, 09:27 PM
This is an Noob-Friendly script usable in Mixed mall's it will stop players form pvping,Attacking NPC's.
The entery is now on Bootybay Guard u can use the script on them and change HP-DMG in database or w8 till i add the SQL.
All Credits to me Before Fixes by other's dind work,
Thanks to Maroot Arcemu.org Forums for final Added fixing lines!
--Scripted by Lorre, Supporter Nightfall-WoW
--This script is still under development, This means it may not work yet.
local VERSION = "1.0"
local SERVER_NAME = "Nightfall-WoW" --Change to your server name
local GUARD_FEATURE = "Enabled" --[ Define wether the Guard is Enabled or Disabled. ]]
local NPC_ENTRYID = 4624
local type, pairs = type, pairs;
local function Death_Finger(pUnit, Player)
pUnit:FullCastSpellOnTarget(31984, Player) -- Change (5) to your spell <ID> 'Death touch may not work on all servers'.
end
--Do not edit below, Only if you know what your doing.
function Anti_Pvp_Guard_OnSpawn(pUnit, Event)
if (GUARD_FEATURE == "Enabled") then
pUnit:RegisterEvent("Check_PvP", 1200, 0)
end
end
function Check_PvP(pUnit, Event, Player)
local Player_W = pUnit:GetInRangePlayers()
if (Player_W ~= nil) and (type(Player_W) == "table") then
for index, player in pairs(Player_W) do
if (player:IsPlayerAttacking() == true) then
player:SendAreaTriggerMessage("PvP is not allowed in this area") --When some PvP in the not allowed area this messager will be send in Screen.
pUnit:RegisterEvent("Death_Finger", 1500, 4)
Death_Finger(pUnit, player)
end
end
end
end
RegisterUnitEvent(NPC_ENTRYID, 18, "Anti_Pvp_Guard_OnSpawn")
--Never edit Below this
print (" ================================================== ==")
print (" Loaded: Anti-Pvp-Guard (V"..VERSION..")")
print (" Made by Lorre")
print (" This script is Original released for Nightfall WoW")
print (" This script now works on: ("..SERVER_NAME..")")
print (" ================================================== ==")
Change log:
Added: change texst.
Changed: if (type(Player_W) == "userdata") then TO if Target ~= nil then
Added: Credit Print texst
Added: Enable and Dissable Function
Removed: Check If in combat Talk to NPC not needed.
Fixed script local type, pairs = type, pairs;
RakkorZ - ZxoxZ
05-15-2009, 09:35 PM
Very nice, and really clean script. I really like it.
+4 Rep from me. :)
Thanks,
Regards,
Zxoxz.
Wizard
05-15-2009, 09:46 PM
Nice script mate. Post would be a lot better if you make SQL of guard.
+Rep anyways.
-Domz
ogchaos
05-15-2009, 10:13 PM
Alliance Mall Guard:
function AllianceMallGuard_ArcaneExplosion (pUnit, Event)
pUnit:CastSpellOnTarget(29973, pUnit:GetRandomPlayer(0))
end
function AllianceMallGuard_Charge (pUnit, Event)
pUnit:CastSpellOnTarget(38907, pUnit:GetRandomPlayer(0))
end
function AllianceMallGuard_OnCombat (Unit, Event)
Unit:RegisterEvent ("AllianceMallGuard_ArcaneExplosion", 4000, 10)
Unit:SendChatMessage (12, 0, "You Came To The Wrong Place!")
end
function AllianceMallGuard_OnDied (Unit, Event)
Unit:RemoveEvents()
end
function AllianceMallGuard_OnKilledTarget (Unit, Event)
Unit:SendChatMessage (12, 0, "The Alliance Mall Is Safe Now!")
end
function AllianceMallGuard_OnLeaveCombat (Unit, Event)
Unit:SendChatMessage (12, 0, "Get Out Of The Alliance Mall!!")
Unit:RemoveEvents()
end
function AllianceMallGuard_OnReachWayPoint (Unit, Evnet)
Unit:RegisterEvent ("AllianceMallGuard_Charge", 1000, 1)
end
RegisterUnitEvent(600001, 1, "AllianceMallGuard_OnCombat")
RegisterUnitEvent(600001, 2, "AllianceMallGuard_OnLeaveCombat")
RegisterUnitEvent(600001, 3, "AllianceMallGuard_OnKilledTarget")
RegisterUnitEvent(600001, 4, "AllianceMallGuard_OnDied")
RegisterUnitEvent(600001, 8, "AllianceMallGuard_OnReachWayPoint")
Horde Mall guard:
function HordeMallGuard_ArcaneExplosion (pUnit, Event)
pUnit:CastSpellOnTarget(29973, pUnit:GetRandomPlayer(0))
end
function HordeMallGuard_Charge (pUnit, Event)
pUnit:CastSpellOnTarget(38907, pUnit:GetRandomPlayer(0))
end
function HordeMallGuard_OnCombat (Unit, Event)
Unit:RegisterEvent ("HordeMallGuard_ArcaneExplosion", 4000, 10)
Unit:SendChatMessage (12, 0, "You Came To The Wrong Place!")
end
function HordeMallGuard_OnDied (Unit, Event)
Unit:RemoveEvents()
end
function HordeMallGuard_OnKilledTarget (Unit, Event)
Unit:SendChatMessage (12, 0, "The Horde Mall Is Safe Now!")
end
function HordeMallGuard_OnLeaveCombat (Unit, Event)
Unit:SendChatMessage (12, 0, "Get Out Of The Horde Mall!!")
Unit:RemoveEvents()
end
function HordeMallGuard_OnReachWayPoint (Unit, Evnet)
Unit:RegisterEvent ("HordeMallGuard_Charge", 1000, 1)
end
RegisterUnitEvent(600002, 1, "HordeMallGuard_OnCombat")
RegisterUnitEvent(600002, 2, "HordeMallGuard_OnLeaveCombat")
RegisterUnitEvent(600002, 3, "HordeMallGuard_OnKilledTarget")
RegisterUnitEvent(600002, 4, "HordeMallGuard_OnDied")
RegisterUnitEvent(600002, 8, "HordeMallGuard_OnReachWayPoint")
SQL:
INSERT INTO `creature_names` VALUES ('600001', 'Alliance Mall Guard', 'Security', '0', '0', '0', '0', '4', '0', '0', '24991', '0', '0', '0', '1', '1', null, null);
INSERT INTO `creature_proto` VALUES ('600001', '200', '200', '1', '200000000', '200000000', '200000000', '0.8', '0', '10', '0', '200000000', '200000000', '0', '0', '0', '0', '300', '2000000000', '2000000000', '2000000000', '2000000000', '2000000000', '2000000000', '2000000000', '5', '25', '0', '1', '10000000', '0', '0', '5', '20', '25', '0', '0', '0', '0', '0', '0', '0');
INSERT INTO `creature_names` VALUES ('600002', 'Horde Mall Guard', 'Security', '0', '0', '0', '0', '4', '0', '0', '25337', '0', '0', '0', '1', '1', null, null);
INSERT INTO `creature_proto` VALUES ('600002', '200', '200', '2', '200000000', '200000000', '200000000', '0.8', '0', '10', '0', '200000000', '200000000', '0', '0', '0', '0', '300', '2000000000', '2000000000', '2000000000', '2000000000', '2000000000', '2000000000', '2000000000', '5', '25', '0', '1', '10000000', '0', '0', '5', '20', '25', '0', '0', '0', '0', '0', '0', '0');
Try this? Always worked well for me.
Alvanaar
05-15-2009, 10:22 PM
The script is not going to work :p: if (player:IsPlayerAttackin() == true) then
needs to be
if (player:IsPlayerAttacking() == true) then you missed the "g".
Also:
RegisterUnitEvent(311212, 2, "Anti_Pvp_Guard_OnSpawn")
should actually be RegisterUnitEvent(311212, 18, "Anti_Pvp_Guard_OnSpawn") for what you want it to do.
And also: pUnit:CastSpellOnTarget(5, Unit:GetMainTank(0))
should be: pUnit:CastSpellOnTarget(5, Unit:GetMainTank())
Also, this entire function won't work: function Check_PvP(pUnit, Event, Player)
Player_W = pUnit:GetRandomPlayer(0)
if (type(Player_W) == "userdata") then
if (pUnit:GetDistance(Player_W) <= MAX_RANGE*33) then
if (player:IsPlayerAttackin() == true) then
player:SendAreaTriggerMessage("PvP is not allowed in this area")
pUnit:RegisterEvent("Death_Touch", 1500, 0)
end
end
end
end
You have up the top of that function function Check_PvP(pUnit, Event, Player)
"Player" is in capitals, but then, below that, you have "player" in lowercase, I don't think that'll work.
I'm also curious why you used: if (type(Player_W) == "userdata") then
rather than: if Player_W ~= nil
Anyways, there is probably more problems with the code and stuff.
But, I like it, good work. :)
Alvanaar
LJwow
05-16-2009, 08:43 AM
Bump
Blyitgen
05-16-2009, 08:58 AM
i will use these as level road and global mall guards :O
Wizard
05-16-2009, 09:05 AM
Good, you have added SQL. And I will just re-edit mall guard/'s and use them as global guards.
Thanks,
-Domz
stoneharry
05-16-2009, 10:42 AM
you used unit not pUnit at parts + spell 5 can not be casted by npc's; wont work/do anything :p
LJwow
05-16-2009, 11:20 AM
Stoneharry:you used unit not pUnit at parts + spell 5 can not be casted by npc's; wont work/do anything
I added pUnits and made --Change Texst easy to understand and simple to change! ;)
Alvanaar
05-16-2009, 11:44 AM
So how should i add local Target = pUnit:GetTarget()
if Target ~= nil then
Pardon?
LJwow
05-16-2009, 11:47 AM
i meaned why :P
Alvanaar
05-16-2009, 12:05 PM
What is: if (type(Player_W) == "userdata") then
:S
?
(I know what Player_W is)
LJwow
05-16-2009, 12:09 PM
Well than il edit it ;) And Accept msn
Alvanaar
05-16-2009, 02:58 PM
Okie dokies. :)
LJwow
05-17-2009, 04:54 PM
B-ump
maxelocked
05-19-2009, 11:00 AM
alliance mall guard:
function alliancemallguard_arcaneexplosion (punit, event)
punit:castspellontarget(29973, punit:getrandomplayer(0))
end
function alliancemallguard_charge (punit, event)
punit:castspellontarget(38907, punit:getrandomplayer(0))
end
function alliancemallguard_oncombat (unit, event)
unit:registerevent ("alliancemallguard_arcaneexplosion", 4000, 10)
unit:sendchatmessage (12, 0, "you came to the wrong place!")
end
function alliancemallguard_ondied (unit, event)
unit:removeevents()
end
function alliancemallguard_onkilledtarget (unit, event)
unit:sendchatmessage (12, 0, "the alliance mall is safe now!")
end
function alliancemallguard_onleavecombat (unit, event)
unit:sendchatmessage (12, 0, "get out of the alliance mall!!")
unit:removeevents()
end
function alliancemallguard_onreachwaypoint (unit, evnet)
unit:registerevent ("alliancemallguard_charge", 1000, 1)
end
registerunitevent(600001, 1, "alliancemallguard_oncombat")
registerunitevent(600001, 2, "alliancemallguard_onleavecombat")
registerunitevent(600001, 3, "alliancemallguard_onkilledtarget")
registerunitevent(600001, 4, "alliancemallguard_ondied")
registerunitevent(600001, 8, "alliancemallguard_onreachwaypoint")
horde mall guard:
function hordemallguard_arcaneexplosion (punit, event)
punit:castspellontarget(29973, punit:getrandomplayer(0))
end
function hordemallguard_charge (punit, event)
punit:castspellontarget(38907, punit:getrandomplayer(0))
end
function hordemallguard_oncombat (unit, event)
unit:registerevent ("hordemallguard_arcaneexplosion", 4000, 10)
unit:sendchatmessage (12, 0, "you came to the wrong place!")
end
function hordemallguard_ondied (unit, event)
unit:removeevents()
end
function hordemallguard_onkilledtarget (unit, event)
unit:sendchatmessage (12, 0, "the horde mall is safe now!")
end
function hordemallguard_onleavecombat (unit, event)
unit:sendchatmessage (12, 0, "get out of the horde mall!!")
unit:removeevents()
end
function hordemallguard_onreachwaypoint (unit, evnet)
unit:registerevent ("hordemallguard_charge", 1000, 1)
end
registerunitevent(600002, 1, "hordemallguard_oncombat")
registerunitevent(600002, 2, "hordemallguard_onleavecombat")
registerunitevent(600002, 3, "hordemallguard_onkilledtarget")
registerunitevent(600002, 4, "hordemallguard_ondied")
registerunitevent(600002, 8, "hordemallguard_onreachwaypoint")
sql:
insert into `creature_names` values ('600001', 'alliance mall guard', 'security', '0', '0', '0', '0', '4', '0', '0', '24991', '0', '0', '0', '1', '1', null, null);
insert into `creature_proto` values ('600001', '200', '200', '1', '200000000', '200000000', '200000000', '0.8', '0', '10', '0', '200000000', '200000000', '0', '0', '0', '0', '300', '2000000000', '2000000000', '2000000000', '2000000000', '2000000000', '2000000000', '2000000000', '5', '25', '0', '1', '10000000', '0', '0', '5', '20', '25', '0', '0', '0', '0', '0', '0', '0');
insert into `creature_names` values ('600002', 'horde mall guard', 'security', '0', '0', '0', '0', '4', '0', '0', '25337', '0', '0', '0', '1', '1', null, null);
insert into `creature_proto` values ('600002', '200', '200', '2', '200000000', '200000000', '200000000', '0.8', '0', '10', '0', '200000000', '200000000', '0', '0', '0', '0', '300', '2000000000', '2000000000', '2000000000', '2000000000', '2000000000', '2000000000', '2000000000', '5', '25', '0', '1', '10000000', '0', '0', '5', '20', '25', '0', '0', '0', '0', '0', '0', '0');
try this? Always worked well for me.
dont work for a mix mall
LJwow
05-26-2009, 08:34 PM
BUMP working now
ogchaos
07-19-2009, 10:15 AM
Btw do you get attacked if you PVP with spells ?
You get attacked if your in combat.
ogchaos
07-24-2009, 12:45 PM
No you dont, This script only activates when you attack without spells ... Is there a way to change that?
sethekk82
07-30-2009, 12:21 AM
Bump
Still wondering if there's a way to add a function where if a player casts a spell on another target, they will be attacked.
ogchaos
07-30-2009, 08:40 AM
Yes there is,
:IsCasting() == true
But I don't know to insert it, Can someone do it and post ?
sethekk82
08-03-2009, 03:36 AM
Yea I have no clue either....
Bump
LJwow
09-17-2009, 03:59 PM
I have the script with the spell add also but i may not release it couse i made it for a paying costumer.
ogchaos
09-17-2009, 06:20 PM
Dude, Unless you stated that you wouldn't give it away or share or unless he has full coding rights you can share man .. lol
Fjerdue
10-09-2009, 10:14 AM
The NPC also kill the player in Player vs NPC battles :/
Anyway to change this?
Lbniese
10-25-2009, 07:44 AM
This scripts does so no one attacking, like alliance doesnt attack horde and horde doenst attack alliance?, or just stopping duels? or both :P
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.