NPC Levels

Hi,

i tried to create NPC’s level but it doesn’t work :confused:

Thx for help <3

CODE:

Use


 tags.

I would be glad to help you, but you are a leaker lol.

kk ^^

[editline]9th August 2015[/editline]

Anyone else?

dude, you posted a thread like an hour ago and now you need more help… it makes me come to think you’re not trying at all.

You’re calling the 3rd, 4th, and 5th keys of the table even though they don’t exist.

Just use math.random instead of table.random, and make minval + maxval, much “smoother”. #GermanyFTW and use CODE/LUA tags.

table.Random literally uses math.random internally.

table.Random iterates over the given table twice.


function table.Random( t )
	local rk = math.random( 1, table.Count( t ) )
	local i = 1
	for k, v in pairs( t ) do 
		if ( i == rk ) then return v, k end
		i = i + 1 
	end
end

It’s better to do:


x = sometable[ math.random( #sometable ) ]

If you know for certain that the table is flat and numerically indexed.

I didnt mean math.random to loop through the table, I mean math.random to use it, just as it was used to, minxp, maxxp, simple.