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

Bridge Lever Error

bybbzan

mapper
Joined
Aug 4, 2012
Messages
809
Solutions
2
Reaction score
136
Location
Sweden
Hi guys, i recently made a post that i would like deleted since i found the script i was looking for.
BUT now i got this error.. so annoying.

Code:
[Error - LuaScriptInterface::loadFile] data/actions/scripts/addedbyme/bridgelever.lua:1: ')' expected near '('[Warning - Event::loadScript] Cannot load script (data/actions/scripts/addedbyme/bridgelever.lua)

Code:
function eventual(cid, getThingPos(item.uid), wallpos)
doCreateItem(1284,1,wallpos[1])
doCreateItem(1284,1,wallpos[2])
doCreateItem(1284,1,wallpos[3])
doTransformItem(getThingPos(item.uid),item.itemid-1)
end

function onUse(cid, item, frompos, item2, topos)
wallpos = {
{x=1007, y=989, z=8, stackpos=1},
{x=1008, y=989, z=8, stackpos=1},
{x=1009, y=989, z=8, stackpos=1}
}
getwalls = {
getThingfromPos(wall1),
getThingfromPos(wall2),
getThingfromPos(wall3)
}

if item.uid == 7002 and item.itemid == 1945 then
doRemoveItem(getwalls[1].uid,1)
doRemoveItem(getwalls[2].uid,1)
doRemoveItem(getwalls[3].uid,1)
doTransformItem(item.uid,item.itemid+1)
doCreatureSay(cid, "You just opened a secret passage!", TALKTYPE_ORANGE_1)
addEvent(eventual, 10000, cid, getThingPos(item.uid), wallpos)
elseif item.uid == 7002 and item.itemid == 1946 then
doPlayerSendCancel(cid,"You can't use this yet.")
else
doPlayerSendCancel(cid,"Sorry, not possible.")
end
return 1
end
 
Remove getThingPos(item.uid) as parameter in function eventual or change it to something else, for example pos.
Then change the doTransformItem(getThingPos(item.uid),item.itemid-1). Atm item is nil, since it's not a parameter in function eventual.
To get the uniqueid based on pos you can use getTileItemById. To get the uid add .uid, so it will look like this.
Code:
getTileItemById(pos, itemId).uid
So with the function doTransformItem, it will look like this.
Code:
doTransformItem(getTileItemById(pos, 1946).uid, 1945)
Since the lever has an uniqueid added in the mapeditor and therefore won't change, you can also add the uniqueid as parameter instead of getting it with getTileItemById.

The parameters of the function are defined at the place where the function is called.
Example:

function doSomething(cid, amount, whatever)
if isPlayer(cid) then
doPlayerAddExperience(cid, amount)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, whatever)​
end​
end

Now in the script you can call the function.

function onUse(cid, item, fromPosition, itemEx, toPosition)
doSomething(cid, 500, "You just got 500 experience!")
return true​
end

The parameter cid from function onUse is defined in the source, but by adding it as first parameter in function doSomething (it doesn't matter how you call functions as long as the name is not used yet), you also define it as first parameter for function doSomething, which now has the same meaning in function doSomething as in function onUse.
The other ones you define in the script. You give them a name in the (called) function, how you call the parameters in the function doesn't matter, what matters is the position.
So the second parameter atm will mean the number 500 and the third one the text "You just got 500 experience!". Then in the function you can add what you want to do with that.

So with this script, if you click use on the item, you will get 500 experience and the message: You just got 500 experience!
Now you can simply change it so you can let the same function do something different.

doSomething(cid, 2000, "You got 2000 experience, congratulations!")

Now you will get 2000 experience and the message: You got 2000 experience, congratulations!
This way you can also use the same function multiple times for different things.

With addEvent it works the same way, only the function addEvent calls an other function after a certain time.
Code:
addEvent(function, time, parameters)
So with the function doSomething it will look like this.
Code:
addEvent(doSomething, 10 * 1000, cid, 2000, "You got 2000 experience, congratulations!")
Now you will get that message and 2000 experience after 10 seconds.
 
Last edited:
Back
Top