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

Cart 8.2

bomba

Member
Joined
Feb 26, 2008
Messages
635
Reaction score
7
Location
Brazil
How I make to add a time of duration of the ticket? The hard ticket only ten hours.

PHP:
local teleport = {
x = ?,
y = ?,
z = ?
}

function onUse(cid, item, frompos, item2, topos)
    if getPlayerStorageValue(cid,15001) == 1 then
            setPlayerStorageValue(cid,15001,0)
            doTeleportThing(cid, teleport, TRUE)
            doSendMagicEffect(toPos, CONST_ME_MAGIC_BLUE)
		doCreatureSay(item.uid, "Sorry, you need a ticket to travel.", TALKTYPE_ORANGE_1)
    return TRUE
end
 
Last edited:
I dont understand what you want, but I can say that u r missing one 'end' at the end of your script :D
 
He want add duration time into this script, for example: if u buy ticket u can travel with it only 1 hour then its broken or something :D
 
try to search for exahsuted function, something like this:
1. Put this at the end of your global.lua


PHP:
function exhaust(cid, storevalue, exhausttime)  
-- Exhaustion function by Alreth, v1.1 2006-06-24 01:31  
-- Returns 1 if not exhausted and 0 if exhausted  
    newExhaust = os.time()  
    oldExhaust = getPlayerStorageValue(cid, storevalue)  
    if (oldExhaust == nil or oldExhaust < 0) then  
        oldExhaust = 0  
    end  
    if (exhausttime == nil or exhausttime < 0) then  
        exhausttime = 1  
    end  
    diffTime = os.difftime(newExhaust, oldExhaust)  
    if (diffTime >= exhausttime or diffTime < 0) then  
        setPlayerStorageValue(cid, storevalue, newExhaust)   
        return 1  
    else  
        return 0  
    end  
end

and then, your script :

PHP:
local teleport = { 
x = ?, 
y = ?, 
z = ? 
} 
local storevalue = 9999 -- value where exhausted is saved 
local exhausttime = 36000 -- 10h exhaustion

function onUse(cid, item, frompos, item2, topos) 
    if (exhaust(cid, storevalue, exhausttime) == 0) then 
            doTeleportThing(cid, teleport, TRUE) 
            doSendMagicEffect(toPos, CONST_ME_MAGIC_BLUE) 
        doCreatureSay(item.uid, "Sorry, you need a ticket to travel.", TALKTYPE_ORANGE_1) 
    return TRUE 
    end 
end


and when you buying ticket you must set this exhausttime to 10h


I don't think what it works, but it is just idea, I don't have free time now to make it working :(
 
Why not just make some unused item a ticket and set it decay time to 10 hours?

Code:
local teleport = { x = ?, y = ?, z = ? }

function onUse(cid, item, frompos, item2, topos) 
    if getPlayerItemCount(cid, ITEMID 8D) ~= 0 then 
        doTeleportThing(cid, teleport, TRUE) 
        doSendMagicEffect(toPos, CONST_ME_MAGIC_BLUE) 
    else
        doCreatureSay(item.uid, "Sorry, you need a ticket to travel.", TALKTYPE_ORANGE_1)
    end 
    return TRUE 
end
 
Back
Top