• 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 Help to fix my try bountyhunt npc list

infernality

Member
Joined
Jul 24, 2016
Messages
58
Reaction score
13
Someone could help me to fix, and finish

What I tried to make new?
A list to wanted players in NPC ingame and not in website to be more RPG
@maikons idea

Code:
    if (msgcontains(msg, 'list') then
       local str = {}

    for ???????????????
    table.insert(str, tostring(" {".. name .."}["..hunted by.."] for ".. reward .."k,\n") )
    end

    if next(str) == nil then
    npcHandler:say("No heads prize.", cid)
    else
         doShowTextDialog(cid, 2175, table.concat(str))
       end
     end


Full NPC code:

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
function onCreatureAppear(cid)  npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)  npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg) end
function onThink()  npcHandler:onThink() end
-- OTServ event handling functions end
local talkState = {}
local huntN = {}
local huntP = {}

local function checkName(player)
   local sp_id = getPlayerGUIDByName(player)
   if sp_id == nil then
     return FALSE
   end
 
   local id = 0
   local result_plr = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` = "..sp_id.." AND `killed` = 0;")
  if(result_plr:getID() ~= -1) then
     id = tonumber(result_plr:getDataInt("sp_id"))
     result_plr:free()
  end
 
   if id ~= sp_id then
     return TRUE
   end
return FALSE
end

local function huntPlayer(cid,player,cost)
local guid = tonumber(getPlayerGUID(cid))
local player = tonumber(getPlayerGUIDByName(player))
local cost = tonumber(cost)

if guid == nil or player == nil or cost == nil then
   return FALSE
end
   db.executeQuery("INSERT INTO `bounty_hunters` VALUES (NULL,"..guid..","..player..",0," .. os.time() .. ","..cost..",0,0);")
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Hunt has been added successfuly!")
   return TRUE
end

function creatureSayCallback(cid, type, msg)
  -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
if(not(npcHandler:isFocused(cid))) then
   return false
end
   if talkState[cid] == nil then
     talkState[cid] = 0
   end
     if (msgcontains(msg, 'list') then
       local str = {}

    for ???????????????
    table.insert(str, tostring(" {".. name .."}["..hunted by.."] for ".. reward .."k,\n") )
    end

    if next(str) == nil then
    npcHandler:say("No heads prize.", cid)
    else
         doShowTextDialog(cid, 2175, table.concat(str))
       end
     end
  if (msgcontains(msg, 'hunted') or msgcontains(msg, 'yes') or msgcontains(msg, 'hunt')) and talkState[cid] == 0 then
       if(getPlayerLevel(cid) < 50) then
         selfSay('Oh man you are just a kid, come back after take level 50 or more!',cid)
         talkState[cid] = 0
         return true
       end
       selfSay('Oh, you want to kill somebody, don`t you? Tell me, what is his name.',cid)
       talkState[cid] = 1
     elseif talkState[cid] == 1 then
       talkState[cid] = 0
       if checkName(msg) == TRUE then
         huntN[cid] = msg
         selfSay('Okay. Tell me, how much of gold coins will you pay to the killer.',cid)
         talkState[cid] = 2
       else
         selfSay('Sorry, this player is already hunted or does not exist. Really sorry!',cid)
       end
     elseif talkState[cid] == 2 then
       talkState[cid] = 0
       kwota = tonumber(msg)
       if kwota == nil then
         selfSay('What? I don`t understand you.', cid)
         elseif kwota > 100000000 then
           selfSay('Sorry, the maximum amount of gold coins is 100.000.000.', cid)
         elseif kwota < 10000 then
           selfSay('Sorry, the minimum amount of gold coins is 10.000.', cid)
         else
         huntP[cid] =  kwota
         selfSay('Do you want to hunt the player {'..huntN[cid]..'} for {'..huntP[cid]..'} gold coins?', cid)
         talkState[cid] = 3
       end
     elseif talkState[cid] == 3 then
       if msgcontains(msg, 'yes') then
         if doPlayerRemoveMoney(cid,huntP[cid]) then
       
         if huntPlayer(cid,huntN[cid],huntP[cid]) == TRUE then
           selfSay('You have added the hunt announcement of killing the player {'..huntN[cid]..'} for {'..huntP[cid]..'} gold coins!', cid)
           else
             selfSay('Maybe next time.',cid)
           end
         else
           selfSay('Sorry, you do not have enough money. Maybe next time!',cid)
         end
       else
         selfSay('Maybe next time.',cid)
       end
       talkState[cid]=0
  end
  -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
  return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Fonts:
System: https://otland.net/threads/bounty-hunters-system-player-hunt-system.27721/
Sources: 0.4
 
Last edited:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
function onCreatureAppear(cid)  npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid)  npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)  npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink()  npcHandler:eek:nThink() end
-- OTServ event handling functions end
local talkState = {}
local huntN = {}
local huntP = {}

