avalock
New Member
Well i requested help building tables as never done them on the support board but never got a reply, so i taught myself ^^. I figured out how to do what i wanted to so i thought i would share with everyone what i made incase anyone else needs something like this. Welcome to use / modify to your needs but if sharing the script / modified version please give credits!
What it is for?
You have an area that players would be team hunting in, but its a distance from your city(s), so normally you would put a NPC that teleports players to different zones, this is same concept but someone would have to make the effort to actually walk there first. Then they can summon all their party to the location, and the summoned targets can accept or ignore the invite.
There is 2 parts to this script, Action and TalkAction to make it work, its untested at the moment (will test soon).
Add into actions.xml:
MeetingStones(TalkAction.lua):
Add into talkactions.xml:
Edit: Thanks to teckman for helping me learn some new things
Hope you like it! P.S. I am very new to using Tables, etc... so please don't be too harsh or negative if there is an easier way to do this, i'm still learning! That said i'm open to positive feed back and offers to show me either were i can find material to learn or direct help in learning
What it is for?
You have an area that players would be team hunting in, but its a distance from your city(s), so normally you would put a NPC that teleports players to different zones, this is same concept but someone would have to make the effort to actually walk there first. Then they can summon all their party to the location, and the summoned targets can accept or ignore the invite.
There is 2 parts to this script, Action and TalkAction to make it work, its untested at the moment (will test soon).
Code:
MeetingStones(Action).lua:
-- Meeting Stones Version 1.0.2
-- Meeting Stones (Action)
-- Created By Avalock
-- Last Edited: 10/08/2013
function onUse(cid, item, fromPosition, itemEx, toPosition)
local MeetingStones = {
[0] = { -- Set Number to Stones UID.
Name = "Exmaple", -- Name of the WarZone the Meeting Stone is linked too. This is important to input!
StorageID = 00000 -- The storage ID that is linked to the meeting stones invite.
},
[40001] = {
Name = "Dragons Den",
StorageID = 40001
},
[40002] = {
Name = "Bleh",
StorageID = 40002
}
},
local MSConfig = {
CoolDown = 125, -- 2 minutes 5 seconds.
CoolDownStorage = 40000,
RSMessage = ""..getCreatureName(cid).." is summoning you to "..MeetingStones[v].Name..". You have 2 minutes to say \'!warzone accept, "..MeetingStones[v].Name.."\'.",
NPMessage = "You aren\'t in a party.",
SAPMessage = "You have summoned all party members. Please wait for them to accept.",
CDMessage = "You must wait until you can summon more players.",
MSGType = MESSAGE_INFO_DESCR
}
local v = MeetingStones[item.uid]
if getPlayerParty(cid) == false and item.uid == v then
doPlayerSendCancel(cid, MSConfig.NPMessage)
elseif getPlayerParty(cid) == true and item.uid == v and getPlayerStorageValue(cid, MSConfig.CoolDownStorage) < os.time() then
for _, pid in ipairs(getPlayersOnline()) do
setPlayerStorageValue(cid, MSConfig.CoolDownStorage, os.time()+MSConfig.CoolDown)
setPlayerStorageValue(party, MeetingStones[v].StorageID, os.time()+120)
doPlayerSendTextMessage(party, MSConfig.MSGType, MSConfig.RSMessage)
end
doPlayerSendTextMessage(cid, MSConfig.MSGType, MSConfig.SAPMessage)
else
doPlayerSendTextMessage(cid, MSConfig.MSGType, MSConfig.CDMessage)
return true
end
return 0
end
Code:
<action uniqueid="40001" script="MeetingStones(Action).lua"/>
MeetingStones(TalkAction.lua):
Code:
-- Meeting Stones Version 1.0.1
-- Meeting Stones (TalkAction)
-- Created By Avalock
-- Last Edited: 10/08/2013
function onSay(cid, words, param, channel)
local destinations = {
[dragons den] = {
Storage = 40001,
Position = {x = 33167, y = 32006, z = 9}
}
}
local tp = destinations[string.lower(param)]
if(param == "") then
doPlayerSendCancel(cid, "Please enter the name of the WarZone you wish to accept the summons for.")
return true
end
if getPlayerGroupId(cid) > 2 then
doTeleportThing(cid, tp.Position)
doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You arrive safely at "..destinations[param].."!")
elseif getCreatureCondition(cid, CONDITION_INFIGHT) == true then
doPlayerSendCancel(cid, "You can\'t accept a summons whilst in combat!")
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
elseif getPlayerStorageValue(cid, tp.storage) == -1 then
doPlayerSendCancel(cid, "You haven\'t been summoned to this WarZone!")
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
elseif getPlayerStorageValue(cid, tp.storage) >= os.time() then
doPlayerSendCancel(cid, "Your invite has expired!")
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
else
doTeleportThing(cid, tp.Position)
doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You accepted the summons and arrive safely at "..destinations[param].."!")
end
return true
end
Add into talkactions.xml:
Code:
<talkaction words="!warzone accept," script="MeetingStones(TalkAction).lua"/>
Edit: Thanks to teckman for helping me learn some new things
Hope you like it! P.S. I am very new to using Tables, etc... so please don't be too harsh or negative if there is an easier way to do this, i'm still learning! That said i'm open to positive feed back and offers to show me either were i can find material to learn or direct help in learning
Last edited: