• 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 Npc get a number from player

lhc00

New Member
Joined
Mar 23, 2010
Messages
23
Reaction score
0
I would like to know how do I make a npc that can receive a number of the player and execute the code based on the number.

E.g: The player type a number, and the number typed will be the ActionID of the item that will be given to the player. I've tried the old method of versions before 8.4, using getCount, but it didn't worked =X

Thx by the help :D
 
use something like this: (excluding the npc parameters etc....)(not sober enough from alcohol to do that xD)

Lua:
if tonumber(param) > 0 and tonumber(param) < 1300 then
	doSetItemSpecialDescription(doPlayerGiveItem(cid,itemid,count),'aid',param)
elseif tonumber(param) == nil or tonumber(param) > 0 and tonumber(param) > 1300 then
	doPlayerSendCancel(cid,'Choose a number betweeen 0 and 1300')
end
 
I've tried to use tonumber(msg) but it didn't work, the error that is showed on the console is:

attempt to compare number with nil

I've tried remove tonumber, and the error was:

attempt to compare number with string

o_O
 
The problem is that shouldn't return nil, i typed on tibia a number, and the console is saying that is nil, here is the part of the code:

Code:
if talkState[talkUser] == 2 then
             num = tonumber(msg)
                if num > 0 then 
                doItemSetAttribute(doPlayerAddItem(cid, 6092, 1), 'aid', num) 
                end
end
 
I think the problem is that the npc is getting the value before the player type the value, Someone knows how to make the npc wait for an answer?
 
Back
Top