local function checkName(player)
   local sp_id = getPlayerGUIDByName(player)
   if sp_id == nil then
     return FALSE
   end

   local id = 0
   local result_plr = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` = "..sp_id.." AND `killed` = 0;")
  if(result_plr:getID() ~= -1) then
     id = tonumber(result_plr:getDataInt("sp_id"))
     result_plr:free()
  end

   if id ~= sp_id then
     return TRUE
   end
return FALSE
end

local function huntPlayer(cid,player,cost)
local guid = tonumber(getPlayerGUID(cid))
local player = tonumber(getPlayerGUIDByName(player))
local cost = tonumber(cost)

if guid == nil or player == nil or cost == nil then
   return FALSE
end
   db.executeQuery("INSERT INTO `bounty_hunters` VALUES (NULL,"..guid..","..player..",0," .. os.time() .. ","..cost..",0,0);")
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Hunt has been added successfuly!")
   return TRUE
end

function creatureSayCallback(cid, type, msg)
  -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
if(not(npcHandler:isFocused(cid))) then
   return false
end
   if talkState[cid] == nil then
     talkState[cid] = 0
   end
     if (msgcontains(msg, 'list') then
       local str = {}

   local bountyList = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` > 0")
   if(bountyList:getID() ~= -1) then
    id = tonumber(bountyList:getDataInt("sp_id"))
    table.insert(str, id)
    result_plr:free()
   end

       if str == nil then
         npcHandler:say("No heads prize.", cid)
       else
         doShowTextDialog(cid, 2175, table.concat(str))
       end
     end
  if (msgcontains(msg, 'hunted') or msgcontains(msg, 'yes') or msgcontains(msg, 'hunt')) and talkState[cid] == 0 then
       if(getPlayerLevel(cid) < 50) then
         selfSay('Oh man you are just a kid, come back after take level 50 or more!',cid)
         talkState[cid] = 0
         return true
       end
       selfSay('Oh, you want to kill somebody, don`t you? Tell me, what is his name.',cid)
       talkState[cid] = 1
     elseif talkState[cid] == 1 then
       talkState[cid] = 0
       if checkName(msg) == TRUE then
         huntN[cid] = msg
         selfSay('Okay. Tell me, how much of gold coins will you pay to the killer.',cid)
         talkState[cid] = 2
       else
         selfSay('Sorry, this player is already hunted or does not exist. Really sorry!',cid)
       end
     elseif talkState[cid] == 2 then
       talkState[cid] = 0
       kwota = tonumber(msg)
       if kwota == nil then
         selfSay('What? I don`t understand you.', cid)
         elseif kwota > 100000000 then
           selfSay('Sorry, the maximum amount of gold coins is 100.000.000.', cid)
         elseif kwota < 10000 then
           selfSay('Sorry, the minimum amount of gold coins is 10.000.', cid)
         else
         huntP[cid] =  kwota
         selfSay('Do you want to hunt the player {'..huntN[cid]..'} for {'..huntP[cid]..'} gold coins?', cid)
         talkState[cid] = 3
       end
     elseif talkState[cid] == 3 then
       if msgcontains(msg, 'yes') then
         if doPlayerRemoveMoney(cid,huntP[cid]) then
     
         if huntPlayer(cid,huntN[cid],huntP[cid]) == TRUE then
           selfSay('You have added the hunt announcement of killing the player {'..huntN[cid]..'} for {'..huntP[cid]..'} gold coins!', cid)
           else
             selfSay('Maybe next time.',cid)
           end
         else
           selfSay('Sorry, you do not have enough money. Maybe next time!',cid)
         end
       else
         selfSay('Maybe next time.',cid)
       end
       talkState[cid]=0
  end
  -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
  return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

What list says?
 
It's not finish bro, idk how to make
Code:
for ???????????????
table.insert(str, tostring(" {".. name .."}["..hunted by.."] for ".. reward .."k,\n") )
end
 
What's the problem? Is possible to solved?
if a guy with a packet editor spam this protocol server will need to make a lot of db querys but packet editor like Winsock Packet Editor is faster than db can query up the list, then your server crash, you can avoid this by loading list to memory and make server update this list instead a db query, or you can create storage values to block players from spaming list, if your server use tfs 1.x you can set a packet limit per second, default value of 25 is enough.
 
if a guy with a packet editor spam this protocol server will need to make a lot of db querys but packet editor like Winsock Packet Editor is faster than db can query up the list, then your server crash, you can avoid this by instead a db query, or you can create storage values to block players from spaming list, if your server use tfs 1.x you can set a packet limit per second, default value of 25 is enough.
It will hang the server but wont crash it, just a freeze :3 ,the best solution would be."loading list to memory and make server update this list" I advice you to not touch storage too much as they are sql queries too..
 
It will hang the server but wont crash it, just a freeze :3 ,the best solution would be."loading list to memory and make server update this list" I advice you to not touch storage too much as they are sql queries too..
for sure server will crash because mysql will, i meant load to memory in a variable at startup and let the server update the list not the players.
about storages you're wrong, it is loaded to memory at player login, saved on player logout, use storage values is fine because it only execute queries at player login/logout.
 
for sure server will crash because mysql will, i meant load to memory in a variable at startup and let the server update the list not the players.
about storages you're wrong, it is loaded to memory at player login, saved on player logout, use storage values is fine because it only execute queries at player login/logout.
Hmm,Why would mysql crash? it will just freeze,it will keep performing queries and queries but wont crash, there is no reason to update the list if no player is requesting it so best solution would be add the list to a memory and check if the last time it was updated > x minutes
 
Hmm,Why would mysql crash? it will just freeze,it will keep performing queries and queries but wont crash, there is no reason to update the list if no player is requesting it so best solution would be add the list to a memory and check if the last time it was updated > x minutes
just make a simple loop in C to insert query and watch mysql scheduler crash.
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
function onCreatureAppear(cid)  npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid)  npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)  npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink()  npcHandler:eek:nThink() end
-- OTServ event handling functions end
local talkState = {}
local huntN = {}
local huntP = {}

local function checkName(player)
  local sp_id = getPlayerGUIDByName(player)
  if sp_id == nil then
  return FALSE
  end

  local id = 0
  local result_plr = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` = "..sp_id.." AND `killed` = 0;")
  if(result_plr:getID() ~= -1) then
  id = tonumber(result_plr:getDataInt("sp_id"))
  result_plr:free()
  end

  if id ~= sp_id then
  return TRUE
  end
return FALSE
end

local function huntPlayer(cid,player,cost)
local guid = tonumber(getPlayerGUID(cid))
local player = tonumber(getPlayerGUIDByName(player))
local cost = tonumber(cost)

if guid == nil or player == nil or cost == nil then
  return FALSE
end
  db.executeQuery("INSERT INTO `bounty_hunters` VALUES (NULL,"..guid..","..player..",0," .. os.time() .. ","..cost..",0,0);")
  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Hunt has been added successfuly!")
  return TRUE
end

function creatureSayCallback(cid, type, msg)
  -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
if(not(npcHandler:isFocused(cid))) then
  return false
end
  if talkState[cid] == nil then
  talkState[cid] = 0
  end
  if (msgcontains(msg, 'list') then
  local str = {}

  local bountyList = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` > 0")
  if(bountyList:getID() ~= -1) then
  id = tonumber(bountyList:getDataInt("sp_id"))
  table.insert(str, id)
  result_plr:free()
  end

  if str == nil then
  npcHandler:say("No heads prize.", cid)
  else
  doShowTextDialog(cid, 2175, table.concat(str))
  end
  end
  if (msgcontains(msg, 'hunted') or msgcontains(msg, 'yes') or msgcontains(msg, 'hunt')) and talkState[cid] == 0 then
  if(getPlayerLevel(cid) < 50) then
  selfSay('Oh man you are just a kid, come back after take level 50 or more!',cid)
  talkState[cid] = 0
  return true
  end
  selfSay('Oh, you want to kill somebody, don`t you? Tell me, what is his name.',cid)
  talkState[cid] = 1
  elseif talkState[cid] == 1 then
  talkState[cid] = 0
  if checkName(msg) == TRUE then
  huntN[cid] = msg
  selfSay('Okay. Tell me, how much of gold coins will you pay to the killer.',cid)
  talkState[cid] = 2
  else
  selfSay('Sorry, this player is already hunted or does not exist. Really sorry!',cid)
  end
  elseif talkState[cid] == 2 then
  talkState[cid] = 0
  kwota = tonumber(msg)
  if kwota == nil then
  selfSay('What? I don`t understand you.', cid)
  elseif kwota > 100000000 then
  selfSay('Sorry, the maximum amount of gold coins is 100.000.000.', cid)
  elseif kwota < 10000 then
  selfSay('Sorry, the minimum amount of gold coins is 10.000.', cid)
  else
  huntP[cid] =  kwota
  selfSay('Do you want to hunt the player {'..huntN[cid]..'} for {'..huntP[cid]..'} gold coins?', cid)
  talkState[cid] = 3
  end
  elseif talkState[cid] == 3 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveMoney(cid,huntP[cid]) then
   
  if huntPlayer(cid,huntN[cid],huntP[cid]) == TRUE then
  selfSay('You have added the hunt announcement of killing the player {'..huntN[cid]..'} for {'..huntP[cid]..'} gold coins!', cid)
  else
  selfSay('Maybe next time.',cid)
  end
  else
  selfSay('Sorry, you do not have enough money. Maybe next time!',cid)
  end
  else
  selfSay('Maybe next time.',cid)
  end
  talkState[cid]=0
  end
  -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
  return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

What list says?

I've tried your script and fixed easy bugs, like ( no closed... Emoticon on code...

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
function onCreatureAppear(cid)  npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)  npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg) end
function onThink()  npcHandler:onThink()  end
-- OTServ event handling functions end
local talkState = {}
local huntN = {}
local huntP = {}

