Page 1 of 1

Zone scritping question

Posted: Mon Feb 15, 2010 12:05 am
by samsarat2209
Hi every body

Is there a way to link a lua script to a zone loading?
In partical for the begining zone, i need some configuration scripting.
I was unable to find this information.

Thanks for help.

Thank for EQ2Emu :)
Great fantasm that come real :)

Re: Zone scritping question

Posted: Mon Feb 15, 2010 1:00 am
by Scatman
You mean when a zone first initially loads or when a player enters the zone?

Re: Zone scritping question

Posted: Mon Feb 15, 2010 1:49 am
by samsarat2209
At least when the player enter the zone.

Re: Zone scritping question

Posted: Mon Feb 15, 2010 8:11 am
by John Adams
It would help if we had an exact example of what you are trying to accomplish. Ie, here is a sample Zone Script from our server, that displays text when you enter a specific area:

Code: Select all

--[[
	Script Name	: ZoneScripts/QueensColony.lua
	Script Purpose	: Location Pop-ups
	Script Author	: John Adams
	Script Date	: 2009.05.07
	Script Notes	: Sample ZoneScript
--]]

function init_zone_script(Zone)
	SetLocationProximityFunction(Zone, 70, -4.25, 168.5, 30, "SunsetMeadow")
	SetLocationProximityFunction(Zone, 175, -3, 135, 30, "SunsetMeadow")
	SetLocationProximityFunction(Zone, 203, -3.3, 144.5, 30, "SunsetMeadow")
end

function SunsetMeadow(Zone, Player)
	SendPopUpMessage(Player, "Sunset Meadow", 255, 255, 0)
end
Basically, in the Sunset Meadow area, if a player crosses the threshhold of any of the 3 entrances, the text "Sunset Meadow" will appear on their screen in Yellow.

Put the file into a folder under EQ2World.exe (ie., ./ZoneScripts/Test.lua)

Then go to the `zones` table and add "ZoneScripts/Test.lua" to the zone record's `lua_script` field.

There are five (5) places to add scripts: Items, Spawns, Spells, Quests and Zones. More to come.

Re: Zone scritping question

Posted: Mon Feb 15, 2010 9:07 am
by Scatman
There is also a function in a zone's zonescript called player_entry(Zone, Player). It gets called whenever a player enters a zone.
Example:

Code: Select all

function player_entry(Zone, Player)
   SendMessage(Player, "Welcome to the zone " .. GetName(Player) .. "!")
end

Re: Zone scritping question

Posted: Tue Feb 16, 2010 3:39 am
by samsarat2209
Yes !!
Thats enough for me. :)
In fact, iwas'nt know where and how to place zone scripts.
Thanks :)