[Guide] How to make Gameobject Traps menu

Shout-Out

User Tag List

Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    Spooky's Avatar Member
    Reputation
    3
    Join Date
    Jun 2006
    Posts
    4
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've looked over this script numerous times and have tried different possibilties. Unfortuntely when this script loads everything else is just fine, however when you try joining the server the console reports a "Access Violation" and I know it's due to the script because once I delete it from the script folder the server loads up fine.

    [Guide] How to make Gameobject Traps
  2. #17
    orco6's Avatar Member
    Reputation
    1
    Join Date
    Apr 2008
    Posts
    26
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol! downloaded a new repack! now here´s the error when i click the gameobject:

    scripts\zzztest.lua:3: attempt to call method ´Get X´ < a nil value>

    Any idea how to solve the problem? here´s the code again :

    function footmanarmy_OnUse(pUnit,event)

    local x = pUnit:GetX();
    local y = pUnit:GetY();
    local z = pUnit:GetZ();
    local o = pUnit:GetO();

    pUnit:SpawnCreature(17211, x , y , z, o, 80, 43200);
    end

    RegisterGameObjectEvent(1000084, 2, "footmanarmy_OnUse");

    My server load the script just fine, the only problem is the message im receiving now.
    Last edited by orco6; 09-19-2008 at 09:02 PM.

  3. #18
    stoneharry's Avatar Moderator Harry


    Reputation
    1618
    Join Date
    Sep 2007
    Posts
    4,564
    Thanks G/R
    151/150
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    ok, well i think the problam would be the fact that your trying to get coords on a gameobject, instead of just spawning at certain coords. I'm going to have a little search to see details on the gameobject commands on latest revs of Arcemu

    Also the original script (the one i said at first with exact coords) should work as i tested it on a lot of different revs with a "picnic" thing. I got the original idea from another script i saw which spawned some trolls when you tried to use a chest.

  4. #19
    orco6's Avatar Member
    Reputation
    1
    Join Date
    Apr 2008
    Posts
    26
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    LOL! FINALLY! I CAN REFERENCE THE UNIT SO THAT THE ´GET_´COMAND CAN GET THEIR COORDINATES! Thanks for all the help stoneharry, spooky and others im giving +rep for you all until i receive a message that i should wait 24h before giving +rep again lol! Here´s the code!:

    function Summoningchest_OnUse(pUnit,event,miscunit,misc)

    schest = 0;
    if schest == 0 then
    schest = miscunit:GetClosestPlayer();
    local x = miscunit:GetX();
    local y = miscunit:GetY();
    local z = miscunit:GetZ();
    local o = miscunit:GetO();

    miscunit:SpawnCreature(17211, x, y, z, o, 80, 43200);
    end
    end
    RegisterGameObjectEvent (1000084, 2, "Summoningchest_OnUse")

    IT WORKS! I CAN SPAWN A NPC CLICKING ON A GAMEOBJECT!(1000084 is its id in mysql, its type is 1 (button) and its name is Summoningchest and the number 2 in the code its because the "when" event is when the gameobject is used (right clicked)) LOL! i don´t know exactly how these pUnit, miscunit, misc works (when should i use them, but worked with miscunit) but now my script works perfectly, i click on the gameobject and it spawn a footman in my position. I´ve seen many scripts with this spawn comand but these prederminated coordinates wasn´t what i was looking for, i wanted a script to spawn when the gameobject is used but to summon whereever the player who cliked the gameobject is (if the gameobject is within range to be used) because i have a project to make buildings like warcraft3, people build using scripted items to summon gameobjects ( this is simple), and buy units clicking on gameobjects scripted to summon a unit for them if they have enough money and another scripted item to put these units under their control ( something like a mind control or a tame beast or enslave) i can´t say where they´ll build their barracks so i couldn´t make this with prederminated coordinates. LOL! i get the idea from another script for sapphiron. Here is its code:

    function Sapphiron_OnCombat(Unit, event)
    setvars(Unit,{
    Waterfall = nil,
    players = {},
    Sapphiron = {pUnit = Unit,GUID = Sapphiron:GetGUID()},
    IceBlock = nil,
    WingBuffet = nil,
    x = 0,
    y = 0,
    z = 0,
    radius = 0,
    radians = 0,
    summoncount = 0,
    clockwise = nil,
    FrostTrigger = nil})
    Unit:CastSpell(7940)
    Unit:SpawnGameObject(181225,3536.852783, -5159.951172, 143.636139,Unit:GetO(),0)
    Unit:RegisterEvent("Sapphiron_LifeDrain", 24000, 0)
    Unit:RegisterEvent("Chill", 15000, 0)
    Unit:RegisterEvent("Sapphiron_Cleave", 10000, 0)
    Unit:RegisterEvent("Sapphiron_Enrage", 900000, 0)
    Unit:RegisterEvent("Fly", 2000, 1)
    Unit:RegisterEvent("Sapphiron_FrostAura", 2000, 0)
    --TESTING AI TICK Unit:RegisterEvent("Sapphiron_CloseToDeath", 500, 0)
    end
    RegisterGameObjectEvent(181225, 2, "Close")

    function Close(Unit)
    print "working xd"
    local args = getvars(Unit)
    args.Waterfall = Unit
    setvars(Unit,args)
    Unit:SetUInt32Value(GAMEOBJECT_STATE,1)
    end
    RegisterUnitEvent(15989,7,"Sapphiron_CloseToDeath")

    function Sapphiron_CloseToDeath(Unit, event)
    print "works"
    if Unit:GetHealthPct() <= 10 then
    Unit:RemoveEvents()
    Unit:RegisterEvent("Sapphiron_FrostAura", 2000, 0)
    Unit:RegisterEvent("Sapphiron_LifeDrain", 24000, 0)
    Unit:RegisterEvent("Sapphiron_Blizzard", 15000, 0)
    Unit:RegisterEvent("Sapphiron_Cleave", 10000, 0)
    Unit:RegisterEvent("Sapphiron_Enrage", 900000, 0)
    end
    if(Unit:IsFlying() == true) then
    Sapphiron_LandAlt(Sapphiron,event)
    end
    end
    function Sapphiron_LandAlt(Unit, event)
    Unit:Land()
    Unit:MoveTo(Unit:GetX(),Unit:GetY(),Unit:GetZ()-10,Unit:GetO())
    Unit:RegisterEvent("Sapphiron_Normal", 8000, 1)
    end

    function Chill(Unit,event)
    local args = getvars(Unit)
    if math.random(0,1) < 0.5 then
    args.clockwise = true
    else
    args.clockwise = false
    end
    local plr = Unit:GetRandomPlayer(0)
    local newx,newy,newz,o = plr:GetX(),plr:GetY(),plr:GetZ(),Unit:GetO()
    local newradius = Unit:CalcDistance(x,y,z)
    --[[ This will overwrite the Units globals destroying all previous entries.
    You must define these first in the 'args' class before setting them.
    The only exception to this is when you first define your starting variables
    in your Unit's onCombat or onSpawn events, or if you want to destroy all previous entries?
    setvars(Unit,{x = newx,y = newy, z = newz,radius = newradius}) ]]
    -- Define new variables
    args.newx = x;
    args.newy = y;
    args.newz = z;
    args.newradius = radius;
    -- Then save them
    setvars(Unit, args);

    Unit:SpawnCreature(16082,args.x,args.y,args.z,o,Unit:GetFaction(),15000)
    if args.summoncount <= 20 then
    Unit:RegisterEvent("Circle",2000, 0)
    else
    --[[ same with here;
    setvars(Unit,{summoncount= 0,x = 0,y = 0, z = 0, radians = 0,radius = 0}) ]]
    args.summoncount = 0;
    args.x = 0;
    args.y = 0;
    args.z = 0;
    args.radians = 0;
    args.radius = 0;
    -- save them.
    setvars(Unit, args);
    end
    end
    function Circle(Unit,event)
    local args = getvars(Unit)
    if (args.clockwise == true) then
    newradians = args.radians+0.314159
    elseif (args.clockwise == false) then
    newradians = args.radians-0.314159
    end
    local newsummoncount = args.summoncount + 1
    local newx = math.cos(radians)+args.radius
    local newy = math.sin(radians)+args.radius
    --setvars(Unit,{x = newx,y = newy, summoncount = newsummoncount, radians = newradians})
    args.x = newx;
    args.y = newy;
    args.summoncount = newsummoncount;
    args.radians = newradians;
    -- save them
    setvars(Unit, args);
    Unit:SpawnCreature(16082,args.x,args.y,args.z,args,Unit:GetO(),15000)
    end

    RegisterUnitEvent(16082,5,"ChillTrigger")
    function ChillTrigger(Trigger,event)
    print "Yes OnSpawn for Creature works xD"
    local args = getvars(Unit)
    Trigger:SetNameById(args.Sapphiron.pUnit:GetEntry())
    Trigger:SetUInt32Value(UNIT_FIELD_FLAGS,UNIT_FLAG_NOT_SELECTABLE)
    Trigger:SetUInt32Value(UNIT_FIELD_FLAGS,UNIT_FLAG_NOT_ATTACKABLE_2)
    Trigger:SetCombatMeleeCapable(1)
    Trigger:Root()
    Trigger:CastSpell(28547)
    end

    function Icebolt(Unit, event)
    local plr = Unit:GetRandomPlayer(0)
    if (plr~= nil) then
    Unit:FullCastSpellOnTarget(28522,plr)
    Unit:RegisterEvent("ImmunityCheck", 100,1 )
    end
    end

    function Sapphiron_FrostAura(Unit)
    Unit:CastSpell(28531)
    end

    function Sapphiron_LifeDrain(Unit, event)
    local tank = Unit:GetMainTank()
    if tank~= nil then
    Unit:FullCastSpellOnTarget(28542,tank)
    end
    end

    function Sapphiron_Cleave(Unit, event)
    if (Unit:GetMainTank() ~= nil) then
    Unit:CastSpellOnTarget(31345, Unit:GetMainTank())
    else
    end
    end

    function Sapphiron_Enrage(Unit)
    Unit:CastSpell(26662)
    end

    function Fly(Unit, event)
    print "Fly intitiated"
    Unit:RemoveEvents()
    Unit:SetCombatMeleeCapable(1)
    Unit:SetUInt32Value(UNIT_FIELD_FLAGS,UNIT_FLAG_NOT_ATTACKABLE_9)
    Unit:MoveTo(Unit:GetSpawnX(),Unit:GetSpawnY(),Unit:GetSpawnZ(),Unit:GetSpawnO())
    Unit:RegisterEvent("Fly2", 500, 1)
    end

    function Fly2(Unit,event)
    print "Fly2 intitiated"
    if Unit:IsCreatureMoving() == false then
    Unit:SetFlying()
    Unit:RegisterEvent("Fly3", 2000, 1)
    else
    Unit:RegisterEvent("Fly2", 500, 1)
    end
    end

    function Fly3(Unit, event)
    print "Fly3 intitiated"
    Unit:MoveTo(Unit:GetX(),Unit:GetY(),Unit:GetZ()+10,Unit:GetO())
    Unit:RegisterEvent("Fly4", 1000, 1)
    end

    function Fly4(Unit,event)
    print "Fly4 intitiated"
    if Unit:IsCreatureMoving() == false then
    Unit:SpawnCreature(17025,Unit:GetSpawnX(),Unit:GetSpawnY(),Unit:GetSpawnZ(),Unit :GetSpawnO(),Unit:GetFaction(),0)
    Unit:RegisterEvent("Icebolt", 2000, 5)
    Unit:RegisterEvent("Sapphiron_CastFrostBreath", 10000, 1)
    else
    Unit:RegisterEvent("Fly4",1000, 1)
    end
    end

    RegisterUnitEvent(17025,5,"WingBuffet")

    function WingBuffet(Unit,event)
    print "WingBuffet initiated"
    local args = getvars(Unit)
    args.WingBuffet = Unit
    setvars(Unit,args)
    Unit:SetUInt32Value(UNIT_FIELD_FLAGS,UNIT_FLAG_NOT_SELECTABLE)
    Unit:SetUInt32Value(UNIT_FIELD_FLAGS,UNIT_FLAG_NOT_ATTACKABLE_2)
    Unit:CastSpell(2932
    end

    function ImmunityCheck(Unit,event)
    local args = getvars(Unit)
    local tbl = Unit:GetInRangePlayers()
    for k,v in pairs(tbl) do
    if v:HasAura(28522) == true then
    args.Sapphiron.pUnit:FullCastSpellOnTarget(7940,v)
    args.IceBlock = Unit:SpawnGameObject(181247,v:GetX(),v:GetY(),v:GetZ(),v:GetO(),25000)
    setvars(Unit,args)
    end
    end
    --setvars(Unit,args); should be in the for loop to avoid unnecessary work
    end

    RegisterGameObjectEvent(181247,2,"LoS")
    function LoS(Unit,event)
    print "OnSpawn works"
    local args = getvars(Unit)
    for k,v in pairs(args) do print (k,v)
    end
    -- or -- table.foreach(args, print) - works the same as above just neater.
    local tbl = Unit:GetInRangePlayers()
    for k,v in pairs(tbl) do
    print (k,v)
    if Unit:IsInFront(v) then
    local say = " is behind iceblock."
    Unit:SendChatMessage(12,0,v:GetName()..say)
    Unit:CastSpell(7940,v)
    end
    end
    end


    function Sapphiron_CastFrostBreath(Unit, event)
    Unit:SendChatMessage(16, 0, "Sapphiron takes a deep breath...")
    Unit:RemoveEvents()
    Unit:SpawnCreature(15624,Unit:GetX(),Unit:GetY(),Unit:GetZ(),Unit:GetO(),Unit:Ge tFaction(),0)
    Unit:RegisterEvent("Sapphiron_Land", 8000, 1)
    end
    ---------------FROST BREATH DUMMY TRIGGER----------------
    RegisterUnitEvent(15624,5,"Trigger")
    function Trigger(Unit,event)
    local args = getvars(Unit)
    args.FrostTrigger = Unit
    setvars(Unit,args)
    Unit:EnableMoveFly(1)
    Unit:SetUInt32Value(UNIT_FLAG_NOT_SELECTABLE)
    Unit:SetUInt32Value(UNIT_FLAG_NOT_ATTACKABLE_2)
    Unit:SetMoveRunFlag(0)
    Unit:MoveTo(args.Sapphiron.pUnit:GetSpawnX(),args.Sapphiron.pUnit:GetSpawnY(),ar gs.Sapphiron.pUnit:GetSpawnZ(),args.Sapphiron.pUnit:GetSpawnO())
    Unit:RegisterEvent("TriggerStopped", 1000, 1)
    end

    function TriggerStopped(Unit,event)
    print "TriggerStopped initiated"
    if(Unit:IsCreatureMoving() == false) then
    Unit:FullCastSpell(2931
    Unit:RemoveFromWorld()
    else
    Unit:RegisterEvent("TriggerStopped",500,1)
    end
    end
    ----------------------------------------------------------------------------

    function Sapphiron_Land(Unit, event)
    local tbl = Unit:GetInRangeObjects()
    local tbl2 = Unit:GetInRangePlayers()
    for k,v in pairs(tbl) do
    if v:GetEntry() == 181247 then
    v:RemoveFromWorld()
    end
    end
    for k,v in pairs(tbl2) do
    if v:HasAura(7940) == true then
    v:RemoveAura(7940)
    end
    if v:HasAura(28522) == true then
    v:Remove(28522)
    end
    end
    Unit:Land()
    Unit:SetCombatMeleeCapable(1)
    Unit:MoveTo(Unit:GetX(),Unit:GetY(),Unit:GetZ()-10,Unit:GetO())
    Unit:RegisterEvent("Sapphiron_Normal", 3000, 1)
    end

    function Sapphiron_Normal(Unit, event)
    Unit:SetCombatMeleeCapable(0)
    Unit:GetMainTank()
    Unit:RegisterEvent("Sapphiron_Fly", 67000, 0)
    Unit:RegisterEvent("Sapphiron_FrostImmune", 0, 0)
    Unit:RegisterEvent("Sapphiron_FrostAura", 2000, 0)
    Unit:RegisterEvent("Sapphiron_LifeDrain", 24000, 0)
    --Unit:RegisterEvent("Sapphiron_Blizzard", 15000, 0)
    Unit:RegisterEvent("Sapphiron_Cleave", 10000, 0)
    Unit:RegisterEvent("Sapphiron_Enrage", 900000, 0)
    end

    function Sapphiron_OnLeaveCombat(Unit)
    local args = getvars(Unit)
    if args.Waterfall ~= nil then
    args.Waterfall:SetUInt32Value(GAMEOBJECT_STATE,0)
    end
    setvars(Unit,true)
    --collectgarbage(); No longer needed as setvars will take care of garbage collection now.
    Unit:RemoveEvents()
    end

    function Sapphiron_OnDied(Unit)
    Unit:CastSpell(29357)
    local args = getvars(Unit)
    if args.Waterfall ~= nil then
    args.Waterfall:SetUInt32Value(GAMEOBJECT_STATE,0)
    end
    --setvars(Unit,true) this will be taken care of in the OnLeaveCombat so no need to do it twice.
    end


    RegisterUnitEvent(15989, 1, "Sapphiron_OnCombat")
    RegisterUnitEvent(15989, 2, "Sapphiron_OnLeaveCombat")
    RegisterUnitEvent(15989, 4, "Sapphiron_OnDied")
    Last edited by orco6; 09-20-2008 at 12:21 PM.

  5. #20
    stoneharry's Avatar Moderator Harry


    Reputation
    1618
    Join Date
    Sep 2007
    Posts
    4,564
    Thanks G/R
    151/150
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Nice one But you could have wrapped them in code tags

Page 2 of 2 FirstFirst 12

Similar Threads

  1. [Guide] How to make any Race be any Class and play it
    By Illidan1 in forum WoW EMU Guides & Tutorials
    Replies: 51
    Last Post: 03-19-2008, 08:32 PM
  2. [Guide] How to make a account creation page! Very easy!! (Hamachi)
    By rfvtgbyhn in forum WoW EMU Guides & Tutorials
    Replies: 1
    Last Post: 11-02-2007, 05:25 PM
  3. [Guide]How to make your Server 2.2.0 !
    By Guysus in forum WoW EMU Guides & Tutorials
    Replies: 17
    Last Post: 10-02-2007, 05:10 PM
  4. Guide how to make TWINK PRIEST
    By Croat in forum World of Warcraft Guides
    Replies: 8
    Last Post: 04-29-2007, 08:18 AM
  5. *Guide* How to make a movie
    By djmazi in forum World of Warcraft Guides
    Replies: 5
    Last Post: 12-22-2006, 09:15 PM
All times are GMT -5. The time now is 10:23 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search