local function checkName(player)
  local sp_id = getPlayerGUIDByName(player)
  if sp_id == nil then
  return FALSE
  end

  local id = 0
  local result_plr = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` = "..sp_id.." AND `killed` = 0;")
  if(result_plr:getID() ~= -1) then
  id = tonumber(result_plr:getDataInt("sp_id"))
  result_plr:free()
  end

  if id ~= sp_id then
  return TRUE
  end
return FALSE
end

local function huntPlayer(cid,player,cost)
local guid = tonumber(getPlayerGUID(cid))
local player = tonumber(getPlayerGUIDByName(player))
local cost = tonumber(cost)

if guid == nil or player == nil or cost == nil then
  return FALSE
end
  db.executeQuery("INSERT INTO `bounty_hunters` VALUES (NULL,"..guid..","..player..",0," .. os.time() .. ","..cost..",0,0);")
  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Hunt has been added successfuly!")
  return TRUE
end

function creatureSayCallback(cid, type, msg)
  -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
if(not(npcHandler:isFocused(cid))) then
  return false
end
  if talkState[cid] == nil then
  talkState[cid] = 0
  end
  if (msgcontains(msg, 'list')) then
  local str = {}

  local bountyList = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` > 0")
  if(bountyList:getID() ~= -1) then
  id = tonumber(bountyList:getDataInt("sp_id"))
  table.insert(str, id)
  result_plr:free()
  end

  if str == nil then
  npcHandler:say("No heads prize.", cid)
  else
  doShowTextDialog(cid, 2175, table.concat(str))
  end
  end
  if (msgcontains(msg, 'hunted') or msgcontains(msg, 'yes') or msgcontains(msg, 'hunt')) and talkState[cid] == 0 then
  if(getPlayerLevel(cid) < 50) then
  selfSay('Oh man you are just a kid, come back after take level 50 or more!',cid)
  talkState[cid] = 0
  return true
  end
  selfSay('Oh, you want to kill somebody, don`t you? Tell me, what is his name.',cid)
  talkState[cid] = 1
  elseif talkState[cid] == 1 then
  talkState[cid] = 0
  if checkName(msg) == TRUE then
  huntN[cid] = msg
  selfSay('Okay. Tell me, how much of gold coins will you pay to the killer.',cid)
  talkState[cid] = 2
  else
  selfSay('Sorry, this player is already hunted or does not exist. Really sorry!',cid)
  end
  elseif talkState[cid] == 2 then
  talkState[cid] = 0
  kwota = tonumber(msg)
  if kwota == nil then
  selfSay('What? I don`t understand you.', cid)
  elseif kwota > 100000000 then
  selfSay('Sorry, the maximum amount of gold coins is 100.000.000.', cid)
  elseif kwota < 10000 then
  selfSay('Sorry, the minimum amount of gold coins is 10.000.', cid)
  else
  huntP[cid] =  kwota
  selfSay('Do you want to hunt the player {'..huntN[cid]..'} for {'..huntP[cid]..'} gold coins?', cid)
  talkState[cid] = 3
  end
  elseif talkState[cid] == 3 then
  if msgcontains(msg, 'yes') then
  if doPlayerRemoveMoney(cid,huntP[cid]) then
   
  if huntPlayer(cid,huntN[cid],huntP[cid]) == TRUE then
  selfSay('You have added the hunt announcement of killing the player {'..huntN[cid]..'} for {'..huntP[cid]..'} gold coins!', cid)
  else
  selfSay('Maybe next time.',cid)
  end
  else
  selfSay('Sorry, you do not have enough money. Maybe next time!',cid)
  end
  else
  selfSay('Maybe next time.',cid)
  end
  talkState[cid]=0
  end
  -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
  return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

But got some errors:
Code:
[0:4:49.053] [Error - NpcScript Interface]
[0:4:49.053] data/npc/scripts/bountyhunters.lua:onCreatureSay
[0:4:49.053] Description:
[0:4:49.053] data/npc/scripts/bountyhunters.lua:61: attempt to index global 'result_plr' (a nil value)
[0:4:49.053] stack traceback:
[0:4:49.053]  data/npc/scripts/bountyhunters.lua:61: in function 'callback'
[0:4:49.053]  data/npc/lib/npcsystem/npchandler.lua:423: in function 'onCreatureSay'
[0:4:49.054]  data/npc/scripts/bountyhunters.lua:7: in function <data/npc/scripts/bountyhunters.lua:7>


---




About the BUG, ty to warning
Is possible fix using a storage and something like timer or anyother way?
 
Now:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
-- OTServ event handling functions end
local talkState = {}
local huntN = {}
local huntP = {}

local function checkName(player)
local sp_id = getPlayerGUIDByName(player)
if sp_id == nil then
return FALSE
end

local id = 0
local result_plr = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` = "..sp_id.." AND `killed` = 0;")
if(result_plr:getID() ~= -1) then
id = tonumber(result_plr:getDataInt("sp_id"))
result_plr:free()
end

if id ~= sp_id then
return TRUE
end
return FALSE
end

local function huntPlayer(cid,player,cost)
local guid = tonumber(getPlayerGUID(cid))
local player = tonumber(getPlayerGUIDByName(player))
local cost = tonumber(cost)

if guid == nil or player == nil or cost == nil then
return FALSE
end
db.executeQuery("INSERT INTO `bounty_hunters` VALUES (NULL,"..guid..","..player..",0," .. os.time() .. ","..cost..",0,0);")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Hunt has been added successfuly!")
return TRUE
end

function creatureSayCallback(cid, type, msg)
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
if(not(npcHandler:isFocused(cid))) then
return false
end
if talkState[cid] == nil then
talkState[cid] = 0
end
if (msgcontains(msg, 'list')) then
local str = {}

local bountyList = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` > 0")
if(bountyList:getID() ~= -1) then
id = tonumber(bountyList:getDataInt("sp_id"))
table.insert(str, id)
bountyList:free()
end

