• 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 a VIP Medal

freder

New Member
Joined
Jul 7, 2011
Messages
4
Reaction score
0
Hey Guys,

i've tried to make a VIP Medal and now i get problems.

I am using the Real Server 3.3 (8.6).

Well, now the problem!

I've created in actions.xml this script
Code:
<action itemid="10136" event="script" value="vip.lua"/>

Now i've created in scripts folder, this one
Code:
local days = 30
local levelToBeVIP = 1
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerLevel(cid) >= levelToBeVIP then
		if isPlayerVip(cid) == FALSE then
			doCreatureSay(cid, "Congratulations! You have now for "..days.." days VIP! You can now enter VIP-Areas!. ", TALKTYPE_ORANGE_1)
		end
		doSendAnimatedText(getPlayerPosition(cid), "Welcome!", TEXTCOLOR_RED) 
		doPlayerAddVipDays(cid, days)
		doRemoveItem(item.uid, 1)
		doSendAnimatedText(getCreaturePosition(cid), "+"..days.." days", 30)
	else
		doPlayerSendCancel(cid, "You need level "..levelToBeVIP.." to be a VIP player.")
	end	
	return TRUE
end

When i try to test it, say the server.exe to me
Code:
[17/06/2012 08:24:45] [Error - Action Interface] 
[17/06/2012 08:24:45] data/actions/scripts/vip.lua:onUse
[17/06/2012 08:24:45] Description: 
[17/06/2012 08:24:45] data/actions/scripts/vip.lua:6: attempt to call global 'isPlayerVip' (a nil value)
[17/06/2012 08:24:45] stack traceback:
[17/06/2012 08:24:45] 	data/actions/scripts/vip.lua:6: in function <data/actions/scripts/vip.lua:4>

Its doesn't work :(

Please help me!
 
add this into lib/050-funcations

LUA:
function getPlayerVipDays(cid)
    local Info = db.getResult("SELECT `vipdays` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1")
        if Info:getID() ~= LUA_ERROR then
        local days= Info:getDataInt("vipdays")
        Info:free()
        return days
    end
     return LUA_ERROR
end
 
function doAddVipDays(cid, days)
    db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` + " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
 
function doRemoveVipDays(cid, days)
    db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` - " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
 
add this into lib/050-funcations

LUA:
function getPlayerVipDays(cid)
    local Info = db.getResult("SELECT `vipdays` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1")
        if Info:getID() ~= LUA_ERROR then
        local days= Info:getDataInt("vipdays")
        Info:free()
        return days
    end
     return LUA_ERROR
end
 
function doAddVipDays(cid, days)
    db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` + " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
 
function doRemoveVipDays(cid, days)
    db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` - " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end

I sure do see the function isPlayerVip there.
 
LUA:
local days = 30
local levelToBeVIP = 1
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerLevel(cid) >= levelToBeVIP then
		if getPlayerVipDays(cid) <= 0 then
			doCreatureSay(cid, "Congratulations! You have now for "..days.." days VIP! You can now enter VIP-Areas!. ", TALKTYPE_ORANGE_1)
		end
		doSendAnimatedText(getPlayerPosition(cid), "Welcome!", TEXTCOLOR_RED) 
		doPlayerAddVipDays(cid, days)
		doRemoveItem(item.uid, 1)
		doSendAnimatedText(getCreaturePosition(cid), "+"..days.." days", 30)
	else
		doPlayerSendCancel(cid, "You need level "..levelToBeVIP.." to be a VIP player.")
	end	
	return true
end
 
LUA:
local days = 30
local levelToBeVIP = 1
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerLevel(cid) >= levelToBeVIP then
        if getPlayerVipDays(cid) <= 0 then
            doCreatureSay(cid, "Congratulations! You have now for "..days.." days VIP! You can now enter VIP-Areas!. ", TALKTYPE_ORANGE_1)
        end
        doSendAnimatedText(getPlayerPosition(cid), "Welcome!", TEXTCOLOR_RED) 
        doPlayerAddVipDays(cid, days)
        doRemoveItem(item.uid, 1)
        doSendAnimatedText(getCreaturePosition(cid), "+"..days.." days", 30)
    else
        doPlayerSendCancel(cid, "You need level "..levelToBeVIP.." to be a VIP player.")
    end    
    return true
end
Why aren't you reading IRC?
Riddle me some riddles plx
 
Thx! But...

Code:
[17/06/2012 23:07:34] Error during getDataInt(vipdays).

[17/06/2012 23:07:34] [Error - Action Interface] 
[17/06/2012 23:07:34] data/actions/scripts/vip.lua:onUse
[17/06/2012 23:07:34] Description: 
[17/06/2012 23:07:34] data/actions/scripts/vip.lua:10: attempt to call global 'doPlayerAddVipDays' (a nil value)
[17/06/2012 23:07:34] stack traceback:
[17/06/2012 23:07:34] 	data/actions/scripts/vip.lua:10: in function <data/actions/scripts/vip.lua:4>

Whats wrong now?
 
Back
Top