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

Help with VIP command

Dankoo

Active Member
Joined
Sep 4, 2010
Messages
1,007
Reaction score
27
When a VIP player log in or use !vip command, the magic effect is displayed to all VIP players

I know what's causing this, but can't fix it so far, have a look:

this is the script I've adapted etc:

LUA:
function onSay(cid, words, param)
		local config = {
			exhaustion = 1,
			storage = 33545
		}
         for _, name in ipairs(getOnlinePlayers()) do
         local cid = getPlayerByName(name)
               if getPlayerVipDays(cid) >= 1 and (exhaustion.check(cid, config.storage)) then
			   	doPlayerSendCancel(cid, "Você só pode usar este comando uma vez a cada " .. config.exhaustion .. " minuto.")
				return true
				end
				
				if getPlayerVipDays(cid) >= 1 then
                  doSendMagicEffect(getPlayerPosition(cid), 27)
				  doPlayerSendTextMessage(cid, 19, "Você tem ".. getPlayerVipDays(cid) .." dias de VIP.")
                  doSendAnimatedText(getPlayerPosition(cid), "VIP!", TEXTCOLOR_RED)
				  exhaustion.set(cid, config.storage, config.exhaustion * 60)
               end
         end
         return true
end

the problem obviously is here:

LUA:
         for _, name in ipairs(getOnlinePlayers()) do
         local cid = getPlayerByName(name)

But I've tried to replace this, and got no results, as it says the player was not found etc...

what can I use to replace?
thanks :peace:
 
Why would you want this as an 'onSay' function anyways :s, wouldn't globalevent be better?

Anyways, this should work, I guess.

LUA:
function onSay(cid,words,param)
local exhaust,storage = 1,33535
    for _,pid in ipairs(getPlayersOnline()) do
    local vpid = getCreatureName(pid)
    local v = getThingPos(vpid)
        if exhaustion.check(pid,storage) then
            return doPlayerSendCancel(vpid,"Você só pode usar este comando uma vez a cada " .. exhaustion .. " minuto.")
        elseif getPlayerVipDays(pid) > 0 then
            doSendMagicEffect(vpid,27)
            doPlayerSendTextMessage(vpid,19,"Você tem "..getPlayerVipDays(cid).." dias de VIP.")
            doSendAnimatedText(vpid,"VIP!",TEXTCOLOR_RED)
            exhaustion.set(vpid,storage,exhaust*60)
        end
    end
    return true
end
 
Player not found
Creature not found
Thing not found

Yeah, what I've tried to do is

VIP player logs in, a VIP message appears, like the script above, and an message saying how many VIP days are left to him
VIP players says !vip and same thing happens, but with a 1 min exhaust

The problem is that the VIP effect appears to all VIP players, not only the one who logged in or used !vip command u know
 
I don't know how to script

I can understand in a general mode an script when I read it, but I don't know how to create a new script u know, just adapt it to work it other scripts, like the exhaust function

What do you mean by loop? What is a loop in this script?
 
Here.

LUA:
local ex,s = 1,33545
function onSay(cid,words,param)
local v = getThingPos(cid)
    if exhaustion.check(cid,s) then
        return doPlayerSendCancel(cid,"Você só pode usar este comando uma vez a cada "..ex.." minuto.")
    else
        if getPlayerVipDays(cid) > 0 then
            doSendMagicEffect(v,27)
            doPlayerSendTextMessage(cid,19,'Você tem '..getPlayerVipDays(cid)..' dias de VIP.')
            doSendAnimatedText(v,'VIP!',TEXTCOLOR_RED)
            exhaustion.set(cid,s,ex*60)
        end
    end
    return true
end
 
Back
Top