• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua check name if the player already has vip

ADM24horas

New Member
Joined
Oct 4, 2015
Messages
70
Reaction score
0
anyone can put to correct the problem for example if I use the scroll VIP 2 times the dummy name will be [VIP] [VIP] Name





function onUse(cid, item, fromPosition, itemEx, toPosition)
local config={
removeOnUse = "yes" -- remover quando usar ("yes" or "no")
}
local days = 30 -- dias que serão adicionados
local daysvalue = days * 24 * 60 * 60
local storageplayer = getPlayerStorageValue(cid, 13778)
local timenow = os.time()
if getPlayerStorageValue(cid, 13778) - os.time() <= 0 then
time = timenow + daysvalue
else
time = storageplayer + daysvalue
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Foram adicionados ".. days .." dias de VIP no seu character.")
setPlayerStorageValue(cid, 13778, time)
local quantity = math.floor((getPlayerStorageValue(cid, 13778) - timenow)/(24 * 60 * 60))
doSendMagicEffect(getPlayerPosition(cid), math.random(28,30))
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem ".. quantity .." dias de VIP restantes.")
if (config.removeOnUse == "yes") then
doRemoveItem(item.uid, 1)
db.executeQuery("UPDATE `players` SET `name` = '[VIP] "..getCreatureName(cid).."' WHERE `id` = "..getPlayerGUID(cid)..";")
doPlayerSendTextMessage(cid,25,"Você será kickado em 5 segundos para mudança de nome.")
doPlayerAddAddons(cid, 1)
addEvent(doRemoveCreature, 5*1000, cid, true)
end
return TRUE
end
 
I didn't test it but you can try this:

What I added:
Code:
        local name = getCreatureName(cid)
        if not string.find(name, '[VIP]') then
            db.executeQuery("UPDATE `players` SET `name` = '[VIP] ".. name .."' WHERE `id` = "..getPlayerGUID(cid)..";")
        end

Full:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local config={
        removeOnUse = "yes" -- remover quando usar ("yes" or "no")
    }
    local days = 30 -- dias que serão adicionados
    local daysvalue = days * 24 * 60 * 60
    local storageplayer = getPlayerStorageValue(cid, 13778)
    local timenow = os.time()
    if getPlayerStorageValue(cid, 13778) - os.time() <= 0 then
    time = timenow + daysvalue
    else
    time = storageplayer + daysvalue
    end
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Foram adicionados ".. days .." dias de VIP no seu character.")
    setPlayerStorageValue(cid, 13778, time)
    local quantity = math.floor((getPlayerStorageValue(cid, 13778) - timenow)/(24 * 60 * 60))
    doSendMagicEffect(getPlayerPosition(cid), math.random(28,30))
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem ".. quantity .." dias de VIP restantes.")
    if (config.removeOnUse == "yes") then
        doRemoveItem(item.uid, 1)
        local name = getCreatureName(cid)
        if not string.find(name, '[VIP]') then
            db.executeQuery("UPDATE `players` SET `name` = '[VIP] ".. name .."' WHERE `id` = "..getPlayerGUID(cid)..";")
        end
        doPlayerSendTextMessage(cid,25,"Você será kickado em 5 segundos para mudança de nome.")
        doPlayerAddAddons(cid, 1)
        addEvent(doRemoveCreature, 5*1000, cid, true)
    end
return TRUE
end
 
thank worked perfectly, if not asking too much you could put just for use in the area pz?

Try this, what I added:
Code:
    if  (not getTileInfo(getThingPos(cid)).protection)  then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You may only use this item in a protection zone.")
        return true
    end

Full:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if (not getTileInfo(getThingPos(cid)).protection) then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You may only use this item in a protection zone.")
        return true
    end
    local config={
        removeOnUse = "yes" -- remover quando usar ("yes" or "no")
    }
    local days = 30 -- dias que serão adicionados
    local daysvalue = days * 24 * 60 * 60
    local storageplayer = getPlayerStorageValue(cid, 13778)
    local timenow = os.time()
    if getPlayerStorageValue(cid, 13778) - os.time() <= 0 then
    time = timenow + daysvalue
    else
    time = storageplayer + daysvalue
    end
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Foram adicionados ".. days .." dias de VIP no seu character.")
    setPlayerStorageValue(cid, 13778, time)
    local quantity = math.floor((getPlayerStorageValue(cid, 13778) - timenow)/(24 * 60 * 60))
    doSendMagicEffect(getPlayerPosition(cid), math.random(28,30))
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem ".. quantity .." dias de VIP restantes.")
    if (config.removeOnUse == "yes") then
        doRemoveItem(item.uid, 1)
        local name = getCreatureName(cid)
        if not string.find(name, '[VIP]') then
            db.executeQuery("UPDATE `players` SET `name` = '[VIP] ".. name .."' WHERE `id` = "..getPlayerGUID(cid)..";")
        end
        doPlayerSendTextMessage(cid,25,"Você será kickado em 5 segundos para mudança de nome.")
        doPlayerAddAddons(cid, 1)
        addEvent(doRemoveCreature, 5*1000, cid, true)
    end
