PDA

View Full Version : [Guide] How to make a lua teleporter



Djfrederick
20-01-09, 10:08 AM
How to make a Lua Teleporter by djfrederick :)

First of all, i haven't seen this guide by searching or looking backwards in posts.

Lua scripting is pretty easy. Lua is a functional programming language used to do alot of things. I want you to take a look at this list if you look down.

This is the hold ''Lua scripting list'' with all the differend commands. It could be a good idea to save the list, to next time you wanner make a lua script:


.:GOSSIP STUFF:.
:GossipCreateMenu -- I have
:GossipMenuAddItem -- no clue
:GossipSendMenu --on how to work
:GossipComplete --with
:GossipSendPOI -- gossip. Go to http://luaplusplus.org/forum/index.php?page=Thread&threadID=29 for tut.
.:GET STUFF:.
:GetMainTank() --Returns main tank.
:GetAddTank() --Returns offtank.
:GetX() --Gets unit's X cordinate.
:GetY() --Gets unit's Y cordinate.
:GetZ() --Gets unit's Z cordinate.
:GetO() --Gets unit's O cordinate.
:GetTauntedBy() --Gets the target the unit was taunted by.
:GetSoulLinkedWith() --Gets the unit that it is soullinked with.
:GetItemCount(xxxx) -- Get the amount of "xxxx" items in the player's inventory. Replace the XXXX with the itemid.
:GetName() --Gets the name of the unit.
:GetHealthPct() --Gets the health percent of the unit.
:GetManaPct() --Gets the mana percent of the unit.
:GetInstanceID() --Gets the instance id of the unit(if in an instance)
:GetClosestPlayer() --Gets the closest player.
:GetSpellId(spellid) -- This returns the spell as unit(planned for spell editing).
:GetRandomPlayer(flag)
RANDOM_ANY = 0,
RANDOM_IN_SHORTRANGE = 1,
RANDOM_IN_MIDRANGE = 2,
RANDOM_IN_LONGRANGE = 3,
RANDOM_WITH_MANA = 4,
RANDOM_WITH_RAGE = 5,
RANDOM_WITH_ENERGY = 6,
RANDOM_NOT_MAINTANK= 7
:GetRandomFriend() --Gets a random friend(friendly to the unit)
:GetUnitBySqlId(sqlid) -- use this to return a unit BY SQL ID. .go info or .npc info can provide u w/ sql id
:GetUnitByGUID(guid) -- This returns a unit that has that guid.
:GetPlayerClass() --Gets the player's class, will return in number form.
:GetHealth() --Gets the unit's health, returns the exact health
:GetMaxHealth() --Gets the unit's max health.
:GetCreatureNearestCoords() -- similar to getgameobjectnearestcoords but for creatures.
:GetCreatureGuid() -- absolete
:GetGameObjectGuid() -- absolete
:GetPlayerCountInRadius() -- this will lagg the client when called, don't use it, use GetInRangePlayerCount() instead.
:GetGameObjectNearestCoords(x,y,z,gameobjectid) -- This returns the GO as a unit if it is found.
Usage:
local door = Unit:GetGameObjectNearestCoords(x,y,z,doorid)
if door ~= nil then
door:SetUInt32Value(GAMEOBJECT_STATE,1) -- close the door
end
:GetDistance(target) -- use this to check the distance from this unit to the target specified, it does not scale to yards.
:GetGUID() -- returns a uint64 guid number that is unique to every player/creature/go/(item?).
:GetZoneId() -- returns the zone id that the unit is currently in.
:GetMaxMana() -- This returns the maximum mana the unit CAN have.
:GetMana() -- This returns the exact mana the unit has. Use this w/ getpowertype to check if the unit as mana to begin with.
:GetCurrentSpellId() -- if a unit is casting a spell, this will return the spellid of the spell that is unit is casting.
:GetInstanceID() -- returns the instance id number if the unit/player/go is in an instance.
:GetSpawnX() -- returns the x spawn point coord.
:GetSpawnY() -- " " y " ".
:GetSpawnZ() -- " " z " ".
:GetSpawnO() -- " " o " ".
:GetInRangePlayersCount() -- if the unit has inrangeplayers, this will return how many of those players are there.
:GetAIState() -- returns the ai state that the unit is in, in number form.
:GetAITargets() -- this will return a table containing a list of targets that the unit has(threat table);
:GetInRangeObjects() -- returns a table containing a list of inrange gameobjects.
:GetInRangeObjectCount() -- returns the number of gameobjects near the unit/go/player.
:GetAITargetsCount() -- self explainatory.
:GetPowerType() -- this returns the power type IN STRING FORM,"Health", "Mana", "Rage", etc.
:GetInRangeFriends() -- Use this to return units that are friendly to the unit. It returns in a table.
:GetPlayerLevel() -- Don't have to explain this one.
:GetStealthLevel() -- This returns the stealth points the unit has if any.
:GetFaction() -- returns the faction number.
:GetNextTarget() -- returns current target?
:GetUInt32Value(field) -- check core to see how they are used.
:GetUInt64Value(field) -- check core to see how they are used.
:GetMapId() -- returns mapid.
.:BOOLS(Is? commands):.
:IsPlayer() -- same as IsCreature but for players instead, use to check if the current unit is a player.
:IsCreature() -- if the current unit it is called on is a creature, it returns true/false if its not.
:IsInCombat() returns true/false if the unit is in combat/not in combat.
:IsCasting() -- if unit is casting a spell it returns true/false if the unit is not.(Maybe be not functional)
:IsAlive() -- reverse of isdead(), returns true if the unit is alive/false if the unit is dead.
:IsDead() -- is dead check. If the unit is dead, it will return true/false if its not.
:IsInWorld() -- kind of a safe check to see if the current unit exists in the world, returns true/false
:IsPlayerMoving() -- this is for players, returns true/false if the player is moving/not moving
:IsCreatureMoving() -- same but for creatures, returns true/false if creature is moving/notmoving
:IsInFront(target) -- it returns true/false if the current unit is in front of the target specified.
:IsInBack(target) -- explainatory.
:IsPacified() -- if unit is pacified true/false if not.
:IsInWater() -- for players only, checks if the player is in water.
:NoRespawn() -- set to 1 to disable respawn, 0 to allow respawning, for creatures only.
:IsStealthed() -- If unit is stealthed, true/false if not.
:IsPlayerAttacking() -- true/false if player is attacking, player only command.
.:OTHERS:.
:SendChatMessage(type,language,message) -- Type is the chat type e.g. Say,Yell,RaidWarning, chat.h has a list of them; language is pretty obvious.
Usage:
function SayThis(Unit,event)
local plr = Unit:GetMainTank()
if plr ~= nil then
Unit:SendChatMessage(14(yell),0(Universal lang),plr:GetName()..", you cannot resist me!")
end
end
:MoveTo(x,y,z,o) -- pretty self explainatory. Use .gps while ingame to retrieve coords, O is just orientation.
Usage:
function MoveTo(Unit,event)
Unit:MoveTo(Unit:GetSpawnX(),Unit:GetSpawnY(),Unit :GetSpawnZ(),Unit:GetSpawnO()) -- makes the unit move to its spawn points.
end
:CastSpell(spellid) -- Just fill in the spell id which you want to the current unit to cast. This will cast the spell on caller of this function and ignore cast time.
Usage:
function CastSpell(Unit,event)
Unit:CastSpell(5) -- death touch xd
end
:CastSpellOnTarget(spellid,target) -- first blank is spellid just like above, 2nd is target, there is a bug w/ this function that it causes it not to cast on the target.
Use FullCastSpellOnTarget(spellid,target) if you want to cast on a target.
:FullCastSpell(spellid) -- This does the same as castspell except with casttime.
:FullCastSpellOnTarget -- Fully casts the spell with cast time but on a target(if target is the unit, just use castspell or fullcastspell)
:SpawnGameObject(entry_id,x,y,z,duration)-- spawns a gameobject from the entry id given at the location vector given
Usage:
Unit:SpawnGameObject(166434(random no.),Unit:GetX(),Unit:GetY(),Unit:GetZ(),0(0 duration to make the go not despawn. Add duration in milisecs to make it despawn after x seconds))
:SpawnCreature(entryid,x,y,z,faction,duration) -- Unlike spawngameobject, creatures use factions. This decides whether they are friendly/hated towards the player and other stuff like if you kill it what rep u get.
Usage:
Unit:SpawnCreature(randomnumberhere,Unit:GetX(),Un it:GetY(),Unit:GetZ(),14,5000(despawn after 5 secs))
:RegisterEvent(string,delay,repeats) -- registers a function to call on the unit, note that only creatures can use this, not gameobjects.
Usage:
Unit:RegisterEvent("KillYou",5000, 1)
whereas
function KillYou(Unit,event)
Unit:FullCastSpellOnTarget(5,Unit:GetRandomPlayer( 0))
end
:RemoveEvents() -- this has no arguments and removes all registered functions.
Usage:
function OnCreatureDied(Unit,event)
Unit:RemoveEvents()-- when the creature is dead, remove all functions so it doesn't do anything.
end
:SendBroadcastMessage(string) -- this is a player only command. The player who called it, displays a message that you typed in there
Usage:
function Error(Unit,event)
local tank = Unit:GetMainTank()
tank:SendBroadCastMessage("You are now tanking "..Unit:GetName())
end
:SendAreaTriggerMessage(stringfunc) I have never used this and don't know its effects.
:KnockBack() -- neither this.
:MarkQuestObjectiveAsComplete(questid,objective) -- Never used this.
:LearnSpell(spellid) -- This is a player only command, it teaches the player unit that it is called on the spellid
Usage:
local plr = Unit:GetClosestPlayer()
plr:LearnSpell(5) -- learn death touch xd
:UnlearnSpell(spellid) -- This just removes a spell already known from the player.
Usage
local plr = Unit:GetClosestPlayer()
plr:UnlearnSpell(5) -- noooes gief death touch!!
:HasFinishedQuest(questid)-- this is a boolean like others to come. It checks whether the player has finished the quest provided w/ the id, if not, it pushes false.
Usage:
local plr = Unit:GetClosestPlayer()
if plr:HasFinishedQuest(questid) == true then
do this if the player has completed the quest
end
:ClearThreatList() -- this maybe confused to wipethreatlist. What it does is set all threat levels to 1, This means the creature will still aggro, but aggro can be easily taken away.
:ChangeTarget(target) -- This causes the Unit to change the target, it is basically SetNextTarget(target).
:Emote(emoteid) -- Use this to get the unit to do a certain emote.
:Despawn(delay,respawn)-- Note this is a creature only one, if you filled the first blank, it will delay the alloted time filled before despawning, if you filled second, it will respawn the unit after the alloted time.
:PlaySoundToSet(soundid) -- Look in soundentries.dbc for various sounds to play. .playall(soundid) can come in handy to differenciate.
:RemoveAura(spellid) -- If a spell has an aura, this will remove that aura.
Usage:
Unit:RemoveAura(41431) -- noes, gief bubble plis
:StopMovement(delaytime) -- This will make the unit stop moving for the time specified. A creature only command.
:AddItem(itemid) -- This is a player only command, use it to add an item to a players inventory.
:RemoveItem(itemid) -- Use to take a way and item from a players invent.
:CreateCustomWaypointMap() -- This creates a custom waypoint map, whether u call this or not, createwaypoint will create one automatically.
:CreateWaypoint(x,y,z,waittime,moveflags,displayid ) -- x,y,z are the coords, waittime is the delay for it to not move,moveflags are either 0 for walk, 256 for run, or 768 for fly, displayid is how you want the waypoints to look like(Like mini models).
:DestroyCustomWaypointMap() -- use it to destroy all waypoints that the unit has. Only works for creatures.
:MoveToWaypoint(waypointid) -- When you create ur first waypoint, they are numberd in order start from 1. 0 and 1 do the same thing. Use it to make a unit move to various waypoints.
:TeleportUnit(mapid,x,y,z) -- This teleport's a PLAYER only unit to the location specified.
:ClearHateList() -- this is a duplicate of ClearThreatList(). They do the same thing.
:WipeHateList() -- This removes ALL Threat off the mob, this will cause the mob to leavecombat and return to spawn.
:WipeTargetList() -- This just does the same as WipeHateList(), causes the mob to reset.
:WipeCurrentTarget() -- This will cause the unit to disengaged the current player and target a new.
:CastSpellAoF(x,y,z,spellid) -- This is for aoe spell types. Currently bugged since the spell does no dmg.
:RemoveAllAuras() -- removes ALL auras, positive or negative on the current unit.
:StopChannel() -- If the unit is channeling a spell, it stops it.
:ChannelSpell(guid,spellid) -- Use this to make a unit channel, guid is the target's guid u wish and spellid is the spell u want to channel.
Usage:
local plr = Unit:GetRandomPlayer()
if plr ~= nil then
Unit:ChannelSpell(plr:GetGUID(),spellid) -- channel a certain spell on the player.
end
:ReturnToSpawnPoint() -- makes a unit go back to its spawn point.
:HasAura(auraid) -- this is a boolean, returns true if the unit has the auraid given, or false if not.
:Land() -- Use this to land units that are already flying.
:CancelSpell() -- This cancels the units current spell?
:AdvanceSkill(skillid,amounttoincrement) -- use it the same way u use gm command.
:AddSkill(skillid) -- use to add a skill to player if the player doesn't already have it.
:RemoveSkill(skillid) -- explainatory.
:PlaySpellVisual(guid,spellid) -- doesn't seem to work.
:RemoveThreatByPtr(target) -- Removes all threat if any, on the current target specified
:EventCastSpell(target,sp,delay,repeats) -- this casts a spell over and over on the target specified, delay is amount to wait before recasting, repeats is how many times.
:AttackReaction(target,dmg,spell) -- This creates fake threat towards the unit specified
Usage:
local plr = Unit:GetRandomPlayer(0)
Unit:AttackReaction(plr, 1, 0) -- If the unit doesn't have any aggro, it will now aggro this player.
:Root() -- this unlike stopmovement(), disables all movement.
:Unroot() -- allows movement again.
:Heal(target,spellid,amount) -- The current unit heals the target specified for the amount and spell id.
:Energize(target,spellid,amount,type) -- Restore mana/rage/focus/hp?
:Strike(target,dmg,sp,adddmg,exclusivedmg,pct_dmg_ mod) -- I dono xD
:Kill(target) -- this pretty much calls a dealdamage that deals damage equivalent to the Units hp.
:DealDamage(target,damage,spellid) -- Use this to deal modified dmg to the target specified.
:RessurectPlayer() -- player only command, rez the player!
:RemoveFromWorld() -- use this for both creatures/gos to remove that unit from the world.
:ModThreat(target, amount) -- modifies threat of the target, if any, to the amount specified.
:AddAssitTarget(target) -- Use this in conjunction w/ onassisttarget died event to call stuff.
:RemoveAurasByMechanic(mechanicid,hostileonly) -- This removes all auras depending on what mechanic,(sleep,fear,etc), hostileonly is a bool, put 1 to remove only hostile auras, 0 for all pos and nega auras
:RemoveStealth() -- if the unit is in stealth, it removes it from stealth.
:RegisterAIUpdateEvent(miliseconds) -- This creates an ai update event to use w/ ONAIUPDATEVENT.
:ModifyAIUpdateEvent(newtime) -- changes the prev time to the one provided.
:RemoveAIUpdateEvent() -- similar to RemoveEvents() but only removes aiupdate event.
:DeleteWaypoint(wpid) -- if the unit has that wpid, it deletes it.
.:SET STUFF:.
:SetMana(newmana) -- Sets the units current mana to this.
:SetMaxMana(maxmana) -- sets the maximum mana the unit can have, to this.
:SetHealth(newhp) -- explainatory.
:SetMaxHealth(newmaxhp) -- explainator.
:SetFieldFlags() -- absolete, use SetUInt32/64Value(field,value)
:SetFlying() -- if the unit can hover, it sets to hover.
:SetCombatCapable(1/0) -- 1 disables combat, 0 re-enables combat.
:SetCombatMeleeCapable(1/0) - 1 disables melee ability, 0 enables it.
:SetCombatRangedCapable(1/0) -- and so on.
:SetCombatSpellCapable(1/0) -- and so on.
:SetCombatTargetingCapable(1/0) -- Disables targeting, only disables new targeting, if the unit already has targgeted u, it will continue to do so.
:SetNPCFlags() -- absolete
:SetModel(newid) -- changes the display of the unit.
:SetScale(newscale) -- changes the size of the unit, doesn't scale compared to scalespells.
:SetFaction(newfaction) -- changes the faction of the unit, doesn't take effect until u rezone.
:SetStandState(newstandstate) -- Need more info.
:SetTauntedBy(target) -- set to be taunted by the target provided
:SetSoulLinkedWith(target) -- set soul linked, I think this means that only that target can attack this unit.
:SetInFront(target) -- I guess it sets the current unit to be infront of the target provided.
:SetOutOfCombatRange(combatrange) -- this sets outofcombatrange.
:SetMovementType(0 - walk, 256 - run, 768 - fly) - yep.
:SetHealthPct() -- sets the PERCENT of the hp.
:ModifyRunSpeed(float) -- changes
:ModifyWalkSpeed(float) -- the units
:ModifyFlySpeed(float) -- speed.
:SetOrientation(newo) -- new direction to face.
:SetFacing(newo) -- new direction to face, only if unit is idle.
:SetNextTarget(target) -- make the unit target the one provided.
:SetStealth(stealthpoints) -- makes the unit go into stealth mode, is detected depending on how many stealth points
:SetPowerType(string) -- this uses strings to set the power type ("health,mana,rage,focus,energy")
:SetDeathState(newdeathstate) -- sets death state
:SetPlayerStanding(faction,value) -- sets the rep of the player related to the faction.
:SetPlayerLevel(level) -- explainatory.
(I didn't make this list, the credits goes to the maker)

Read trough the list please.

STEP 1: How to start
Make a new .txt dokument. Name is relevant. Chance the ''.txt'' to ''.lua'' and open it as Notepad.

Okay, we wanner make it a Teleporter NPC so start out with:

function On_Gossip(unit, event, player)
unit:GossipCreateMenu(3544, player, 0) You always put ''3544'' first and then the rest is ''3543''.

STEP 2: Adding some menus
You wanner make a menu for your players and yourself to teleport to. Lets say, that i wanner make a section with only ''Northrend Locations''. Then

i'll make a new line and make it look like this:

function On_Gossip(unit, event, player)
unit:GossipCreateMenu(3544, player, 0)
unit:GossipMenuAddItem(2, "Northrend Locations", 1, 0) Keep the ''2'' there. Make a name for the section, ''1'' if its the first menu ''2'' if next, ''0'' Let it stay.

You do the same if you wanner make a new section with locations, it could look like this:

function On_Gossip(unit, event, player)
unit:GossipCreateMenu(3544, player, 0)
unit:GossipMenuAddItem(2, "Northrend Locations", 1, 0)
unit:GossipMenuAddItem(2, "Azeroth Locations", 2, 0) And so on.
When you are done with the locations then: ALWAYS REMEMBER TO WRITE ''end'' when you are done with a menu, and because you want people to see the menu, write:

unit:GossipSendMenu(player)
end
In the end, it should look like this:

unit:GossipCreateMenu(3544, player, 0)
unit:GossipMenuAddItem(2, "Northrend Locations", 1, 0)
unit:GossipMenuAddItem(2, "Azeroth Locations", 2, 0)
unit:GossipSendMenu(player)
end

STEP 3: The player

After you have made all the location you have to do so people can see the menu and talk to the NPC.
Jump 1 line down in the script and type:

function Gossip_Submenus(unit, event, player, id, intid, code)
Then 1 more line after that write:


if(intid == 999) then
unit:GossipCreateMenu(3543, player, 0)

Now you got the ''SubMenu''. You only have to add the locations you have made in ''Step 2''. Like this:


if(intid == 999) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(2, "Northrend Locations", 1, 0)
unit:GossipMenuAddItem(2, "Azeroth Locations", 2, 0) Again, ''2''
just have to be there, ''Name for the section'', ''1'' if its the first menu ''2'' if next, ''0'' just leave it that way.
After the first 3 steps it should look like this:


function On_Gossip(unit, event, player)
unit:GossipCreateMenu(3544, player, 0)
unit:GossipMenuAddItem(2, "Northrend Locations", 1, 0)
unit:GossipMenuAddItem(2, "Azeroth Locations", 2, 0)
unit:GossipSendMenu(player)
end
function Gossip_Submenus(unit, event, player, id, intid, code)
if(intid == 999) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(2, "Northrend Locations", 1, 0)
unit:GossipMenuAddItem(2, "Azeroth Locations", 2, 0)
unit:GossipSendMenu(player)
end

STEP 4: Menu and etc

If you for example click on the ''Northrend Locations'' now, there wont happen anything. So you have to make another ''Menu'' for the ''Menu''.
Lets say you wanner make some locations to cities, when you click on ''Northrend Locations''. You find the ''GossipMenuAddItem'' from step 2 and

find this part:


unit:GossipMenuAddItem(2, "Northrend Locations", 1, 0)

The number you need now is the orange one.
You jump 1 line down and type in:


if(intid == 1) then
unit:GossipCreateMenu(3543, player, 0)

Now you have made another ''Menu'' when you click on ''Northrend Locations''.

Then type this in again:


unit:GossipMenuAddItem(1, "NAME HERE", 300, 0)

Lets say that i wanner make a tab so my players can teleport to Dragonblight. Then i write:


unit:GossipMenuAddItem(1, "Dragonblight", 300, 0) ''1'' is
directly teleporting when click, Name of location, Where the spell teleports you to, ''0'' just leave it.

Normally after you have made alot of locations in the ''Northrend Locations'' tab, you want a [Back] bottom. For this you write:


unit:GossipMenuAddItem(0, "[Back]", 999, 0) ''0'' does nothing, Name of the bottom, ''999'' is ''back'', ''0'' just leave it.
You do the same thing with the ''Azeroth Locations'' section.

After Step 4, it should look like this:


function On_Gossip(unit, event, player)
unit:GossipCreateMenu(3544, player, 0)
unit:GossipMenuAddItem(2, "Northrend Locations", 1, 0)
unit:GossipMenuAddItem(2, "Azeroth Locations", 2, 0)
unit:GossipSendMenu(player)
end
function Gossip_Submenus(unit, event, player, id, intid, code)
if(intid == 999) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(2, "Northrend Locations", 1, 0)
unit:GossipMenuAddItem(2, "Azeroth Locations", 2, 0)
unit:GossipSendMenu(player)
end
if(intid == 1) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(1, "Drangonblight", 300, 0)
unit:GossipMenuAddItem(0, "[Back]", 999, 0)
unit:GossipSendMenu(player)
end
if(intid == 2) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(1, "Stormwind", 301, 0)
unit:GossipMenuAddItem(0, "[Back]", 999, 0)
unit:GossipSendMenu(player)
end

STEP 5: .gps and coords.

This is the in-game part.
Go in-game and find the place you want in Dragonblight the Teleporter teleports you to. When you have found the spot, write the command ''.gps''. You only need the MapID, X, Y, Z cords.

Jump 1 line down again and type in:


if(intid == 300) then
player:Teleport(MapID, X, Y, Z)
unit:GossipComplete(player)
end
The ''300'' is the
unit:GossipMenuAddItem(1, "Drangonblight, 300, 0) other number in the GossipMenuAddItem for Dragonblight.

Do the same thing for the ''Stormwind'' location in the ''Azeroth Locations'' section.

When you are done with Step 5, it should look something like this:


function On_Gossip(unit, event, player)
unit:GossipCreateMenu(3544, player, 0)
unit:GossipMenuAddItem(2, "Northrend Locations", 1, 0)
unit:GossipMenuAddItem(2, "Azeroth Locations", 2, 0)
unit:GossipSendMenu(player)
end
function Gossip_Submenus(unit, event, player, id, intid, code)
if(intid == 999) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(2, "Northrend Locations", 1, 0)
unit:GossipMenuAddItem(2, "Azeroth Locations", 2, 0)
unit:GossipSendMenu(player)
end
if(intid == 1) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(1, "Drangonblight", 300, 0)
unit:GossipMenuAddItem(0, "[Back]", 999, 0)
unit:GossipSendMenu(player)
end
if(intid == 2) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(1, "Stormwind", 301, 0)
unit:GossipMenuAddItem(0, "[Back]", 999, 0)
unit:GossipSendMenu(player)
end
if(intid == 300) then
player:Teleport(MapID, X, Y, Z)
unit:GossipComplete(player)
end
if(intid == 301) then
player:Teleport(MapID, X, Y, Z)
unit:GossipComplete(player)
end

STEP 6: Make the .sql file

You Teleporter needs a .sql to execute to the database. There are some differend programs to do it, and you could use WoW Vendetta - Wage Your War (http://www.WoW-V.com). But i think i will use the program called: ''FlexibleDBEditor'' you can download it from here: http://www.************/forums/programs/196694-flexiable-database-editor-updated-3-0-3-a.html

If not you wanner make a hole new npc use this:


INSERT INTO creature_proto (entry, minlevel, maxlevel, faction, minhealth, maxhealth, mana, scale, npcflags, attacktime, mindamage, maxdamage, rangedattacktime, rangedmindamage, rangedmaxdamage, respawntime, armor, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, combat_reach, bounding_radius, auras, boss, money, invisibility_type, death_state)
VALUES (333333, 250, 250, 35, 1000000, 1000000, 1000000, 1.5, 3, 1800, 150, 250, 1800, 500, 650, 36000, 0, 0, 0, 0, 0, 0, 0, 1, 0, "MEMO", 0, 0, 0, 0);
INSERT INTO creature_names (entry, `name`, Subname, Flags1, type, Family, Rank, unk4, SpellDataID, male_displayid, female_displayid, unknown_float1, unknown_float2, Civilian, Leader, info_str)
VALUES (333333,"Taxi","Djfredericks Repack",0,7,0,0,0,NULL,28213,28213,1, 1,1,NULL, '');

ORANGE = Entry ID, BLUE = Name, WHITE = Subname, RED = DisplayID for a woman, GREEN = DisplayID for a man.

STEP 7: DisplayID and Entry

Go to you lua script again. Jump 1 line down and type in:


RegisterUnitGossipEvent(ENTRY ID, 1, "On_Gossip")
RegisterUnitGossipEvent(ENTRY ID, 2, "Gossip_Submenus")

Put your Entry ID from the .sql you made in, where it says: ENTRY ID
After you have followed the hole guide, it should look something like this:


function On_Gossip(unit, event, player)
unit:GossipCreateMenu(3544, player, 0)
unit:GossipMenuAddItem(2, "Northrend Locations", 1, 0)
unit:GossipMenuAddItem(2, "Azeroth Locations", 2, 0)
unit:GossipSendMenu(player)
end
function Gossip_Submenus(unit, event, player, id, intid, code)
if(intid == 999) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(2, "Northrend Locations", 1, 0)
unit:GossipMenuAddItem(2, "Azeroth Locations", 2, 0)
unit:GossipSendMenu(player)
end
if(intid == 1) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(1, "Drangonblight", 300, 0)
unit:GossipMenuAddItem(0, "[Back]", 999, 0)
unit:GossipSendMenu(player)
end
if(intid == 2) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(1, "Stormwind", 301, 0)
unit:GossipMenuAddItem(0, "[Back]", 999, 0)
unit:GossipSendMenu(player)
end
if(intid == 300) then
player:Teleport(MapID, X, Y, Z)
unit:GossipComplete(player)
end
if(intid == 301) then
player:Teleport(MapID, X, Y, Z)
unit:GossipComplete(player)
end
end
RegisterUnitGossipEvent(ENTRY ID, 1, "On_Gossip")
RegisterUnitGossipEvent(ENTRY ID, 2, "Gossip_Submenus")

NOTE: When you are done with the script then type in another ''end'' like in the script we just made. Like this:


if(intid == 301) then
player:Teleport(MapID, X, Y, Z)
unit:GossipComplete(player)
end
end

Not after:


RegisterUnitGossipEvent(ENTRY ID, 1, "On_Gossip")
RegisterUnitGossipEvent(ENTRY ID, 2, "Gossip_Submenus")

Gratz, you now made a small and simple NPC Lua Teleporter :)
Don't hope it were to hard to understand for you.

The best of luck, Djfrederick.

Apple
20-01-09, 11:10 AM
really nice , +Rep again for this awesome thread/guide

Djfrederick
20-01-09, 11:56 AM
Thanks mate ;)

Like to help the community.

Avidgamer
21-01-09, 06:23 AM
Yeah, very nice.

Once I spread some Rep, I can give you the Rep you deserve ;)

Djfrederick
21-01-09, 03:32 PM
Thanks, you guys.

QQrofl
21-01-09, 03:50 PM
Awesome Guide! +rep.

Blindguard
24-01-09, 04:51 PM
Nice lad, thanks!

Djfrederick
27-01-09, 02:34 PM
You're welcome. :)

Djfrederick
23-12-09, 04:49 PM
Huge bump. Just for the new users.

xxgrimxx
09-04-10, 11:59 PM
Hey dude thx, its a good guide but i had trouble following a long a little.. But overall thx and nice

xxgrimxx
18-04-10, 01:02 AM
bumpidy bumpidy