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

Create teleport

Sasha

New Member
Joined
Feb 25, 2015
Messages
4
Reaction score
0
Is there any one can help me with making script and this one is create teleport by clicking on lever also this lever won't create teleport on that place if there is any teleport already on it with duration please :(
 
Its your start what you want to do.. Take it and be happy, use it and move your brains, nobody gonna do everything for you


Code:
local t = {
    sec = 10,
    sec2 = 5,
    portal = {x = 32353, y = 32219, z = 7},
    portalwhere = {x = 32341, y = 32226, z = 7},
    itemid = 11798,
    active = 1,
    cooldown = 10,
    storage = 11999,
    storage2 = 11998
}

function onStepIn(cid, item, position, lastPosition)


local viptimestorage = 15001
local player = Player(cid)



if (player:getStorageValue(viptimestorage) <= os.time()) then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have VIP priviliges. You can buy VIP doll from website.")


elseif getGlobalStorageValue(t.storage2) >= os.time() then
        return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Wait ".. getGlobalStorageValue(t.storage2) - os.time().." Sec. Until you can walk again.")
    else
  


local portal = doCreateItem(t.itemid,1,t.portalwhere)
doSetItemActionId(portal, 12001)
addEvent(function() doRemoveItem(getTileItemById(t.portalwhere, t.itemid).uid) end,t.cooldown * 1000)
doSendMagicEffect(t.portalwhere, CONST_ME_TELEPORT)


doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Teleport created for 10 seconds.")
setGlobalStorageValue(t.storage2, os.time() + t.cooldown)

end

return true
end
 
Its your start what you want to do.. Take it and be happy, use it and move your brains, nobody gonna do everything for you


Code:
local t = {
    sec = 10,
    sec2 = 5,
    portal = {x = 32353, y = 32219, z = 7},
    portalwhere = {x = 32341, y = 32226, z = 7},
    itemid = 11798,
    active = 1,
    cooldown = 10,
    storage = 11999,
    storage2 = 11998
}

function onStepIn(cid, item, position, lastPosition)


local viptimestorage = 15001
local player = Player(cid)



if (player:getStorageValue(viptimestorage) <= os.time()) then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have VIP priviliges. You can buy VIP doll from website.")


elseif getGlobalStorageValue(t.storage2) >= os.time() then
        return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Wait ".. getGlobalStorageValue(t.storage2) - os.time().." Sec. Until you can walk again.")
    else
 


local portal = doCreateItem(t.itemid,1,t.portalwhere)
doSetItemActionId(portal, 12001)
addEvent(function() doRemoveItem(getTileItemById(t.portalwhere, t.itemid).uid) end,t.cooldown * 1000)
doSendMagicEffect(t.portalwhere, CONST_ME_TELEPORT)


doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Teleport created for 10 seconds.")
setGlobalStorageValue(t.storage2, os.time() + t.cooldown)

end

return true
end
may you explain it please because i can't understand some things on it, and for sure i will work hard to learn :)
 
Its variables
local t = {
sec = 10, --- Seconds how long teleport has been created
portalwhere = {x = 32341, y = 32226, z = 7}, ---- Where teleport gonna be created
itemid = 11798, --- Which item gonna be shows
active = 1, ---- True or false "1 or 0"
cooldown = 10, --- How long teleport shows up
storage = 11999, --- Storage its like database and all information saving in storages. Exeption accounts, passwords it saving in mysql
storage2 = 11998 --- Storage again
}

This function means what happining when u walk on that tile
function onStepIn(cid, item, position, lastPosition)
---- HERE ALL CODE

local viptimestorage = 15001 --- Storage again (true or false) if you are VIP you can enter in teleport
local player = Player(cid) ---- Here is the player id.


learn about if and else and elseif


if (player:getStorageValue(viptimestorage) <= os.time()) then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have VIP priviliges. You can buy VIP doll from website.")

elseif getGlobalStorageValue(t.storage2) >= os.time() then
return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Wait ".. getGlobalStorageValue(t.storage2) - os.time().." Sec. Until you can walk again.")
else
getGlobalStorageValue ---- global storage
getPlayerStorageValue ---- Only player storage


player:getStorageValue(viptimestorage) --- we are getting storage of player it returns time. So IF time <= os.time() << Real date time then we doing something

player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have VIP priviliges. You can buy VIP doll from website.")

^^ It shows player message.




local portal = doCreateItem(t.itemid,1,t.portalwhere) --- We are creating item on the map itemid, how many, and where
doSetItemActionId(portal, 12001) --- we are adding item action (whats happining when we walk on it)


addEvent(function() doRemoveItem(getTileItemById(t.portalwhere, t.itemid).uid) end,t.cooldown * 1000) -- adding event to remove item after 10 seconds
doSendMagicEffect(t.portalwhere, CONST_ME_TELEPORT) -- magic effects


doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Teleport created for 10 seconds.") -- player message again
setGlobalStorageValue(t.storage2, os.time() + t.cooldown) --- cooldown






end


In data pack folder is many many folders like movements talkactions actions creaturescripts and more....

actions folder -- Whats happening when you press on item
creaturescripts -- Whats happening when you login or logout kill somebody and more...
talkactions -- when you write something like (!showteleport) so we can execute this script
movements ---- Whats happening when you walk on it.

the differents is only call function
actions:

function onUse(player, item, fromPosition, target, toPosition, isHotkey)


movements:
function onStepIn(cid, item, position, lastPosition)

talkactions:
function onSay(cid, words, param)
 
this one didn't work with me or you didn't understand what i need :( i wanted onUse script to appear teleport on X place to teleport you to X place and this tp will disappear after 10 seconds and you can't create teleport until it remove (old one)
 
i believe you can check how current onUse scripts work and tutorials and find fine examples from OTLand
the method you are looking for to create items is this:
doCreateItem(itemid, type/count, pos)
Example:
local position = {x=200, y=100, z=7}
doCreateItem(17868, 1, position)

Im not entirely sure how can you modify teleport for the item, so i think just make an item and use the nevix script for that item.
 
Back
Top