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

Clary

New Member
Joined
Mar 7, 2008
Messages
1,007
Reaction score
1
Well as some of u here know that i am trying to learn Lua

while trying to create my first move script i got this error can anyone help?
PHP:
function onStepIn(cid, item, pos)
	if item.actionid == 2579 then
		if isPlayer(cid) ~= TRUE then		
doConvinceSummon(cid, Training Monk, 0, summonplayerpos)
summonplayerpos = {x=1008, y=1042, z=7, stackpos=253}
summonplayer = getThingfromPos(summonplayerpos)
end
return 0
end
return 1
and i get this error
Code:
[26/05/2008  12:51:56] Warning: [Event::loadScript] Can not load script. data/movements/scripts/not used/floor.lua
[26/05/2008  12:51:56] data/movements/scripts/not used/floor.lua:4: ')' expected near 'Monk'

and lua function i am using:
Global.lua
PHP:
function doConvinceSummon(cid, creature, amount, pos)
summonplayerpos = {x=pos.x, y=pos.y, z=pos.z, stackpos=253}
summonplayer = getThingfromPos(summonplayerpos)
 
 
    if(summonplayer ~= nil and summonplayer.itemid > 0) then    
        doPlayerSendCancel(cid,"There is not enough room to summon here.")
        ret = 0
    else
        convince = doSummonCreature(creature, pos)
        doConvinceCreature(cid, convince)
        ret = 1
end
 
        return ret
end

my second script in talk:
PHP:
function onSay(cid, words, param)
doPlayerRemoveItem(cid, 5908, 1)
   doCreatureAddHealth(cid, 20+ getCreatureMaxHealth(cid))
   doCreatureAddMana(cid, 20+ getCreatureMaxMana(cid))
return 0
end
return 1
well i get no error but it will only remove the item and it wont add player health any ideas?
 
Last edited:
Well, try that:

PHP:
local summonplayerpos = { x = 1008, y = 1042, z = 7, stackpos = 253 }
function onStepIn(cid, item, pos)
    if item.actionid == 2579 then
        if isPlayer(cid) ~= TRUE then        
			doConvinceSummon(cid, "Training Monk", 0, summonplayerpos)
		end
	end
	return TRUE
end
 
Last edited:
lol that is the prob? " " omg..
what about this?
PHP:
function onSay(cid, words, param)
doPlayerRemoveItem(cid, 5908, 1)
   doCreatureAddHealth(cid, 20+ getCreatureMaxHealth(cid))
   doCreatureAddMana(cid, 20+ getCreatureMaxMana(cid))
return 0
end
return 1
well i get no error but it will only remove the item and it wont add player health any
ideas?

P.S: the first script no error no summon i changed the count 0 -> 1 but also no summon any idea's?
 
Last edited:
PHP:
function onSay(cid, words, param)
	doPlayerRemoveItem(cid, 5908, 1)
	doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
    doPlayerAddMana(cid, getPlayerMaxMana(cid))
end

What was the + 20 for there, if u r adding full hp? o_O

Well, here it is with if-statement:
PHP:
function onSay(cid, words, param)
	if doPlayerRemoveItem(cid, 5908, 1) == TRUE then
		doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
		doPlayerAddMana(cid, getPlayerMaxMana(cid))
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, "You do not have an item with id 5908.")
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
	end
	return TRUE
end

Try them, if theyre working ^^

@About summon.

try adding it below local summonplayerpos:
Code:
local summonplayer = getThingfromPos(summonplayerpos)

@Again about summon.

set ~= TRUE in if isPlayer to == TRUE.
 
Last edited:
@down
1- how to add event o_O coz step out didn't work
2- i want that to add for example ur maxhealth is 30 i want it to make it 50 understood?

P.S after my 2 scripts are fixed i want a mod. to clean the thread and leave the first post so u don't think i am spamming i just want to learn Lua
anyway is there any chitchat here where post's aren't counted?
 
Last edited:
Well on Step in worked now ty alot!
My second question about it now is how to add Stepout i want if u step out of that tile the monster desummon any idea's?
and second script i think there isn't such a thing called 20+ getcreaturemaxhealth(cid))

P.S after my 2 scripts are fixed i want a mod. to clean the thread and leave the first post so u don't think i am spamming i just want to learn Lua
anyway is there any chitchat here where post's aren't counted?

Well, getCreatureMaxHealth(cid) already adds full health, so that + 20 isnt needed.
There isnt a shoutbox or any other shoutbox-type stuff here.
Instead of onStepOut, you can add an event that will remove the summon in the certain period of time. :thumbup:
 
