• 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!

Can't accept war.

olekpro

Member
Joined
Nov 1, 2014
Messages
121
Reaction score
6
Hello, i have problem. I'm using tfs 0.3.6 and gesior acc. Website is working great but war system in game.. ehh... I can invite guild to war, can cancel it.. but i can't accept Wooot!
I have got error in console.



[Error - TalkAction Interface]
data/talkactions/scripts/war.lua:eek:nSay
Description:
data/talkactions/scripts/war.lua:73: attempt to call global 'doGuildAddEnemy' (a nil value)
stack traceback:
data/talkactions/scripts/war.lua:73: in function <data/talkactions/scripts/war.lua:1>

i'm using war.lua :

  1. function onSay(cid, words, param, channel)
  2. local guild = getPlayerGuildId(cid)
  3. if exhaustion.check(cid, 2000) == false then
  4. exhaustion.set(cid, 2000, 3)
  5. if getPlayerLevel(cid) >= 40 then
  6. if(not guild or getPlayerGuildLevel(cid) < GUILDLEVEL_LEADER) then
  7. doPlayerSendChannelMessage(cid, "", "You cannot execute this talkaction.", TALKTYPE_CHANNEL_W, 0)
  8. return true
  9. end

  10. local t = string.explode(param, ",")
  11. if(not t[2]) then
  12. doPlayerSendChannelMessage(cid, "", "Not enough param(s).", TALKTYPE_CHANNEL_W, 0)
  13. return true
  14. end

  15. local enemy = getGuildId(t[2])
  16. if(not enemy) then
  17. doPlayerSendChannelMessage(cid, "", "Guild \"" .. t[2] .. "\" does not exists.", TALKTYPE_CHANNEL_W, 0)
  18. return true
  19. end

  20. if(enemy == guild) then
  21. doPlayerSendChannelMessage(cid, "", "You cannot perform war action on your own guild.", TALKTYPE_CHANNEL_W, 0)
  22. return true
  23. end

  24. local enemyName, tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
  25. if(tmp:getID() ~= -1) then
  26. enemyName = tmp:getDataString("name")
  27. tmp:free()
  28. end

  29. if(isInArray({"accept", "reject", "cancel"}, t[1])) then
  30. local query = "`guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild
  31. if(t[1] == "cancel") then
  32. query = "`guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy
  33. end

  34. tmp = db.getResult("SELECT `id`, `begin`, `end`, `payment` FROM `guild_wars` WHERE " .. query .. " AND `status` = 0")
  35. if(tmp:getID() == -1) then
  36. doPlayerSendChannelMessage(cid, "", "Currently there's no pending invitation for a war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
  37. return true
  38. end

  39. if(t[1] == "accept") then
  40. local _tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)
  41. local state = _tmp:getID() < 0 or _tmp:getDataInt("balance") < tmp:getDataInt("payment")

  42. _tmp:free()
  43. if(state) then
  44. doPlayerSendChannelMessage(cid, "", "Your guild balance is too low to accept this invitation.", TALKTYPE_CHANNEL_W, 0)
  45. return true
  46. end

  47. db.executeQuery("UPDATE `guilds` SET `balance` = `balance` - " .. tmp:getDataInt("payment") .. " WHERE `id` = " .. guild)
  48. end

  49. query = "UPDATE `guild_wars` SET "
  50. local msg = "accepted " .. enemyName .. " invitation to war."
  51. if(t[1] == "reject") then
  52. query = query .. "`end` = " .. os.time() .. ", `status` = 2"
  53. msg = "rejected " .. enemyName .. " invitation to war."
  54. elseif(t[1] == "cancel") then
  55. query = query .. "`end` = " .. os.time() .. ", `status` = 3"
  56. msg = "canceled invitation to a war with " .. enemyName .. "."
  57. else
  58. query = query .. "`begin` = " .. os.time() .. ", `end` = " .. (tmp:getDataInt("end") > 0 and (os.time() + ((tmp:getDataInt("begin") - tmp:getDataInt("end")) / 86400)) or 0) .. ", `status` = 1"
  59. end

  60. query = query .. " WHERE `id` = " .. tmp:getDataInt("id")
  61. if(t[1] == "accept") then
  62. doGuildAddEnemy(guild, enemy, tmp:getDataInt("id"), WAR_GUILD)
  63. doGuildAddEnemy(enemy, guild, tmp:getDataInt("id"), WAR_ENEMY)
  64. end

  65. tmp:free()
  66. db.executeQuery(query)
  67. doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. msg, MESSAGE_EVENT_ADVANCE)
  68. return true
  69. end

  70. if(t[1] == "invite") then
  71. local str = ""
  72. tmp = db.getResult("SELECT `guild_id`, `status` FROM `guild_wars` WHERE `guild_id` IN (" .. guild .. "," .. enemy .. ") AND `enemy_id` IN (" .. enemy .. "," .. guild .. ") AND `status` IN (0, 1)")
  73. if(tmp:getID() ~= -1) then
  74. if(tmp:getDataInt("status") == 0) then
  75. if(tmp:getDataInt("guild_id") == guild) then
  76. str = "You have already invited " .. enemyName .. " to war."
  77. else
  78. str = enemyName .. " have already invited you to war."
  79. end
  80. else
  81. str = "You are already on a war with " .. enemyName .. "."
  82. end

  83. tmp:free()
  84. end

  85. if(str ~= "") then
  86. doPlayerSendChannelMessage(cid, "", str, TALKTYPE_CHANNEL_W, 0)
  87. return true
  88. end

  89. local frags = tonumber(t[3])
  90. if(frags ~= nil) then
  91. frags = math.max(10, math.min(1000, frags))
  92. else
  93. frags = 100
  94. end

  95. local payment = tonumber(t[4])
  96. if(payment ~= nil) then
  97. payment = math.max(100000, math.min(1000000000, payment))
  98. tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)

  99. local state = tmp:getID() < 0 or tmp:getDataInt("balance") < payment
  100. tmp:free()
  101. if(state) then
  102. doPlayerSendChannelMessage(cid, "", "Your guild balance is too low for such payment.", TALKTYPE_CHANNEL_W, 0)
  103. return true
  104. end

  105. db.executeQuery("UPDATE `guilds` SET `balance` = `balance` - " .. payment .. " WHERE `id` = " .. guild)
  106. else
  107. payment = 0
  108. end

  109. local begining, ending = os.time(), tonumber(t[5])
  110. if(ending ~= nil and ending ~= 0) then
  111. ending = begining + (ending * 86400)
  112. else
  113. ending = 0
  114. end

  115. db.executeQuery("INSERT INTO `guild_wars` (`guild_id`, `enemy_id`, `begin`, `end`, `frags`, `payment`) VALUES (" .. guild .. ", " .. enemy .. ", " .. begining .. ", " .. ending .. ", " .. frags .. ", " .. payment .. ");")
  116. doBroadcastMessage(getPlayerGuildName(cid) .. " has invited " .. enemyName .. " to war till " .. frags .. " frags.", MESSAGE_EVENT_ADVANCE)
  117. return true
  118. end

  119. if(not isInArray({"end", "finish"}, t[1])) then
  120. return false
  121. end

  122. local status = (t[1] == "end" and 1 or 4)
  123. tmp = db.getResult("SELECT `id` FROM `guild_wars` WHERE `guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy .. " AND `status` = " .. status)
  124. if(tmp:getID() ~= -1) then
  125. local query = "UPDATE `guild_wars` SET `end` = " .. os.time() .. ", `status` = 5 WHERE `id` = " .. tmp:getDataInt("id")
  126. tmp:free()
  127. doGuildRemoveEnemy(guild, enemy)
  128. doGuildRemoveEnemy(enemy, guild)

  129. db.executeQuery(query)
  130. doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. (status == 4 and "mend fences" or "ended up a war") .. " with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
  131. return true
  132. end

  133. if(status == 4) then
  134. doPlayerSendChannelMessage(cid, "", "Currently there's no pending war truce from " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
  135. return true
  136. end

  137. tmp = db.getResult("SELECT `id`, `end` FROM `guild_wars` WHERE `guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild .. " AND `status` = 1")
  138. if(tmp:getID() ~= -1) then
  139. if(tmp:getDataInt("end") > 0) then
  140. tmp:free()
  141. doPlayerSendChannelMessage(cid, "", "You cannot request ending for war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
  142. return true
  143. end

  144. local query = "UPDATE `guild_wars` SET `status` = 4, `end` = " .. os.time() .. " WHERE `id` = " .. tmp:getDataInt("id")
  145. tmp:free()

  146. db.executeQuery(query)
  147. doBroadcastMessage(getPlayerGuildName(cid) .. " has signed an armstice declaration on a war with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
  148. return true
  149. end

  150. doPlayerSendChannelMessage(cid, "", "Currently there's no active war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
  151. else
  152. doPlayerSendCancel(cid, "You must have 40+ level to use this command.")
  153. end
  154. else
  155. doPlayerSendCancel(cid, "You are exhausted")
  156. end
  157. return true
  158. end
 
Back
Top