if str == nil then
npcHandler:say("No heads prize.", cid)
else
doShowTextDialog(cid, 2175, table.concat(str))
end
end
if (msgcontains(msg, 'hunted') or msgcontains(msg, 'yes') or msgcontains(msg, 'hunt')) and talkState[cid] == 0 then
if(getPlayerLevel(cid) < 50) then
selfSay('Oh man you are just a kid, come back after take level 50 or more!',cid)
talkState[cid] = 0
return true
end
selfSay('Oh, you want to kill somebody, don`t you? Tell me, what is his name.',cid)
talkState[cid] = 1
elseif talkState[cid] == 1 then
talkState[cid] = 0
if checkName(msg) == TRUE then
huntN[cid] = msg
selfSay('Okay. Tell me, how much of gold coins will you pay to the killer.',cid)
talkState[cid] = 2
else
selfSay('Sorry, this player is already hunted or does not exist. Really sorry!',cid)
end
elseif talkState[cid] == 2 then
talkState[cid] = 0
kwota = tonumber(msg)
if kwota == nil then
selfSay('What? I don`t understand you.', cid)
elseif kwota > 100000000 then
selfSay('Sorry, the maximum amount of gold coins is 100.000.000.', cid)
elseif kwota < 10000 then
selfSay('Sorry, the minimum amount of gold coins is 10.000.', cid)
else
huntP[cid] = kwota
selfSay('Do you want to hunt the player {'..huntN[cid]..'} for {'..huntP[cid]..'} gold coins?', cid)
talkState[cid] = 3
end
elseif talkState[cid] == 3 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveMoney(cid,huntP[cid]) then

if huntPlayer(cid,huntN[cid],huntP[cid]) == TRUE then
selfSay('You have added the hunt announcement of killing the player {'..huntN[cid]..'} for {'..huntP[cid]..'} gold coins!', cid)
else
selfSay('Maybe next time.',cid)
end
else
selfSay('Sorry, you do not have enough money. Maybe next time!',cid)
end
else
selfSay('Maybe next time.',cid)
end
talkState[cid]=0
end
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Now:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
-- OTServ event handling functions end
local talkState = {}
local huntN = {}
local huntP = {}

local function checkName(player)
local sp_id = getPlayerGUIDByName(player)
if sp_id == nil then
return FALSE
end

local id = 0
local result_plr = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` = "..sp_id.." AND `killed` = 0;")
if(result_plr:getID() ~= -1) then
id = tonumber(result_plr:getDataInt("sp_id"))
result_plr:free()
end

if id ~= sp_id then
return TRUE
end
return FALSE
end

local function huntPlayer(cid,player,cost)
local guid = tonumber(getPlayerGUID(cid))
local player = tonumber(getPlayerGUIDByName(player))
local cost = tonumber(cost)

if guid == nil or player == nil or cost == nil then
return FALSE
end
db.executeQuery("INSERT INTO `bounty_hunters` VALUES (NULL,"..guid..","..player..",0," .. os.time() .. ","..cost..",0,0);")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Hunt has been added successfuly!")
return TRUE
end

function creatureSayCallback(cid, type, msg)
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
if(not(npcHandler:isFocused(cid))) then
return false
end
if talkState[cid] == nil then
talkState[cid] = 0
end
if (msgcontains(msg, 'list')) then
local str = {}

local bountyList = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` > 0")
if(bountyList:getID() ~= -1) then
id = tonumber(bountyList:getDataInt("sp_id"))
table.insert(str, id)
bountyList:free()
end

if str == nil then
npcHandler:say("No heads prize.", cid)
else
doShowTextDialog(cid, 2175, table.concat(str))
end
end
if (msgcontains(msg, 'hunted') or msgcontains(msg, 'yes') or msgcontains(msg, 'hunt')) and talkState[cid] == 0 then
if(getPlayerLevel(cid) < 50) then
selfSay('Oh man you are just a kid, come back after take level 50 or more!',cid)
talkState[cid] = 0
return true
end
selfSay('Oh, you want to kill somebody, don`t you? Tell me, what is his name.',cid)
talkState[cid] = 1
elseif talkState[cid] == 1 then
talkState[cid] = 0
if checkName(msg) == TRUE then
huntN[cid] = msg
selfSay('Okay. Tell me, how much of gold coins will you pay to the killer.',cid)
talkState[cid] = 2
else
selfSay('Sorry, this player is already hunted or does not exist. Really sorry!',cid)
end
elseif talkState[cid] == 2 then
talkState[cid] = 0
kwota = tonumber(msg)
if kwota == nil then
selfSay('What? I don`t understand you.', cid)
elseif kwota > 100000000 then
selfSay('Sorry, the maximum amount of gold coins is 100.000.000.', cid)
elseif kwota < 10000 then
selfSay('Sorry, the minimum amount of gold coins is 10.000.', cid)
else
huntP[cid] = kwota
selfSay('Do you want to hunt the player {'..huntN[cid]..'} for {'..huntP[cid]..'} gold coins?', cid)
talkState[cid] = 3
end
elseif talkState[cid] == 3 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveMoney(cid,huntP[cid]) then

if huntPlayer(cid,huntN[cid],huntP[cid]) == TRUE then
selfSay('You have added the hunt announcement of killing the player {'..huntN[cid]..'} for {'..huntP[cid]..'} gold coins!', cid)
else
selfSay('Maybe next time.',cid)
end
else
selfSay('Sorry, you do not have enough money. Maybe next time!',cid)
end
else
selfSay('Maybe next time.',cid)
end
talkState[cid]=0
end
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

It's show me:
Code:
22
When I said hi,list
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
-- OTServ event handling functions end
local talkState = {}
local huntN = {}
local huntP = {}

local function checkName(player)
local sp_id = getPlayerGUIDByName(player)
if sp_id == nil then
return FALSE
end

local id = 0
local result_plr = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` = "..sp_id.." AND `killed` = 0;")
if(result_plr:getID() ~= -1) then
id = tonumber(result_plr:getDataInt("sp_id"))
result_plr:free()
end

if id ~= sp_id then
return TRUE
end
return FALSE
end

local function huntPlayer(cid,player,cost)
local guid = tonumber(getPlayerGUID(cid))
local player = tonumber(getPlayerGUIDByName(player))
local cost = tonumber(cost)

if guid == nil or player == nil or cost == nil then
return FALSE
end
db.executeQuery("INSERT INTO `bounty_hunters` VALUES (NULL,"..guid..","..player..",0," .. os.time() .. ","..cost..",0,0);")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Hunt has been added successfuly!")
return TRUE
end

function creatureSayCallback(cid, type, msg)
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
if(not(npcHandler:isFocused(cid))) then
return false
end
if talkState[cid] == nil then
talkState[cid] = 0
end
if (msgcontains(msg, 'list')) then
local str = {}

local bountyList = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` > 0")
if(bountyList:getID() ~= -1) then
repeat
  id = tonumber(bountyList:getDataInt("sp_id"))
  table.insert(str, id)
until not bountyList:next()
end

if str == nil then
npcHandler:say("No heads prize.", cid)
else
doShowTextDialog(cid, 2175, table.concat(str))
end
end
if (msgcontains(msg, 'hunted') or msgcontains(msg, 'yes') or msgcontains(msg, 'hunt')) and talkState[cid] == 0 then
if(getPlayerLevel(cid) < 50) then
selfSay('Oh man you are just a kid, come back after take level 50 or more!',cid)
talkState[cid] = 0
return true
end
selfSay('Oh, you want to kill somebody, don`t you? Tell me, what is his name.',cid)
talkState[cid] = 1
elseif talkState[cid] == 1 then
talkState[cid] = 0
if checkName(msg) == TRUE then
huntN[cid] = msg
selfSay('Okay. Tell me, how much of gold coins will you pay to the killer.',cid)
talkState[cid] = 2
else
selfSay('Sorry, this player is already hunted or does not exist. Really sorry!',cid)
end
elseif talkState[cid] == 2 then
talkState[cid] = 0
kwota = tonumber(msg)
if kwota == nil then
selfSay('What? I don`t understand you.', cid)
elseif kwota > 100000000 then
selfSay('Sorry, the maximum amount of gold coins is 100.000.000.', cid)
elseif kwota < 10000 then
selfSay('Sorry, the minimum amount of gold coins is 10.000.', cid)
else
huntP[cid] = kwota
selfSay('Do you want to hunt the player {'..huntN[cid]..'} for {'..huntP[cid]..'} gold coins?', cid)
talkState[cid] = 3
end
elseif talkState[cid] == 3 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveMoney(cid,huntP[cid]) then

if huntPlayer(cid,huntN[cid],huntP[cid]) == TRUE then
selfSay('You have added the hunt announcement of killing the player {'..huntN[cid]..'} for {'..huntP[cid]..'} gold coins!', cid)
else
selfSay('Maybe next time.',cid)
end
else
selfSay('Sorry, you do not have enough money. Maybe next time!',cid)
end
else
selfSay('Maybe next time.',cid)
end
talkState[cid]=0
end
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

This should add player ids to the table, now all you have to do it find function similar to this "getPlayerNameByGUID()" and replace this:
table.insert(str, getPlayerNameByGUID(id))
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
-- OTServ event handling functions end
local talkState = {}
local huntN = {}
local huntP = {}

local function checkName(player)
local sp_id = getPlayerGUIDByName(player)
if sp_id == nil then
return FALSE
end

local id = 0
local result_plr = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` = "..sp_id.." AND `killed` = 0;")
if(result_plr:getID() ~= -1) then
id = tonumber(result_plr:getDataInt("sp_id"))
result_plr:free()
end

if id ~= sp_id then
return TRUE
end
return FALSE
end

local function huntPlayer(cid,player,cost)
local guid = tonumber(getPlayerGUID(cid))
local player = tonumber(getPlayerGUIDByName(player))
local cost = tonumber(cost)

if guid == nil or player == nil or cost == nil then
return FALSE
end
db.executeQuery("INSERT INTO `bounty_hunters` VALUES (NULL,"..guid..","..player..",0," .. os.time() .. ","..cost..",0,0);")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Hunt has been added successfuly!")
return TRUE
end

function creatureSayCallback(cid, type, msg)
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
if(not(npcHandler:isFocused(cid))) then
return false
end
if talkState[cid] == nil then
talkState[cid] = 0
end
if (msgcontains(msg, 'list')) then
local str = {}

local bountyList = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` > 0")
if(bountyList:getID() ~= -1) then
repeat
  id = tonumber(bountyList:getDataInt("sp_id"))
  table.insert(str, id)
