• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Help with NPCs and sorting values in LUA

Summ

(\/)(;,,;)(\/) Y not?
Staff member
Global Moderator
Joined
Oct 15, 2008
Messages
4,136
Solutions
12
Reaction score
1,115
Location
Germany :O
Hello
I have some nice ideas, but I need some functions/help..

1. How can I make a NPC say something if someone enters the screen?
It somehow possible with onThink functions? Please post a example.

2. If I got some numbers how I can make a ranking?
Code:
one = getPlayerStorageValue(cid,1001)
two = getPlayerStorageValue(cid,1002)
three = getPlayerStorageValue(cid,1003)
...
twenty = getPlayerStorageValue(cid,1020)
How can I make it so the script gets the values and sorts them from highest to the lowest?
 
Last edited:
And how do I make it that it only says it to one person each 20 secs and not if the player leaves the screen for 2 sec and comes again?

No one can help me with the second question??
It's important..
 
About sorting, you can pack all these values into table and use table.sort

for example:
local t = {}
table.insert(t, 3)
table.insert(t, 400)
table.insert(t, 7)
table.insert(t, 1)
table.sort(t, function(a, b) return a > b end)

t[1] -- your highest value
t[#t] -- your lowest value

if you want from lowest to highest just change in this part - a > b to <


second way is normal if statement if you don't have much numbers
 
Back
Top