• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua [GOT] Help me to make 2 things

warriorfrog

Active Member
Joined
Jul 29, 2015
Messages
334
Reaction score
35
I have a game of throne system, i found in other forum made by: Zipster98

But i need a help to change 2 things

I really need some help... Its much thing to me im trapped in it in 2 weeks, idk what to do now...

1- 1 guild per throne... 1 guild can get only 1 throne (max)...
I've tried:
Changes on movements (tile acess to start enter in castle)...
I added it
Code:
  for i=1,8,1 do
  local guildId = getGlobalStorageValue(actionid + DEFAULT_STORAGE)
  if getPlayerGuildId(cid) == guildId then
  doPlayerSendCancel(cid, "Your guild already has a throne dominated! Only one per guild.")
  doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
  doTeleportThing(cid, fromPosition, true)
  return true
  end
  actionid = actionid + 1
  end

Full throne_capturing.lua:
Code:
local config = {
  level = 50,
  count = 1,
  messages = {
  [12003] = "[GOT-Kazz]The guild %s is entering the castle.",
  [12004] = "[GOT-Kazz]The guild %s is already inside the castle.",
  [12005] = "[GOT-Kazz]The guild %s is close to conquer the castle.",

  [12006] = "[GOT-Ab]The guild %s is entering the castle.",
  [12007] = "[GOT-Ab]The guild %s is already inside the castle.",
  [12008] = "[GOT-Ab]The guild %s is close to conquer the castle.",

  [12009] = "[GOT-Edron]The guild %s is entering the castle.",
  [12010] = "[GOT-Edron]The guild %s is already inside the castle.",
  [12011] = "[GOT-Edron]The guild %s is close to conquer the castle.",

  [12012] = "[GOT-Ankrahmun]The guild %s is entering the castle.",
  [12013] = "[GOT-Ankrahmun]The guild %s is already inside the castle.",
  [12014] = "[GOT-Ankrahmun]The guild %s is close to conquer the castle.",

  [12015] = "[GOT-Tiquanda]The guild %s is entering the castle.",
  [12016] = "[GOT-Tiquanda]The guild %s is already inside the castle.",
  [12017] = "[GOT-Tiquanda]The guild %s is close to conquer the castle.",

  [12018] = "[GOT-Rookgaard]The guild %s is entering the castle.",
  [12019] = "[GOT-Rookgaard]The guild %s is already inside the castle.",
  [12020] = "[GOT-Rookgaard]The guild %s is close to conquer the castle.",

  [12021] = "[GOT-Okolnir]The guild %s is entering the castle.",
  [12022] = "[GOT-Okolnir]The guild %s is already inside the castle.",
  [12023] = "[GOT-Okolnir]The guild %s is close to conquer the castle.",

  [12000] = "[GOT-Carlin]The guild %s is entering the castle.",
  [12001] = "[GOT-Carlin]The guild %s is already inside the castle.",
  [12002] = "[GOT-Carlin]The guild %s is close to conquer the castle."
  },
  actionId = {12000, 12023, 4819}
}

