I need some Lua help please. Great concept. menu

Shout-Out

User Tag List

Results 1 to 5 of 5
  1. #1
    TripZone's Avatar Active Member
    Reputation
    44
    Join Date
    Sep 2007
    Posts
    70
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I need some Lua help please. Great concept.

    Alright, I have great concept I want to code but I am having some problems.. The code I had earlier was a complete loss so I trashed it. All I need is an example on how to do it. Thanks +rep for help.

    I wan't to make a capture the flag game on my server. What I did is took the two WSG flags copied them in the database with a diff name and ID. But when I go to right click the flag it does not get picked up by the player... I have everything else for this game setup like NPC etc. This is what I need to finish it..

    A script that will allow the player to pickup the other teams flag and take it to there base when the flag is taken to the base the player who captured the flag and gets it to the bass gets an item.

    I need some Lua help please. Great concept.
  2. #2
    edded's Avatar Member
    Reputation
    5
    Join Date
    Jan 2008
    Posts
    41
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Um well im not sure about this but you can look in the DB for the real warsong flag and check out the type of go it is. then put that as your type that will propablly make it so you can pick it up. Then for retrieving im not sure if this will work but do like

    get x
    get y
    get z
    get map
    if map =3528359025
    if x = 8904375734
    if y = 378574985
    if z = 5487534897
    if player:haveflag()

    add score



    of course that wont work you gotta make if more formal split the teams and you gotta define player:haveflag() below that. Im not even sure it that will work

  3. #3
    Scubast3ve's Avatar Member
    Reputation
    55
    Join Date
    Apr 2009
    Posts
    125
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I want people to learn how to script for themselves so ill tell you this.

    You will need a couple of things:

    The spell id of the flag aura.
    Knowledge on how to script an item.

    two relevent commands are:
    RegisterGameObjectEvent(GameObjectsENTRYID, 2, "ScriptName")
    FullCastSpellOnTarget(SpellID, player)

    And it should work like this:
    you will begin with 4 objects, 2 bases, 2 flags. A player clicks a flag, the flag despawns and the player receives the flag carrier aura. Now the tricky part is dropping for an ondeath of a player now you will need each of the bases checking the location of the flag which means checking their is a player with the aura of a flag and updating that players co-ords then if there isnt a player then spawn a flag at the last known co-ords. or learn to prog cpp cause you cant hook player deaths in lua yet. Then getting to the base is simple cause you just need to check range and if the player has the aura. if both correspond to your arguments the flag will become captured.

    I hope you understand a little of this. And good luck
    Don't Forget To Give Rep To People Who Help You.

  4. #4
    Vision1000's Avatar Member
    Reputation
    104
    Join Date
    Jun 2008
    Posts
    122
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Idk if this is what your looking for, But i'd imagine this is the closest you could get to any kind of CTF game :S. I believe with this script it depends on the Viewdistance of that map in worldmap_info table of the area your going to be using. Anyway, I don't know if its much of a template to go off of, But here you go: (And no it hasn't been tested, just a general idea of what i'd think to do)

    Code:
    
    local intFlagDespawn_A = 0
    local intFlagDespawn_H = 0
    local A_SCORECOUNT = 0
    local H_SCORECOUNT = 0
    
    function H_Flag_OnUse(Unit, Event, player) -- Tells the check npc the following; If the flag was dropped, It stops the npc from returning the flag to the base, Tells the checknpc the flag is active, Sets the new Horde Flag carrier. Buffs the Flag carrier, Despawns the Goobject flag
    	H_FC = player
    	Unit:FullCastSpellOnTarget(HORDEWSGSPELL, H_FC)
    	Unit:RemoveFromWorld()
    	H_FC_ACTIVE = 1
    	H_FC_DROPPED = 0
    end
    
    function A_Flag_OnUse(Unit, Event, player)- Tells the check npc the following; If the flag was dropped, It stops the npc from returning the flag to the base, Tells the checknpc the flag is active, Sets the new Alliance Flag carrier. Buffs the Flag carrier, Despawns the Goobject flag
    	A_FC = player
    	Unit:FullCastSpellOnPlayer(WSGSPELL, A_FC) -- May need to do a little extra for this.
    	Unit:RemoveFromWorld()
    	A_FC_ACTIVE = 1
    	A_FC_DROPPED = 0
    end
    
    function AreaCheck_OnLoad(Unit, Event) -- Check npc
    	Unit:RegisterEvent("CheckDead_A", 500, 0)
    end
    
    function CheckDead_A(Unit, Event) -- Checks for various events; First and foremost, if the FC is in world(Incase they logged out/dcd or porter), If the flag is at its base, If the flag is active, it checks if the player has died Until the player caps it, or actually dies. Also checks if the flag is dropped, to start a 6second count down.
    	if (A_FC:IsInWorld() == false) then -- Not sure if this will work. Might have to check for MapID/distance (Incase someone grabbed the flag and logged out or ported)
    		Unit:SpawnGameobject(A_BASELOCATION)
    		A_FLAG_ATBASE = 1
    	elseif (A_FC_ACTIVE == 1) then
    		if (A_FC:IsDead() == true) then
    			local x = A_FC:GetX()
    			local y = A_FC:GetY()
    			local z = A_FC:GetZ()
    			Unit:SpawnGameobject(x,y,z,0)
    			A_FC_DROPPED = 1
    		end
    	else
    		if (A_FLAG_ATBASE == 1) then
    			A_FC_ACTIVE = 0
    		elseif (A_FC_DROPPED == 1) then
    			intFlagDespawn_A = intFlagDespawn_A + 1
    			if (intFlagDespawn_A == 12) then
    				A_FLAG:RemoveFromWorld()
    				Unit:SpawnGameobject(A_BASELOCATION)
    				intFlagDespawn = 0
    				A_FC_ACTIVE = 0
    				A_FLAG_ATBASE = 1
    			end
    		end
    	end
    
    	if (H_FC:IsInWorld() == false) then
    		Unit:SpawnGameobject(BASELOCATION)
    		H_FLAG_ATBASE = 1
    	elseif (H_FC_ACTIVE == 1) then
    		if (H_FC:IsDead() == true) then
    			local x=H_FC:GetX()
    			local y=H_FC:GetY()
    			local z=H_FC:GetZ()
    			Unit:SpawnGameobject(x,y,z,0)
    			A_FC_DROPPED = 1
    		end
    	else
    		if (H_FLAG_ATBASE == 1) then
    			A_FC_ACTIVE = 0
    		elseif (H_FC_DROPPED == 1) then
    			intFlagDespawn_H = intFlagDespawn_H + 1
    			if (intFlagDespawn_H == 12) then
    				H_FLAG:RemoveFromWorld()
    				Unit:SpawnGameobject(H_BASELOCATION)
    				H_FC_ACTIVE = 0
    				H_FLAG_ATBASE = 1
    			end
    		end
    	end
    end
    
    function FlagCaptureA_OnLoad(Unit, Event)
    	FLAGCAP_A = Unit
    	FLAGCAP_A:RegisterEvent("CheckForFC_A", 2000, 0) -- FLagcapture area npc's
    end
    
    function FlagCaptureH_OnLoad(Unit, Event)
    	FLAGCAP_H = Unit
    	FLAGCAP_H:RegisterEvent("CheckForFC_H", 2000, 0) -- ^^
    end
    
    function CheckForFC_H(Unit, Event) -- Checks to see The player is in range of a flag cap, If they are it will reset both flags, give the Horde a point. After 3 points, the horde win, you can give them all a prize and send a broadcast message to the players about who won ect ect
    local i
    local v
    	if (H_FC_ACTIVE == 1) then
    		if (Unit:GetDistance(H_FC) <= 25) then
    			H_SCORECOUNT = H_SCORECOUNT + 1
    			H_FC:RemoveAura(A_FLAGAURA)
    			H_FC_ACTIVE = 0
    			Unit:SpawnGameObject(H_BASELOCATION)
    				if (A_FC_ACTIVE = 1) then
    					H_FC:RemoveAura(A_WSGSPELL)
    					REFEREE:SpawnGameobject(ALLYBASE)
    					A_FC_ACTIVE = 0
    				end
    
    				if (H_SCORECOUNT == 3) then
    					local InRangePlayers = REFEREE:GetInRangePlayers()
    					for i, v in pairs(InRangePlayers) do
    						local race=v:GetPlayerRace()
    						if race==1 or race==3 or race==4 or race==7 or race==11 then
    							v:SendBroadcastMessage("|cFF32CD32 You have been defeated")
    							v:SendAreaTriggerMessage("|cFF32CD32 The Horde Win!")
    						else
    							v:SendBroadcastMessage("|cFFFF0000 You are victorious!")
    							v:SendAreaTriggerMessage("|cFFFF0000 The Horde Win!")
    							-- This could also be a time to have something like v:AddItem(item, quantity)
    						end 
    					end
    				end
    		end
    	end
    end
    
    
    function CheckForFC_A(Unit, Event)-- Checks to see The player is in range of a flag cap, If they are it will reset both flags, give the Alliance a point. After 3 points, the horde win, you can give them all a prize and send a broadcast message to the players about who won ect ect
    local i
    local v
    	if (A_FC_ACTIVE == 1) then
    		if (Unit:GetDistance(A_FC) <= 25) then
    			A_SCORECOUNT = A_SCORECOUNT + 1
    			A_FC:RemoveAura(FLAGAURA)
    			A_FC_ACTIVE = 0
    			Unit:SpawnGameObject(A_BASELOCATION)
    				if (H_FC_ACTIVE = 1) then
    					H_FC:RemoveAura(HORDEWSGSPELL)
    					REFEREE:SpawnGameobject(HORDEBASE)
    					H_FC_ACTIVE = 0
    				end
    
    				if (A_SCORECOUNT == 3) then
    					local InRangePlayers = REFEREE:GetInRangePlayers()
    					for i, v in pairs(InRangePlayers) do
    						local race=v:GetPlayerRace()
    						if race==1 or race==3 or race==4 or race==7 or race==11 then
    							v:SendBroadcastMessage("|cFF32CD32 You are victorious!")
    							v:SendAreaTriggerMessage("|cFF32CD32 The Alliance Win!")
    							-- This could also be a time to have something like v:AddItem(item, quantity)
    						else
    							v:SendBroadcastMessage("|cFFFF0000 You have been defeated")
    							v:SendAreaTriggerMessage("|cFFFF0000 The Alliance Win!")
    						end 
    					end
    				end
    		end
    	end
    end
    
    RegisterGameObjectEvent(GoID, 4, "A_Flag_OnUse") -- The flag itself.
    RegisterUnitEvent(NPCID, 18, "AreaCheck_OnLoad") -- Checks for generall flag events (Dropping, Picked up)
    RegisterUnitEvent(NPCID, 18, "FlagCaptureA_OnLoad") -- \_____Invisible Flag Cap Area NPC's (To detect if the flag carrier is within capping range only)
    RegisterUnitEvent(NPCID, 18, "FlagCaptureH_OnLoad") -- /
    
    Anyway i've probably forgot a few things in that script. But hopefully it will be enough to point you in the right direction.

    The lamest part of this script will probably be trying to figure out ways to prevent players from doing whatever they think up to try and bug out / mess up anything you make. ^_^

    o.0
    Last edited by Vision1000; 08-01-2009 at 02:00 PM.

  5. #5
    TripZone's Avatar Active Member
    Reputation
    44
    Join Date
    Sep 2007
    Posts
    70
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    THANK YOU!! + Rep Scuba Steve for giving me an idea on how it would work. + 2 rep Vision for going out of your way to actually provide a full script.

Similar Threads

  1. Making an addon, need some LUA help
    By gryphons53 in forum WoW UI, Macros and Talent Specs
    Replies: 1
    Last Post: 12-30-2009, 02:39 AM
  2. Need some LUA help!
    By grothar1993 in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 04-18-2009, 07:36 AM
  3. I need some Lua help,
    By Kiev in forum WoW EMU Questions & Requests
    Replies: 11
    Last Post: 12-24-2008, 04:19 PM
  4. i need some lua help please
    By runiker in forum World of Warcraft Emulator Servers
    Replies: 3
    Last Post: 02-29-2008, 07:49 AM
  5. I Need some IE help please!
    By Shadowman2418 in forum Community Chat
    Replies: 0
    Last Post: 07-10-2006, 09:02 PM
All times are GMT -5. The time now is 07:26 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