until not bountyList:next()
end

if str == nil then
npcHandler:say("No heads prize.", cid)
else
doShowTextDialog(cid, 2175, table.concat(str))
end
end
if (msgcontains(msg, 'hunted') or msgcontains(msg, 'yes') or msgcontains(msg, 'hunt')) and talkState[cid] == 0 then
if(getPlayerLevel(cid) < 50) then
selfSay('Oh man you are just a kid, come back after take level 50 or more!',cid)
talkState[cid] = 0
return true
end
selfSay('Oh, you want to kill somebody, don`t you? Tell me, what is his name.',cid)
talkState[cid] = 1
elseif talkState[cid] == 1 then
talkState[cid] = 0
if checkName(msg) == TRUE then
huntN[cid] = msg
selfSay('Okay. Tell me, how much of gold coins will you pay to the killer.',cid)
talkState[cid] = 2
else
selfSay('Sorry, this player is already hunted or does not exist. Really sorry!',cid)
end
elseif talkState[cid] == 2 then
talkState[cid] = 0
kwota = tonumber(msg)
if kwota == nil then
selfSay('What? I don`t understand you.', cid)
elseif kwota > 100000000 then
selfSay('Sorry, the maximum amount of gold coins is 100.000.000.', cid)
elseif kwota < 10000 then
selfSay('Sorry, the minimum amount of gold coins is 10.000.', cid)
else
huntP[cid] = kwota
selfSay('Do you want to hunt the player {'..huntN[cid]..'} for {'..huntP[cid]..'} gold coins?', cid)
talkState[cid] = 3
end
elseif talkState[cid] == 3 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveMoney(cid,huntP[cid]) then

if huntPlayer(cid,huntN[cid],huntP[cid]) == TRUE then
selfSay('You have added the hunt announcement of killing the player {'..huntN[cid]..'} for {'..huntP[cid]..'} gold coins!', cid)
else
selfSay('Maybe next time.',cid)
end
else
selfSay('Sorry, you do not have enough money. Maybe next time!',cid)
end
else
selfSay('Maybe next time.',cid)
end
talkState[cid]=0
end
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

This should add player ids to the table, now all you have to do it find function similar to this "getPlayerNameByGUID()" and replace this:
table.insert(str, getPlayerNameByGUID(id))

Now show me
Code:
222218
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
-- OTServ event handling functions end
local talkState = {}
local huntN = {}
local huntP = {}

local function checkName(player)
local sp_id = getPlayerGUIDByName(player)
if sp_id == nil then
return FALSE
end

local id = 0
local result_plr = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` = "..sp_id.." AND `killed` = 0;")
if(result_plr:getID() ~= -1) then
id = tonumber(result_plr:getDataInt("sp_id"))
result_plr:free()
end

if id ~= sp_id then
return TRUE
end
return FALSE
end

local function huntPlayer(cid,player,cost)
local guid = tonumber(getPlayerGUID(cid))
local player = tonumber(getPlayerGUIDByName(player))
local cost = tonumber(cost)

if guid == nil or player == nil or cost == nil then
return FALSE
end
db.executeQuery("INSERT INTO `bounty_hunters` VALUES (NULL,"..guid..","..player..",0," .. os.time() .. ","..cost..",0,0);")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Hunt has been added successfuly!")
return TRUE
end

function creatureSayCallback(cid, type, msg)
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
if(not(npcHandler:isFocused(cid))) then
return false
end
if talkState[cid] == nil then
talkState[cid] = 0
end
if (msgcontains(msg, 'list')) then
local str = {}

local bountyList = db.getResult("SELECT * FROM `bounty_hunters` WHERE `id` > 0")
if(bountyList:getID() ~= -1) then
repeat
ids = tonumber(bountyList:getDataInt("id"))
table.insert(str, ids)
until not bountyList:next()
end

if str == nil then
npcHandler:say("No heads prize.", cid)
else
doShowTextDialog(cid, 2175, table.concat(str, ", "))
end
end
if (msgcontains(msg, 'hunted') or msgcontains(msg, 'yes') or msgcontains(msg, 'hunt')) and talkState[cid] == 0 then
if(getPlayerLevel(cid) < 50) then
selfSay('Oh man you are just a kid, come back after take level 50 or more!',cid)
talkState[cid] = 0
return true
end
selfSay('Oh, you want to kill somebody, don`t you? Tell me, what is his name.',cid)
talkState[cid] = 1
elseif talkState[cid] == 1 then
talkState[cid] = 0
if checkName(msg) == TRUE then
huntN[cid] = msg
selfSay('Okay. Tell me, how much of gold coins will you pay to the killer.',cid)
talkState[cid] = 2
else
selfSay('Sorry, this player is already hunted or does not exist. Really sorry!',cid)
end
elseif talkState[cid] == 2 then
talkState[cid] = 0
kwota = tonumber(msg)
if kwota == nil then
selfSay('What? I don`t understand you.', cid)
elseif kwota > 100000000 then
selfSay('Sorry, the maximum amount of gold coins is 100.000.000.', cid)
elseif kwota < 10000 then
selfSay('Sorry, the minimum amount of gold coins is 10.000.', cid)
else
huntP[cid] = kwota
selfSay('Do you want to hunt the player {'..huntN[cid]..'} for {'..huntP[cid]..'} gold coins?', cid)
talkState[cid] = 3
end
elseif talkState[cid] == 3 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveMoney(cid,huntP[cid]) then