function tableInsert(table, value)
  -- technically this doesn't need to be #table + 1, it can just be #table
  table[#table + 1] = value
end

function onStepIn(cid, item, position, fromPosition)

  local pid, ip = {}, {} -- now they will hold the values generated by get getGuildOnlineMembers

  local function getGuildOnlineMembers(guildId)

  for _, cid in pairs(getPlayersOnline()) do  
  if getPlayerGuildId(cid) == guildId and getPlayerLevel(cid) >= config.level and not isInArray(ip, getPlayerIp(cid)) then
  tableInsert(pid, cid)
  tableInsert(ip, getPlayerIp(cid))
  end
  end
  return pid
  end

  if not isPlayer(cid) then
  return true
  end

  if (item.actionid >= config.actionId[1] and item.actionid <= config.actionId[2]) then
  -- check if have players online (necessary)
  if getPlayerGuildId(cid) < 1 or #getGuildOnlineMembers(getPlayerGuildId(cid)) < config.count then
  doPlayerSendCancel(cid, "You need to be on guild or your guild must have at least "..config.count.." players level "..config.level.." or more.")
  doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
  doTeleportThing(cid, fromPosition, true)
  return true
  end
  -- check if have a throne owned
  actionid = 2391
  default_storage = 49198
  for i=1,8,1 do
  local guildId = getGlobalStorageValue(actionid + DEFAULT_STORAGE)
  if getPlayerGuildId(cid) == guildId then
  doPlayerSendCancel(cid, "Your guild already has a throne dominated! Only one per guild.")
  doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
  doTeleportThing(cid, fromPosition, true)
  return true
  end
  actionid = actionid + 1
  end
  end

  if getGlobalStorageValue(item.actionid + config.actionId[3]) < os.time() then
  broadcastMessage(config.messages[item.actionid]:format(getPlayerGuildName(cid)))
  setGlobalStorageValue(item.actionid + config.actionId[3], os.time() + 60)
  end
  doCreatureSetSkullType(cid, 3)
  return true
end

But not work! i think i using worng values


2- A sign(ITEMID: 1429) in front the castles show which guild own the city
I've tried:
creaturescripts.xml
Code:
<event type="look" name="got_placas" event="script" value="GOT/placas.lua"/>

login.lua
Code:
registerCreatureEvent(cid, "got_placas")

GOT/placas.lua
Code:
function onLook(cid, thing, position, lookDistance)
  if (item.actionid == 3391) then
  local guildName = getGuildName(getGlobalStorageValue(2391 + DEFAULT_STORAGE))
  doPlayerSetSpecialDescription(item.actionid, "Carlin throne dominated by guild: " .. guildName .. " .")
  end
  return true
end

Not work... Errors on console:
Code:
[4:30:59.534] [Error - CreatureScript Interface]
[4:30:59.534] data/creaturescripts/scripts/GOT/placas.lua:onLook
[4:30:59.534] Description:
[4:30:59.534] data/creaturescripts/scripts/GOT/placas.lua:2: attempt to index global 'item' (a nil value)
[4:30:59.534] stack traceback:
[4:30:59.534]  data/creaturescripts/scripts/GOT/placas.lua:2: in function <data/creaturescripts/scripts/GOT/placas.lua:1>


FULL Code:
===========================================================
LIBs
===========================================================
/lib/GOTlib.lua
http://hastebin.com/emavetagoc.lua

===========================================================
Monsters
===========================================================
Code:
<monstername="Chanceler Carlin"file="GOT/chanceler carlin.xml"/>

chanceler carlin.xml
http://hastebin.com/piwobonawu.xml

===========================================================
Movemments
===========================================================
Code:
<movevent type="StepIn" actionid="12000-12100" event="script" value="GOT/throne_capturing.lua"/>
<movevent type="StepIn" actionid="2391-2398" event="script" value="GOT/tile_acess_members_of_throne.lua"/>

throne_capturing.lua
http://hastebin.com/atizibitim.lua

tile_acess_members_of_throne.lua
http://hastebin.com/icolesapel.lua

===========================================================
Creaturescripts
===========================================================
Code:
  <!-- Guild own throne +25%de exp -->
  <event type="death" name="mDeath" event="script" value="GOT/expbonus_got.lua"/>
  <event type="statschange" name="mStatsChange" event="script" value="GOT/expbonus_got.lua"/>
  <event type="target" name="mTarget" event="script" value="GOT/expbonus_got.lua"/>
  <event type="login" name="mLogin" event="script" value="GOT/expbonus_got.lua"/>

expbonus_got.lua
http://hastebin.com/ogabuyudid.lua
 
Just your error fix:
if (item.actionid == 3391) then
to
if (thing.actionid == 3391) then
EDIT:
also
doPlayerSetSpecialDescription(item.actionid, "Carlin throne dominated by guild: " .. guildName .. " .")
to
doSetItemSpecialDescription(thing.uid, "Carlin throne dominated by guild: " .. guildName .. " .")
 
Just your error fix:
if (item.actionid == 3391) then
to
if (thing.actionid == 3391) then
EDIT:
also
doPlayerSetSpecialDescription(item.actionid, "Carlin throne dominated by guild: " .. guildName .. " .")
to
doSetItemSpecialDescription(thing.uid, "Carlin throne dominated by guild: " .. guildName .. " .")

I tried it to fix my second question, but not work

Code:
[16:17:36.127] [Error - CreatureScript Interface]
[16:17:36.127] data/creaturescripts/scripts/GOT/placas.lua:onLook
[16:17:36.127] Description:
[16:17:36.127] data/lib/004-database.lua:76: [Result:getDataString] Result not set!
[16:17:36.127] stack traceback:
[16:17:36.127]    [C]: in function 'error'
[16:17:36.127]    data/lib/004-database.lua:76: in function 'getDataString'
[16:17:36.127]    data/lib/GOTlib.lua:32: in function 'getGuildName'
[16:17:36.127]    data/creaturescripts/scripts/GOT/placas.lua:3: in function <data/creaturescripts/scripts/GOT/placas.lua:1>

Code:
function onLook(cid, thing, position, lookDistance)
   if (thing.actionid == 3391) then
     local guildName = getGuildName(getGlobalStorageValue(2391 + DEFAULT_STORAGE))
    doSetItemSpecialDescription(thing.uid, "Carlin throne dominated by guild: " .. guildName .. " .")
   end
   return true
end

004-database.lua
Code:
if(result == nil) then
   print("> WARNING: Couldn't load database lib.")
   return
end

Result = createClass(nil)
Result:setAttributes({
   id = -1,
   query = ""
})

function Result:getID()
   return self.id
end

function Result:setID(_id)
   self.id = _id
end

function Result:getQuery()
   return self.query
end

function Result:setQuery(_query)
   self.query = _query
end

function Result:create(_query)
   self:setQuery(_query)
   local _id = db.storeQuery(self:getQuery())
   if(_id) then
     self:setID(_id)
   end

   return self:getID()
end

function Result:getRows(free)
   local free = free or false
   if(self:getID() == -1) then
     error("[Result:getRows] Result not set!")
   end

   local c = 0
   repeat
     c = c + 1
   until not self:next()

   local _query = self:getQuery()
   self:free()
   if(not free) then
     self:create(_query)
   end

   return c
end

function Result:getDataInt(s)
   if(self:getID() == -1) then
     error("[Result:getDataInt] Result not set!")
   end

   return result.getDataInt(self:getID(), s)
end

function Result:getDataLong(s)
   if(self:getID() == -1) then
     error("[Result:getDataLong] Result not set!")
   end

   return result.getDataLong(self:getID(), s)
end

function Result:getDataString(s)
   if(self:getID() == -1) then
     error("[Result:getDataString] Result not set!")
   end

   return result.getDataString(self:getID(), s)
end

function Result:getDataStream(s)
   if(self:getID() == -1) then
     error("[Result:getDataStream] Result not set!")
   end

   return result.getDataStream(self:getID(), s)
end

function Result:next()
   if(self:getID() == -1) then
     error("[Result:next] Result not set!")
   end

   return result.next(self:getID())
end

function Result:free()
   if(self:getID() == -1) then
     error("[Result:free] Result not set!")
   end

   self:setQuery("")
   local ret = result.free(self:getID())
   self:setID(-1)
   return ret
end

Result.numRows = Result.getRows
function db.getResult(query)
   if(type(query) ~= 'string') then
     return nil
   end

   local ret = Result:new()
   ret:create(query)
   return ret
end
 
Back
Top