PHP:
function eventName()
-- here write what it should do
end

and in the script add:
Code:
addEvent(eventName, time, callback)

in the callback you can just simpy write: "a" without quotes.
 
i made this didn't work
PHP:
function eventName() 
local summonplayerpos = { x = 1008, y = 1042, z = 7, stackpos = 253 }
function onStepIn(cid, item, pos)
    if item.actionid == 2579 then
        if isPlayer(cid) == TRUE then        
            doConvinceSummon(cid, "Training Monk", 0, summonplayerpos)
addEvent(eventName, 1, a)
        end
    end
    return TRUE
end 
end
Error:
Code:
[26/05/2008  23:39:42] Warning: [Event::loadScript] Event onStepIn not found. data/movements/scripts/not used/floor.
 
PHP:
function eventName() 
local summonplayerpos = { x = 1008, y = 1042, z = 7, stackpos = 253 }
function onStepIn(cid, item, pos)
    if item.actionid == 2579 then
        if isPlayer(cid) == TRUE then        
            doConvinceSummon(cid, "Training Monk", 0, summonplayerpos)
addEvent(eventName, 1, a)
        end
    end
    return TRUE
end 
end

Wtf? oO

PHP:
local summonplayerpos = { x = 1008, y = 1042, z = 7, stackpos = 253 }
local time = 1000 * 5 -- 5 sec, if im not wrong ^^
function onStepIn(cid, item, pos)
    if item.actionid == 2579 then
        if isPlayer(cid) == TRUE then        
            local summon = doConvinceSummon(cid, "Training Monk", 0, summonplayerpos)
     addEvent(eventName, time, a)
        end
    end
    return TRUE
end 
end
function eventName()
doRemoveCreature(summon)
end

Probably will say "Creature not found." but w/e. :p
 
well i get this error
Code:
[27/05/2008  16:38:31] Lua Script Error: [MoveEvents Interface] 
[27/05/2008  16:38:31] in a timer event called from: 
[27/05/2008  16:38:32] data/movements/scripts/not used/floor.lua:onStepIn

[27/05/2008  16:38:32] luaDoRemoveCreature(). Creature not found

I know u said it may say it but w/e but the point here is it isn't working anyway nvm i think moveEvents are hard

What about this 1 :[I wanna add time check]{it is the animationeffect.lua(in TFS)} to this script:
PHP:
function onSay(cid, words, param)
	if isPlayer(cid) == TRUE and param ~= "" and getPlayerGroupId(cid) > 1 then
		local position = getCreaturePosition(cid)
		doSendDistanceShoot(position, {x = position.x - 7, y = position.y - 4, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x - 7, y = position.y - 3, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x - 7, y = position.y - 2, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x - 7, y = position.y - 1, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x - 7, y = position.y, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x - 7, y = position.y + 1, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x - 7, y = position.y + 2, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x - 7, y = position.y + 3, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x - 7, y = position.y + 4, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x - 7, y = position.y + 5, z = position.z}, param)

		doSendDistanceShoot(position, {x = position.x + 7, y = position.y - 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x + 7, y = position.y - 4, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x + 7, y = position.y - 3, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x + 7, y = position.y - 2, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x + 7, y = position.y - 1, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x + 7, y = position.y, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x + 7, y = position.y + 1, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x + 7, y = position.y + 2, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x + 7, y = position.y + 3, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x + 7, y = position.y + 4, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x + 7, y = position.y + 5, z = position.z}, param)

		doSendDistanceShoot(position, {x = position.x - 7, y = position.y - 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x - 6, y = position.y - 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x - 5, y = position.y - 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x - 4, y = position.y - 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x - 3, y = position.y - 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x - 2, y = position.y - 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x - 1, y = position.y - 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x, y = position.y - 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x + 1, y = position.y - 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x + 2, y = position.y - 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x + 3, y = position.y - 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x + 4, y = position.y - 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x + 5, y = position.y - 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x + 6, y = position.y - 5, z = position.z}, param)

		doSendDistanceShoot(position, {x = position.x - 6, y = position.y + 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x - 5, y = position.y + 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x - 4, y = position.y + 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x - 3, y = position.y + 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x - 2, y = position.y + 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x - 1, y = position.y + 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x, y = position.y + 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x + 1, y = position.y + 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x + 2, y = position.y + 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x + 3, y = position.y + 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x + 4, y = position.y + 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x + 5, y = position.y + 5, z = position.z}, param)
		doSendDistanceShoot(position, {x = position.x + 6, y = position.y + 5, z = position.z}, param)
	end
end

Thanks in advance.

Yours,
Clary
 
Back
Top