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

global.lua or global events

Optomistic

Savannah Here
Joined
Apr 11, 2010
Messages
95
Reaction score
0
Location
O.o My Home in Boise
hey i read a script for a poke ball,says i need to make something called global.lua,do i need to make a folder then put the pokeball
script in side the folder or what.
 
Code:
_warpzone = 2147483648 -- start storing strings here (THIS IS THE ABSOLUTE MAXIMUM VALUE FOR THIS)
_maxlength = 1024 -- multiply by 3 to get the true length.
 
setPlayerStorageInteger = setPlayerStorageValue
getPlayerStorageInteger = getPlayerStorageValue
 
function setPlayerStorageString(cid, key, value)
    if #value > (_maxlength-1) * 3 - 1 then -- Last word is reserved for 0 termination of the string.
        error("Storage string is too long")
    end
    if key > _warpzone / _maxlength then
        error("Storage string key is too large (" .. key .. ")")
    end
    key = _warpzone + key * _maxlength
 
    local word = 0
    local wordwrap = 0
    local wordcount = 0
    local i = 1
    while i <= #value do
        local byte = string.byte(string.sub(value, i, i))
        word = bit.bor(word, bit.lshift(byte, wordwrap))
        wordwrap = wordwrap + 8
        if wordwrap == 24 then
            --[[
                In the ideal world we would be able to store 4 characters per word,
                however, as the default return value for getPlayerStorageValue is
                -1, we can't use the last bit.
            ]]--
            setPlayerStorageInteger(cid, key + wordcount, word)
            word = 0
            wordwrap = 0
            wordcount = wordcount + 1
        end
        i = i + 1
    end
    -- store the last word
    setPlayerStorageInteger(cid, key + wordcount, word)
end
 
function getPlayerStorageString(cid, key)
    if key > _warpzone / _maxlength then
        error("Storage string key is too large (" .. key .. ")")
    end
    key = _warpzone + key * _maxlength
 
    local wordcount = 0
    local str = ""
    while true do
        if wordcount >= _maxlength then
            break
        end
        local word = getPlayerStorageInteger(cid, key + wordcount)
        if word == -1 then
            -- end of string
            break
        else 
            -- Extract the 3 characters from the value
            byte = bit.band(word, 255)
            if byte == 0 then break else str = str .. string.char(byte) end
            byte = bit.rshift(bit.band(word, 65280), 8)
            if byte == 0 then break else str = str .. string.char(byte) end
            byte = bit.rshift(bit.band(word, 16711680), 16)
            if byte == 0 then break else str = str .. string.char(byte) end
        end
        wordcount = wordcount + 1
    end
    return str
end
_warpzone = 2147483648 -- start storing strings here (THIS IS THE ABSOLUTE MAXIMUM VALUE FOR THIS)
_maxlength = 1024 -- multiply by 3 to get the true length.
 
setPlayerStorageInteger = setPlayerStorageValue
getPlayerStorageInteger = getPlayerStorageValue
 
function setPlayerStorageString(cid, key, value)
    if #value > (_maxlength-1) * 3 - 1 then -- Last word is reserved for 0 termination of the string.
        error("Storage string is too long")
    end
    if key > _warpzone / _maxlength then
        error("Storage string key is too large (" .. key .. ")")
    end
    key = _warpzone + key * _maxlength
 
    local word = 0
    local wordwrap = 0
    local wordcount = 0
    local i = 1
    while i <= #value do
        local byte = string.byte(string.sub(value, i, i))
        word = bit.bor(word, bit.lshift(byte, wordwrap))
        wordwrap = wordwrap + 8
        if wordwrap == 24 then
            --[[
                In the ideal world we would be able to store 4 characters per word,
                however, as the default return value for getPlayerStorageValue is
                -1, we can't use the last bit.
            ]]--
            setPlayerStorageInteger(cid, key + wordcount, word)
            word = 0
            wordwrap = 0
            wordcount = wordcount + 1
        end
        i = i + 1
    end
    -- store the last word
    setPlayerStorageInteger(cid, key + wordcount, word)
end
 
function getPlayerStorageString(cid, key)
    if key > _warpzone / _maxlength then
        error("Storage string key is too large (" .. key .. ")")
    end
    key = _warpzone + key * _maxlength
 
    local wordcount = 0
    local str = ""
    while true do
        if wordcount >= _maxlength then
            break
        end
        local word = getPlayerStorageInteger(cid, key + wordcount)
        if word == -1 then
            -- end of string
            break
        else 
            -- Extract the 3 characters from the value
            byte = bit.band(word, 255)
            if byte == 0 then break else str = str .. string.char(byte) end
            byte = bit.rshift(bit.band(word, 65280), 8)
            if byte == 0 then break else str = str .. string.char(byte) end
            byte = bit.rshift(bit.band(word, 16711680), 16)
            if byte == 0 then break else str = str .. string.char(byte) end
        end
        wordcount = wordcount + 1
    end
    return str
end
 
Back
Top