• 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 script problem since update

cire2003

New Member
Joined
May 31, 2008
Messages
29
Reaction score
0
i updated to the beta version recently. b4 i was using a script that was summoning some monster around the person who "liberated" the monster. now i got 2 errors :blink:.

1-when i open the server i get "luaGetCreaturePosition(). Creature not found".

2-when the script is activated i get "luaDoSummonCReature(). Can not summon monster : ~monster name~"

and here is my code.

Code:
local function summon(parameters)
	pos = {parameters.frompos.x+1, parameters.frompos.y, parameters.frompos.z}
	doPlayerSendCancel(parameters.cid, pos)
	doSummonCreature(parameters.name, parameters.frompos)
	return 1
end

pos = getPlayerPosition(cid)

function onUse(cid, item, frompos, item2, topos)

random = math.random(1,2)

if item.itemid == 5957 and item.actionid == 0 then
	if random == 1 then
		doRemoveItem(item.uid,1)
		doSendAnimatedText(getPlayerPosition(cid), "Empty! :(", 3)
		doSendMagicEffect(getPlayerPosition(cid),0)		
	elseif random == 2 then
		doRemoveItem(item.uid,1)
		doSendAnimatedText(getPlayerPosition(cid), "Hummmm...", 1)
		doSendMagicEffect(getPlayerPosition(cid),0)		
		random2 = math.random(1,2)
		if random2 == 1 then
			name = "Guard"
		elseif random2 == 2 then
			name = "Warrior"
		end
		local parameters = {cid=cid, name=name, frompos=frompos}
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "The scroll was trapped! A " ..name.. " will be summoned!!!")
		addEvent(summon, 2500, parameters)
	end

tks :p
 
i updated to the beta version recently. b4 i was using a script that was summoning some monster around the person who "liberated" the monster. now i got 2 errors :blink:.

1-when i open the server i get "luaGetCreaturePosition(). Creature not found".

2-when the script is activated i get "luaDoSummonCReature(). Can not summon monster : ~monster name~"

and here is my code.

Code:
local function summon(parameters)
	pos = {parameters.frompos.x+1, parameters.frompos.y, parameters.frompos.z}
	doPlayerSendCancel(parameters.cid, pos)
	doSummonCreature(parameters.name, parameters.frompos)
	return 1
end

pos = getPlayerPosition(cid)

function onUse(cid, item, frompos, item2, topos)

random = math.random(1,2)

if item.itemid == 5957 and item.actionid == 0 then
	if random == 1 then
		doRemoveItem(item.uid,1)
		doSendAnimatedText(getPlayerPosition(cid), "Empty! :(", 3)
		doSendMagicEffect(getPlayerPosition(cid),0)		
	elseif random == 2 then
		doRemoveItem(item.uid,1)
		doSendAnimatedText(getPlayerPosition(cid), "Hummmm...", 1)
		doSendMagicEffect(getPlayerPosition(cid),0)		
		random2 = math.random(1,2)
		if random2 == 1 then
			name = "Guard"
		elseif random2 == 2 then
			name = "Warrior"
		end
		local parameters = {cid=cid, name=name, frompos=frompos}
		doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "The scroll was trapped! A " ..name.. " will be summoned!!!")
		addEvent(summon, 2500, parameters)
	end

tks :p

I bet you had it before too, because of this line:
Code:
pos = getPlayerPosition(cid)

It is outside of the functions, therefore 'cid' returns nil.
Put it below function [...]
 
tks, i changed it and it corrected the problem #1. i still got my second problem but i understood that its in how im calling my function summon. tryed few things and didnt found anyway how to make it work. is there any other way then calling a function to do a timer b4 something is executed?
 
You must add how many creatures you want to summon.
Like this:

Code:
doSummonCreature("Demon",pos,1)

And of course you will declare what "pos" is.
 
doPlayerSendCancel(parameters.cid, pos)

you cant send a pos as msg? o_O

"cannot summon monster" is because there's no room i guess, i think it's more strict now like monsters that can get hurt by fire can't be summoned on fire (not sure though, just seemed that way when i tried summoning a monster on fire)...
 
doPlayerSendCancel(parameters.cid, pos)

you cant send a pos as msg? o_O

"cannot summon monster" is because there's no room i guess, i think it's more strict now like monsters that can get hurt by fire can't be summoned on fire (not sure though, just seemed that way when i tried summoning a monster on fire)...



Pro scripter ^^, I guess that'd be an answer for the problem. Reputation ++ :)
 
doPlayerSendCancel(parameters.cid, pos)

you cant send a pos as msg? o_O

"cannot summon monster" is because there's no room i guess, i think it's more strict now like monsters that can get hurt by fire can't be summoned on fire (not sure though, just seemed that way when i tried summoning a monster on fire)...

yea, u could have been right on that 1. finally i solved my problem somehow else. problem was when i was using the pos declaration. and since i was allready getting the player pos with parameters, finding it back was done for nothing and just occasionating unknow problem. used only what was called with the fonction, and working well now :p tks tought
 
Back
Top Bottom