BBQ Fanatic
New Member
- Joined
- Jul 10, 2022
- Messages
- 13
- Reaction score
- 3
Hello guys
A while ago @Xikini helped me with some script (below named "existing script"). Now I would like to make a similar, extended script.
On the map there would be a objects (like statues or sth) which clicked by player teleport him to the specific location, but only if he has a specific storage (which is given by stepping on the specific tile for the first time). Thanks to Xikini's script linked above, I do know how to give player storage by stepping on the tile. But can't solve the rest.
I guess I do understand a logic: when clicking an object with ActionId = A, script checks if player has Storage = B. If yes - teleport to XYZ. Otherwise, send a message. And for each Action ID, there will be a different Storages and coordinates (here comes arrays).
I was trying to support myself with following threads:
The second one works properly, but only brainlessly copy+pasted as a different script, without arrays, and using Actions.xml. I was trying to edit Xikini's script (the first link in this post) he gave me, but something gone wrong and idk what.
I ended up having something like this:
(needs review, because I was editing exisiting script, maybe something is not longer needed, maybe I deleted something needed)
But this attempt was to only check if teleportation itself works. I does not include giving a storage by stepping on a tile (which I can solve by the existing script, but for testing I was giving a storage manually through PMA). That's why there is a "name", because I wanted to make this script independent from existing script, but still missing tile's id which will give that storage on stepping
I am aware it's relatively simple script, but don't understand syntax properly to make it done, so I'm asking you for help
A while ago @Xikini helped me with some script (below named "existing script"). Now I would like to make a similar, extended script.
On the map there would be a objects (like statues or sth) which clicked by player teleport him to the specific location, but only if he has a specific storage (which is given by stepping on the specific tile for the first time). Thanks to Xikini's script linked above, I do know how to give player storage by stepping on the tile. But can't solve the rest.
I guess I do understand a logic: when clicking an object with ActionId = A, script checks if player has Storage = B. If yes - teleport to XYZ. Otherwise, send a message. And for each Action ID, there will be a different Storages and coordinates (here comes arrays).
I was trying to support myself with following threads:
Lua - [TFS 0.X] Use only if you have "X" storage
Good evening, how to make it possible to use a certain item only if you have "X" storage? I have an action that gives the player a storage, but I only want it to be able to use it if it already has another storage (313722) = 1. local storage = 396122 function onUse(cid, item, fromPosition...
otland.net
TFS 1.X+ - Teleport on use object
Hello guys. I want to make something like when player use stone coffin he will be teleported to x,y,z. How should I do it? Please help.
otland.net
The second one works properly, but only brainlessly copy+pasted as a different script, without arrays, and using Actions.xml. I was trying to edit Xikini's script (the first link in this post) he gave me, but something gone wrong and idk what.
I ended up having something like this:
(needs review, because I was editing exisiting script, maybe something is not longer needed, maybe I deleted something needed)
Code:
local altars = {
[65535] = { -- actionId given to the statue on map
storage = 69420,
name = "Rat's Cave",
newpos = {posx = 94, posy = 127, posz = 7},
},
}
local shortcutAltars = MoveEvent()
shortcutAltars:type("onUse")
function shortcutAltars.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local index = altars[item:getActionId()]
if player:getStorageValue(index.storage) == 1 then
player:teleportTo(Position(index.newpos.posx, index.newpos.posy, index.newpos.posz))
else
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You are not allowed to do that")
end
end
for actionId, config in pairs(altars) do
shortcutAltars:aid(actionId)
end
shortcutAltars:register()
But this attempt was to only check if teleportation itself works. I does not include giving a storage by stepping on a tile (which I can solve by the existing script, but for testing I was giving a storage manually through PMA). That's why there is a "name", because I wanted to make this script independent from existing script, but still missing tile's id which will give that storage on stepping
I am aware it's relatively simple script, but don't understand syntax properly to make it done, so I'm asking you for help