• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

MoveEvent My first script :S

Eazy M

Developer
Joined
Oct 17, 2010
Messages
911
Reaction score
61
Location
.
Hi,

This is my first script , i dont know if it works, im at school so i can't test it ;)

Code:
function onStepIn(cid, item, frompos, itemEx, topos)
  local temple = {
    pos = {x = XXX, y = XXX, z = XXX}

 if isPlayerPzLocked(cid) then
    doPlayerSendTextMessage(cid,21,"Loose battle icon first plox.")
 else
    doCreatureSay(itemEx.uid, "+60", TALKTYPE_ORANGE_1)
    doCreatureAddHealth(cid, 60)
    end
        return TRUE
end

Comment :O
 
whit is the need of this ?
Code:
 local temple = {
    pos = {x = XXX, y = XXX, z = XXX}
 
@Up

When enter that pos u get +60 hp
Sorry for my scripting, i wanna learn lua for tibia/OT

I scripted LUA for Counter Strike Source before.
 
Actually it shouldnt be like that :p

Where is the check to see if the player in this place , also it can be done more easier with action id so script will look like that
Lua:
function onStepIn(cid, item, frompos, itemEx, topos)
	if isPlayerPzLocked(cid) then
		doPlayerSendTextMessage(cid,21,"Loose battle icon first plox.")
	else
		doCreatureSay(cid, "+60", TALKTYPE_ORANGE_1)
		doCreatureAddHealth(cid, 60)
    end
	return true
end

and then in movement

Code:
<movevent type="StepIn"actionid="xxxx" event="script" value="swimming.lua"/>

And you put the action id on that tile.

Or if you dont want to add an actionid , and you want to use a common itemid then you will need to make checks on place(that is wat you wanted to do)
Lua:
function onStepIn(cid, item, frompos, itemEx, topos)
	temple = {x=1,y=1,z=1}   -- place pos
	p = getThingPos(cid)
	if temple.x == p.x and temple.y == p.y and temple.z == p.z then    -- checking the player pos with the temple pos
		if isPlayerPzLocked(cid) then
			doPlayerSendTextMessage(cid,21,"Loose battle icon first plox.")
		else
			doCreatureSay(cid, "+60", TALKTYPE_ORANGE_1)
			doCreatureAddHealth(cid, 60)
		end
	end
	return true
end

Just showing you , but i think action id one is better :p
 
If you have questions concerning LUA, please add me on msn:
[email protected]

I'm interested in that CS:S lua scripting, so we could help eachother =)
 
@Doggynub

Thanks ;)

@Kira
Yep, it's fun to script lua.
I scripted LUA to counter strike source before. (HACKING SCRIPTS)
 
Last edited by a moderator:
Script is very messy and doesn't work.
As I did with Zysen, I'll give you some fixing too.

1. Put locals that don't use (cid),etc.. , ABOVE the function.

I.e.
Lua:
local temple = {x=1,y=1,z=1}
function onStepIn(cid, item, frompos, itemEx, topos)

2. Don't write a local that is not used!

You say that if you step on the tile on position (temple), the script executes, that's not true.
A local just saves something, saving you alot of work with writing.
If you want the local temple to be used then use this i.e.

Lua:
local temple = {x=1,y=1,z=1}
function onStepIn(cid, item, frompos, itemEx, topos)
    return doTeleportThing(cid,temple)
end

3. Work on your tabbing.

If you don't tab, a script will look messy, like this.

Lua:
local temple = {x=1,y=1,z=1}
function onStepIn(cid, item, frompos, itemEx, topos)
            if getPlayerLevel(cid) >= 60 then
    doTeleportThing(cid,temple)
    doPlayerSendTextMessage(cid,27,'You have been teleported.')
        else
doPlayerSendCancel(cid,'You have to be level 60 or higher')
end
end

If you want it to look neat and easy to be read, make it like this.

Lua:
local temple = {x=1,y=1,z=1}
function onStepIn(cid, item, frompos, itemEx, topos)
    if getPlayerLevel(cid) >= 60 then
        doTeleportThing(cid,temple)
        doPlayerSendTextMessage(cid,27,'You have been teleported.')
    else
        doPlayerSendCancel(cid,'You have to be level 60 or higher')
    end
end

That's for now,
keep on scripting!
 
Back
Top