return TRUE
end
 
hello imkingran you know correct a small error in the script, if I relog when to activate the item from this error in the distro

[10/1/2016 15:7:55] [Error - Action Interface]
[10/1/2016 15:7:55] In a timer event called from:
[10/1/2016 15:7:55] data/actions/scripts/vip/epicvip.lua:eek:nUse
[10/1/2016 15:7:55] Description:
[10/1/2016 15:7:55] (luaDoRemoveCreature) Creature not found

function onUse(cid, item, fromPosition, itemEx, toPosition)
if (not getTileInfo(getThingPos(cid)).protection) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You may only use this item in a protection zone.")
return true
end
local config={
removeOnUse = "yes" -- remover quando usar ("yes" or "no")
}
local days = 30 -- dias que serão adicionados
local daysvalue = days * 24 * 60 * 60
local storageplayer = getPlayerStorageValue(cid, 23510)
local timenow = os.time()
if getPlayerStorageValue(cid, 23510) - os.time() <= 0 then
time = timenow + daysvalue
else
time = storageplayer + daysvalue
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Foram adicionados ".. days .." dias de VIP no seu character.")
setPlayerStorageValue(cid, 23510, time)
local quantity = math.floor((getPlayerStorageValue(cid, 23510) - timenow)/(24 * 60 * 60))
doSendMagicEffect(getPlayerPosition(cid), math.random(28,30))
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem ".. quantity .." dias de VIP restantes.")
if (config.removeOnUse == "yes") then
doRemoveItem(item.uid, 1)
local name = getCreatureName(cid)
if not string.find(name, '[VIP]') then
db.executeQuery("UPDATE `players` SET `name` = '[VIP] ".. name .."' WHERE `id` = "..getPlayerGUID(cid)..";")
end
doPlayerSendTextMessage(cid,25,"Você será kikado em 5 segundos para mudança de nome.")
doPlayerAddAddons(cid, 1)
addEvent(doRemoveCreature, 5*1000, cid, true)
end
return TRUE
end
 
hello imkingran you know correct a small error in the script, if I relog when to activate the item from this error in the distro

[10/1/2016 15:7:55] [Error - Action Interface]
[10/1/2016 15:7:55] In a timer event called from:
[10/1/2016 15:7:55] data/actions/scripts/vip/epicvip.lua:eek:nUse
[10/1/2016 15:7:55] Description:
[10/1/2016 15:7:55] (luaDoRemoveCreature) Creature not found

function onUse(cid, item, fromPosition, itemEx, toPosition)
if (not getTileInfo(getThingPos(cid)).protection) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You may only use this item in a protection zone.")
return true
end
local config={
removeOnUse = "yes" -- remover quando usar ("yes" or "no")
}
local days = 30 -- dias que serão adicionados
local daysvalue = days * 24 * 60 * 60
local storageplayer = getPlayerStorageValue(cid, 23510)
local timenow = os.time()
if getPlayerStorageValue(cid, 23510) - os.time() <= 0 then
time = timenow + daysvalue
else
time = storageplayer + daysvalue
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Foram adicionados ".. days .." dias de VIP no seu character.")
setPlayerStorageValue(cid, 23510, time)
local quantity = math.floor((getPlayerStorageValue(cid, 23510) - timenow)/(24 * 60 * 60))
doSendMagicEffect(getPlayerPosition(cid), math.random(28,30))
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem ".. quantity .." dias de VIP restantes.")
if (config.removeOnUse == "yes") then
doRemoveItem(item.uid, 1)
local name = getCreatureName(cid)
if not string.find(name, '[VIP]') then
db.executeQuery("UPDATE `players` SET `name` = '[VIP] ".. name .."' WHERE `id` = "..getPlayerGUID(cid)..";")
end
doPlayerSendTextMessage(cid,25,"Você será kikado em 5 segundos para mudança de nome.")
doPlayerAddAddons(cid, 1)
addEvent(doRemoveCreature, 5*1000, cid, true)
end
return TRUE
end

Hello Friend,

Always use [ code ] -- code here -- [ /code ] tags when posting a script to the forum. :p

Try this:
Code:
local function removeGuy(cid)
    if cid then
        doRemoveCreature(cid, true)
    end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if (not getTileInfo(getThingPos(cid)).protection) then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You may only use this item in a protection zone.")
    return true
    end
    local config={
        removeOnUse = "yes" -- remover quando usar ("yes" or "no")
    }
    local days = 30 -- dias que serão adicionados
    local daysvalue = days * 24 * 60 * 60
    local storageplayer = getPlayerStorageValue(cid, 23510)
        local timenow = os.time()
    if getPlayerStorageValue(cid, 23510) - os.time() <= 0 then
        time = timenow + daysvalue
    else
        time = storageplayer + daysvalue
    end
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Foram adicionados ".. days .." dias de VIP no seu character.")
    setPlayerStorageValue(cid, 23510, time)
    local quantity = math.floor((getPlayerStorageValue(cid, 23510) - timenow)/(24 * 60 * 60))
    doSendMagicEffect(getPlayerPosition(cid), math.random(28,30))
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem ".. quantity .." dias de VIP restantes.")
    if (config.removeOnUse == "yes") then
        doRemoveItem(item.uid, 1)
        local name = getCreatureName(cid)
        if not string.find(name, '[VIP]') then
            db.executeQuery("UPDATE `players` SET `name` = '[VIP] ".. name .."' WHERE `id` = "..getPlayerGUID(cid)..";")
        end
        doPlayerSendTextMessage(cid,25,"Você será kikado em 5 segundos para mudança de nome.")
        doPlayerAddAddons(cid, 1)
        addEvent(removeGuy, 5*1000, cid)
    end