if huntPlayer(cid,huntN[cid],huntP[cid]) == TRUE then
selfSay('You have added the hunt announcement of killing the player {'..huntN[cid]..'} for {'..huntP[cid]..'} gold coins!', cid)
else
selfSay('Maybe next time.',cid)
end
else
selfSay('Sorry, you do not have enough money. Maybe next time!',cid)
end
else
selfSay('Maybe next time.',cid)
end
talkState[cid]=0
end
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
It's all i can do now you've got player ids in the TextDialog you need to convert that ids to player names
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
-- OTServ event handling functions end
local talkState = {}
local huntN = {}
local huntP = {}

local function checkName(player)
local sp_id = getPlayerGUIDByName(player)
if sp_id == nil then
return FALSE
end

local id = 0
local result_plr = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` = "..sp_id.." AND `killed` = 0;")
if(result_plr:getID() ~= -1) then
id = tonumber(result_plr:getDataInt("sp_id"))
result_plr:free()
end

if id ~= sp_id then
return TRUE
end
return FALSE
end

local function huntPlayer(cid,player,cost)
local guid = tonumber(getPlayerGUID(cid))
local player = tonumber(getPlayerGUIDByName(player))
local cost = tonumber(cost)

if guid == nil or player == nil or cost == nil then
return FALSE
end
db.executeQuery("INSERT INTO `bounty_hunters` VALUES (NULL,"..guid..","..player..",0," .. os.time() .. ","..cost..",0,0);")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[BOUNTY HUNTERS] Hunt has been added successfuly!")
return TRUE
end

function creatureSayCallback(cid, type, msg)
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
if(not(npcHandler:isFocused(cid))) then
return false
end
if talkState[cid] == nil then
talkState[cid] = 0
end
if (msgcontains(msg, 'list')) then
local str = {}

local bountyList = db.getResult("SELECT * FROM `bounty_hunters` WHERE `id` > 0")
if(bountyList:getID() ~= -1) then
repeat
ids = tonumber(bountyList:getDataInt("id"))
table.insert(str, ids)
until not bountyList:next()
end

if str == nil then
npcHandler:say("No heads prize.", cid)
else
doShowTextDialog(cid, 2175, table.concat(str, ", "))
end
end
if (msgcontains(msg, 'hunted') or msgcontains(msg, 'yes') or msgcontains(msg, 'hunt')) and talkState[cid] == 0 then
if(getPlayerLevel(cid) < 50) then
selfSay('Oh man you are just a kid, come back after take level 50 or more!',cid)
talkState[cid] = 0
return true
end
selfSay('Oh, you want to kill somebody, don`t you? Tell me, what is his name.',cid)
talkState[cid] = 1
elseif talkState[cid] == 1 then
talkState[cid] = 0
if checkName(msg) == TRUE then
huntN[cid] = msg
selfSay('Okay. Tell me, how much of gold coins will you pay to the killer.',cid)
talkState[cid] = 2
else
selfSay('Sorry, this player is already hunted or does not exist. Really sorry!',cid)
end
elseif talkState[cid] == 2 then
talkState[cid] = 0
kwota = tonumber(msg)
if kwota == nil then
selfSay('What? I don`t understand you.', cid)
elseif kwota > 100000000 then
selfSay('Sorry, the maximum amount of gold coins is 100.000.000.', cid)
elseif kwota < 10000 then
selfSay('Sorry, the minimum amount of gold coins is 10.000.', cid)
else
huntP[cid] = kwota
selfSay('Do you want to hunt the player {'..huntN[cid]..'} for {'..huntP[cid]..'} gold coins?', cid)
talkState[cid] = 3
end
elseif talkState[cid] == 3 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveMoney(cid,huntP[cid]) then

if huntPlayer(cid,huntN[cid],huntP[cid]) == TRUE then
selfSay('You have added the hunt announcement of killing the player {'..huntN[cid]..'} for {'..huntP[cid]..'} gold coins!', cid)
else
selfSay('Maybe next time.',cid)
end
else
selfSay('Sorry, you do not have enough money. Maybe next time!',cid)
end
else
selfSay('Maybe next time.',cid)
end
talkState[cid]=0
end
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
It's all i can do now you've got player ids in the TextDialog you need to convert that ids to player names

Now showing, when i say list show
Code:
1,2,3

How to load in mysql target name, price, who set target?

bump

bump
 
Last edited by a moderator:
Back
Top