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

First script and first UBER FAIL! :( Remove stone with pick(Function onuse),

Kernel

Tibera!
Joined
Apr 30, 2009
Messages
57
Reaction score
0
:D Yo luaers! Well, after reading some tutorials I decided to do my first script. It should remove stone with pick, and create other tiles and teleport on positions I want. Sucky thing is that I failed on first action, removing stone with a pick.

this is my script(its messed up and probably not logical at all, sry:s) :
NOTE:
Pick id is 2553
Stone id is 1304
stone uniq id is 5108


Lua:
function onUse(cid, item, frompos, item2, topos) 
if item.id == item2.actionid then 
if item2.actionid == 5108 and item2.id == 1304 then 
doRemoveItem(item2.uid) 

end 
else 
return 0 
end 
return 1 
end

There was Idea to add a script part to pick script, but Its complicated.
 
I dont know if your script works fine but its does.
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
         if item.itemid == 2553 and itemEx.itemid == 1304 then
            if itemEx.uid == 5108 then
               doRemoveItem(itemEx.uid)
            end
         else
             return FALSE
         end
         return TRUE
end

PD: I think your script works fine too.. I do not see any errors.

Edit:
Oh, what is that?
Lua:
if item.id == item2.actionid then
 
I dont know if your script works fine but its does.
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
         if item.itemid == 2553 and itemEx.itemid == 1304 then
            if itemEx.uid == 5108 then
               doRemoveItem(itemEx.uid)
            end
         else
             return FALSE
         end
         return TRUE
end

PD: I think your script works fine too.. I do not see any errors.
Mine script was not working :D ill check yours when Ill have time(after like 2 hours).

Edit:
Oh, what is that?
Lua:
if item.id == item2.actionid then

It was thought that if item.id(id of the pick) is the same as stone uniq id, than blebleble....

But I guess I fucked it up :s And maybe you know how to make the script create teleport? I have no idea how to tell script to create teleport that should have destanation I want.


EDIT:
What does itemEx.itemid mean? :eek:

And why do you return false, not true?
 
Mine script was not working :D ill check yours when Ill have time(after like 2 hours).

It was thought that if item.id(id of the pick) is the same as stone uniq id, than blebleble....
You would have to use this code for that:
Lua:
if item.itemid == itemEx.uid then
But I guess I fucked it up :s And maybe you know how to make the script create teleport? I have no idea how to tell script to create teleport that should have destanation I want.
doCreateTeleport(itemid, topos, createpos)
EDIT:
What does itemEx.itemid mean? :eek:
itemEx.itemid is the Item ID of the external item (the one you click on with Use with... crosshairs)
And why do you return false, not true?
In action scripts, return FALSE would return a text message saying "You can not use this item.". It has to be used, or else nothing would happen if none of the IF statements are valid.
By the way, always use return TRUE before the last END statement in your action scripts.
 
Back
Top