return TRUE
end
 
Loading actions... [Error - LuaInterface::loadFile] data/actions/scripts/vip/epicvip4.lua:33: 'end' expected (to close 'function' at line 1) near '<eof>'
[10/1/2016 19:2:26] [Error - Event::checkScript] Cannot load script (data/actions/scripts/vip/epicvip4.lua)
[10/1/2016 19:2:26] data/actions/scripts/vip/epicvip4.lua:33: 'end' expected (to close 'function' at line 1) near '<eof>'
[10/1/2016 19:2:31] (done).
 
Loading actions... [Error - LuaInterface::loadFile] data/actions/scripts/vip/epicvip4.lua:33: 'end' expected (to close 'function' at line 1) near '<eof>'
[10/1/2016 19:2:26] [Error - Event::checkScript] Cannot load script (data/actions/scripts/vip/epicvip4.lua)
[10/1/2016 19:2:26] data/actions/scripts/vip/epicvip4.lua:33: 'end' expected (to close 'function' at line 1) near '<eof>'
[10/1/2016 19:2:31] (done).

Post back here the full script after you copied it.

Try it:
Code:
local function removeGuy(cid)
    if isPlayer(cid) then
        doRemoveCreature(cid, true)
    end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if (not getTileInfo(getThingPos(cid)).protection) then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You may only use this item in a protection zone.")
    return true
    end
    local config={
        removeOnUse = "yes" -- remover quando usar ("yes" or "no")
    }
    local days = 30 -- dias que serão adicionados
    local daysvalue = days * 24 * 60 * 60
    local storageplayer = getPlayerStorageValue(cid, 23510)
        local timenow = os.time()
    if getPlayerStorageValue(cid, 23510) - os.time() <= 0 then
        time = timenow + daysvalue
    else
        time = storageplayer + daysvalue
    end
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Foram adicionados ".. days .." dias de VIP no seu character.")
    setPlayerStorageValue(cid, 23510, time)
    local quantity = math.floor((getPlayerStorageValue(cid, 23510) - timenow)/(24 * 60 * 60))
    doSendMagicEffect(getPlayerPosition(cid), math.random(28,30))
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem ".. quantity .." dias de VIP restantes.")
    if (config.removeOnUse == "yes") then
        doRemoveItem(item.uid, 1)
        local name = getCreatureName(cid)
        if not string.find(name, '[VIP]') then
            db.executeQuery("UPDATE `players` SET `name` = '[VIP] ".. name .."' WHERE `id` = "..getPlayerGUID(cid)..";")
        end
        doPlayerSendTextMessage(cid,25,"Você será kikado em 5 segundos para mudança de nome.")
        doPlayerAddAddons(cid, 1)
        addEvent(removeGuy, 5*1000, cid)
    end
return TRUE
end
 
like this?

http://prntscr.com/9oiwol

Code:
local function removeGuy(cid)
    if isPlayer(cid) then
        doRemoveCreature(cid, true)
    end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if (not getTileInfo(getThingPos(cid)).protection) then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You may only use this item in a protection zone.")
    return true
    end
    local config={
        removeOnUse = "yes" -- remover quando usar ("yes" or "no")
    }
    local days = 999 -- dias que serão adicionados
    local daysvalue = days * 24 * 60 * 60
    local storageplayer = getPlayerStorageValue(cid, 23510)
        local timenow = os.time()
    if getPlayerStorageValue(cid, 23510) - os.time() <= 0 then
        time = timenow + daysvalue
    else
        time = storageplayer + daysvalue
    end
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Foram adicionados ".. days .." dias de VIP no seu character.")
    setPlayerStorageValue(cid, 23510, time)
    local quantity = math.floor((getPlayerStorageValue(cid, 23510) - timenow)/(24 * 60 * 60))
    doSendMagicEffect(getPlayerPosition(cid), math.random(28,30))
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem ".. quantity .." dias de VIP restantes.")
    if (config.removeOnUse == "yes") then
        doRemoveItem(item.uid, 1)
        local name = getCreatureName(cid)
        if not string.find(name, '[VIP]') then
            db.executeQuery("UPDATE `players` SET `name` = '[VIP] ".. name .."' WHERE `id` = "..getPlayerGUID(cid)..";")
        end
        doPlayerSendTextMessage(cid,25,"Você será kikado em 5 segundos para mudança de nome.")
        doPlayerAddAddons(cid, 1)
        addEvent(removeGuy, 5*1000, cid)
    end
return TRUE
end
 
Back
Top