• 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!

Lua Spawn Monster with random chance

Extort

New Member
Joined
Apr 14, 2011
Messages
31
Reaction score
0
I do not make many scripts so i was wondering why this wasn't working. I am using TFS 8.7 Mystic Spirit.

Code:
function onStepIn(cid, item, frompos, item2, topos)
	local dice = math.random(1, 5000)
	local tile1 = {x=1090, y=744, z=7}
	local tile2 = {x=1090, y=744, z=7}
	local tile3 = {x=1090, y=744, z=7}
	local tile4 = {x=1090, y=744, z=7}
	local tile5 = {x=1090, y=744, z=7}	
	local tile6 = {x=1091, y=744, z=7}
 
	if item.actionid == 6500 and dice == 1 then
		doSummonCreature(rotworm, tile1)
	else if item.actionid == 6500 and dice == 3 then
		doSummonCreature(rotworm, tile2)
	else if item.actionid == 6500 and dice == 7 then
		doSummonCreature(rotworm, tile3)	
	else if item.actionid == 6500 and dice == 9 then
		doSummonCreature(rotworm, tile4)	
	else if item.actionid == 6500 and dice == 9 then
		doSummonCreature(rotworm, tile5)		
	else if item.actionid == 6500 and dice > 1 then
		doSummonCreature(rotworm, tile6)	
	end
	end
	end
	end
	end
	end
	return TRUE
end


This is the error i got.

Code:
[27/04/2011 20:23:45] Lua Script Error: [MoveEvents Interface] 
[27/04/2011 20:23:45] data/movements/scripts/rare spawns.lua:onStepIn
[27/04/2011 20:23:45] luaDoSummonCreature(). Monster name() not found
[27/04/2011 20:23:45] stack traceback:
[27/04/2011 20:23:45] 	[C]: in function 'doSummonCreature'
[27/04/2011 20:23:45] 	data/movements/scripts/rare spawns.lua:21: in function <data/movements/scripts/rare spawns.lua:1>

I wanted the script to have a random chance to spawn a mob at a few different locations when someone walks onto a tile with the action id of 6500.
 
Im not sure but check if you have it in 050-function
PHP:
function doSummonCreature(name, pos, displayError)
	local displayError, cid = displayError or true, doCreateMonster(name, pos, displayError)
	if(not cid) then
		cid = doCreateNpc(name, pos, displayError)
	end

	return cid
end
 
How can i check that? I never had to check if i had a function or add one.

Okay i feel stupid, i just looked at a different server. The one i am using doesn't have the Lib folder. So i do not have any of the functions in there. It is 0.2, 8.7 TFS so is there anything i can do?
 
Last edited:
We first open 050-function in data\lib
Once open you have to pressed CTRL + B
Will open a table that will put search
Then put it "doSummonCreature"
 
I just edited my other post. Seems like it was to late, the 8.7, 0.2.10 TFS server i am using doesn't have the Data/Lib folder. What should i do?
 
Then what about a 8.6 server? I DL'd an 8.6 server (OTServ 8.60 (rev 5795)) and there is a functions.lua file but no doSummonCreature so it wouldn't work on that server too right? How could i get it to work?
 
Back
Top