Jump to content

Get a free number (npc id)


JeViCo

Recommended Posts

9 minutes ago, JeViCo said:

Hello everyone! I have a list of numbers from 1 to 100 (ids of npcs). Player take a quest to kill one. How can i avoid the quest where 2 and more players have to kill the same npc? How can i get unused npc's id?

use tables .. 

insert the used id to the table and check that the id isn't in the table when a player try to take a quest 

ex .. 

local myTable = {}
addCommandHandler("q",
  function(p,_,n)
    local n = tonumber(n)
    if not myTable[n] then
      outputChatBox("number inserted to table .. ", p)
      myTable[n] = true
    else
      outputChatBox("this number is already inserted to the table", p)
    end
  end
)

 

  • Thanks 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...