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

TalkAction VIP System (Add/Remove vip points - Buy/Sell item by vip points.) - By StorageValue

Joined
Apr 17, 2008
Messages
1,922
Solutions
1
Reaction score
188
Location
Venezuela
I've added this to my server yesterday, based in storages value, a VIP System. Now players can buy items with these vip points.

Note: (This vip system is not by account, only by players)
If you want a Vip System by database (Points will be by players and not by account), then look here http://otland.net/f81/vip-system-add-remove-vip-points-buy-sell-item-vip-points-database-30186/#post302640

add this to your function.lua:

Code:
function getPlayerVipPoints(cid)
return getPlayerStorageValue(cid, vipStorage)
end

function doPlayerAddVipPoints(cid, points)
return setPlayerStorageValue(cid, vipStorage, getPlayerStorageValue(cid, vipStorage) + points)
end

function doPlayerRemoveVipPoints(cid, points)
return setPlayerStorageValue(cid, vipStorage, getPlayerStorageValue(cid, vipStorage) - points)
end

Now, create a file called vip.lua in your talkactions folder and add this:

Code:
requiredGroup = 3
vipStorage = 61155

function onSay(cid, words, param)
	if(param == "") then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
		return TRUE
	end

local t = string.explode(param, ",")
local target = getPlayerByNameWildcard(t[1])
local points = tonumber(t[2])

	if(words == "/addvip") then

	if(getPlayerGroupId(cid) < requiredGroup) then
		return FALSE
	end

	if(target == 0) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[1] .. " not found.")
		return TRUE
	end

	if(not points) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "No point specified.")
		return TRUE
	end

points = math.abs(points)
	if(getPlayerVipPoints(cid) == -1) then
		doPlayerAddVipPoints(target, points+1)
		doSendMagicEffect(getCreaturePosition(target), CONST_ME_MAGIC_RED)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have added " .. points .. " points to " .. t[1] .. ".")
		return TRUE
	else
		doPlayerAddVipPoints(target, points)
		doSendMagicEffect(getCreaturePosition(target), CONST_ME_MAGIC_RED)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have added " .. points .. " points to " .. t[1] .. ".")
		return TRUE
	end

end

	if(words == "/removevip") then

	if(getPlayerGroupId(cid) < requiredGroup) then
		return FALSE
	end

	if(target == 0) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[1] .. " not found.")
		return TRUE
	end

	if(not points) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "No point specified.")
		return TRUE
	end

points = math.abs(points)
	doPlayerRemoveVipPoints(cid, points)
	doSendMagicEffect(getCreaturePosition(target), CONST_ME_MAGIC_RED)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have removed " .. points .. " points from " .. t[1] .. ".")
	return TRUE
end

	if(words == "/getvip") then

	if(getPlayerGroupId(cid) < requiredGroup) then
		return FALSE
	end

	target = getPlayerByNameWildcard(param)

	if(target == 0) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. param .. " not found.")
		return TRUE
	end

	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. param .. " have " .. getPlayerVipPoints(target) .. " points.")
	return TRUE
end

	if(words == "!buyitem") then

local buyableItems = 
	{
	["boots of haste"] = {id = 2195, count = 1, points = 3},
	["amulet of loss"] = {id = 2173, count = 1, points = 5},
	["soft boots"] = {id = 6132, count = 1, points = 20}
	}

local buyableItem = buyableItems[param]

	if buyableItem then
		if getPlayerVipPoints(cid) >= buyableItem.points then
			doPlayerAddItem(cid, buyableItem.id, buyableItem.count)
			doPlayerRemoveVipPoints(cid, buyableItem.points)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought x" .. buyableItem.count .. " " .. getItemNameById(buyableItem.id) .. ". " .. getPlayerVipPoints(cid) .. " points left.")
			return TRUE
		else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have enough vip points.")
		return TRUE
		end
	else
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Say !itemlist to see the items that you can buy or sell.")
	return TRUE
	end
end

	if(words == "!sellitem") then

local sellableItems = 
	{
	["boots of haste"] = {id = 2195, count = 1, points = 3},
	["amulet of loss"] = {id = 2173, count = 1, points = 5},
	["soft boots"] = {id = 6132, count = 1, points = 20}
	}

local sellableItem = sellableItems[param]

	if sellableItem then
		if getPlayerVipPoints(cid) > 0 then
			if doPlayerRemoveItem(cid, sellableItem.id, sellableItem.count) then
				doPlayerAddVipPoints(cid, sellableItem.points)
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sold x" .. sellableItem.count .. " " .. getItemNameById(sellableItem.id) .. ". " .. getPlayerVipPoints(cid) .. " points left.")
				return TRUE
			else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do no have that item.")
			return TRUE
			end
		else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to have 1 or more vip points to sell an item.")
		return TRUE
		end
	else
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Say !itemlist to see the items that you can buy or sell.")
	return TRUE
	end
end

	if(words == "!itemlist") then
		if(param == "buy") then
			local text = "Items that you can buy:\n\nName: Boots of haste, Price: 3 points.\nName: Amulet of loss, Price: 5 points.\nName: Soft boots, Price: 20 points.\n\nYou have " .. getPlayerVipPoints(cid) .. " vip points."
			doPlayerPopupFYI(cid, text)
			return TRUE
		elseif(param == "sell") then
			local txt = "Items that you can sell:\n\nName: Boots of haste, Price: 3 points.\nName: Amulet of loss, Price: 5 points.\nName: Soft boots, Price: 20 points.\n\nYou have " .. getPlayerVipPoints(cid) .. " vip points."
			doPlayerPopupFYI(cid, txt)
			return TRUE
		else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Say (!itemlist buy) or (!itemlist sell) to see the items that you can buy or sell.")
		return TRUE
		end
	end
end

These are the items that you can buy/sell

Code:
local items = 
	{
	["boots of haste"] = {id = 2195, count = 1, points = 3},
	["amulet of loss"] = {id = 2173, count = 1, points = 5},
	["soft boots"] = {id = 6132, count = 1, points = 20}
	}

Code:
id -- itemid
count -- item count that you will buy or sell
points -- cost in vip points

Code:
 vipStorage = 61155 --vip storage (Don't use it for a quest or something like that) Of course, you can change it.
requiredGroup = 3 --Group ID required to use /addvip, /removevip and /getvip

Words:

  • /addvip (Add vip points to a player. Ex: /addvip Darkhaos, 10)
  • /removevip (Remove vip points to a player. Ex: /removevip Darkhaos, 10)
  • /getvip (Get vip points from a player. Ex: /getvip Darkhaos <- this will send you a message "Player Darkhaos have 10 vip points")
  • !buyitem (buy items with vip points. Ex: !buyitem boots of haste)
  • !sellitem (Sell item by vip points. Ex: !sellitem boots of haste.)
  • !itemlist buy/sell (See the item list that you can buy or sell. Ex: !itemlist buy or !itemlist sell)





 
Last edited:
its awesome

ty rep+++

pls add charges

Spanish: Gracias eres el orgullo latino muy buen programador
 
Last edited:
I've added this to my server yesterday, based in storages value, a VIP System. Now players can buy items with these vip points.

Note: (This vip system is not by account, only by players)
If you want a Vip System by database (Points will be by players and not by account), then look here TalkAction - VIP System (Add/Remove vip points - Buy/Sell item by vip points.) - With Database

add this to your function.lua:

Code:
function getPlayerVipPoints(cid)
return getPlayerStorageValue(cid, vipStorage)
end

function doPlayerAddVipPoints(cid, points)
return setPlayerStorageValue(cid, vipStorage, getPlayerStorageValue(cid, vipStorage) + points)
end

function doPlayerRemoveVipPoints(cid, points)
return setPlayerStorageValue(cid, vipStorage, getPlayerStorageValue(cid, vipStorage) - points)
end

Now, create a file called vip.lua in your talkactions folder and add this:

Code:
requiredGroup = 3
vipStorage = 61155

function onSay(cid, words, param)
    if(param == "") then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
        return TRUE
    end

local t = string.explode(param, ",")
local target = getPlayerByNameWildcard(t[1])
local points = tonumber(t[2])

    if(words == "/addvip") then

    if(getPlayerGroupId(cid) < requiredGroup) then
        return FALSE
    end

    if(target == 0) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[1] .. " not found.")
        return TRUE
    end

    if(not points) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "No point specified.")
        return TRUE
    end

points = math.abs(points)
    if(getPlayerVipPoints(cid) == -1) then
        doPlayerAddVipPoints(target, points+1)
        doSendMagicEffect(getCreaturePosition(target), CONST_ME_MAGIC_RED)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have added " .. points .. " points to " .. t[1] .. ".")
        return TRUE
    else
        doPlayerAddVipPoints(target, points)
        doSendMagicEffect(getCreaturePosition(target), CONST_ME_MAGIC_RED)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have added " .. points .. " points to " .. t[1] .. ".")
        return TRUE
    end

end

    if(words == "/removevip") then

    if(getPlayerGroupId(cid) < requiredGroup) then
        return FALSE
    end

    if(target == 0) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[1] .. " not found.")
        return TRUE
    end

    if(not points) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "No point specified.")
        return TRUE
    end

points = math.abs(points)
    doPlayerRemoveVipPoints(cid, points)
    doSendMagicEffect(getCreaturePosition(target), CONST_ME_MAGIC_RED)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have removed " .. points .. " points from " .. t[1] .. ".")
    return TRUE
end

    if(words == "/getvip") then

    if(getPlayerGroupId(cid) < requiredGroup) then
        return FALSE
    end

    target = getPlayerByNameWildcard(param)

    if(target == 0) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. param .. " not found.")
        return TRUE
    end

    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. param .. " have " .. getPlayerVipPoints(target) .. " points.")
    return TRUE
end

    if(words == "!buyitem") then

local buyableItems =
    {
    ["boots of haste"] = {id = 2195, count = 1, points = 3},
    ["amulet of loss"] = {id = 2173, count = 1, points = 5},
    ["soft boots"] = {id = 6132, count = 1, points = 20}
    }

local buyableItem = buyableItems[param]

    if buyableItem then
        if getPlayerVipPoints(cid) >= buyableItem.points then
            doPlayerAddItem(cid, buyableItem.id, buyableItem.count)
            doPlayerRemoveVipPoints(cid, buyableItem.points)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought x" .. buyableItem.count .. " " .. getItemNameById(buyableItem.id) .. ". " .. getPlayerVipPoints(cid) .. " points left.")
            return TRUE
        else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have enough vip points.")
        return TRUE
        end
    else
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Say !itemlist to see the items that you can buy or sell.")
    return TRUE
    end
end

    if(words == "!sellitem") then

local sellableItems =
    {
    ["boots of haste"] = {id = 2195, count = 1, points = 3},
    ["amulet of loss"] = {id = 2173, count = 1, points = 5},
    ["soft boots"] = {id = 6132, count = 1, points = 20}
    }

local sellableItem = sellableItems[param]

    if sellableItem then
        if getPlayerVipPoints(cid) > 0 then
            if doPlayerRemoveItem(cid, sellableItem.id, sellableItem.count) then
                doPlayerAddVipPoints(cid, sellableItem.points)
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sold x" .. sellableItem.count .. " " .. getItemNameById(sellableItem.id) .. ". " .. getPlayerVipPoints(cid) .. " points left.")
                return TRUE
            else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do no have that item.")
            return TRUE
            end
        else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to have 1 or more vip points to sell an item.")
        return TRUE
        end
    else
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Say !itemlist to see the items that you can buy or sell.")
    return TRUE
    end
end

    if(words == "!itemlist") then
        if(param == "buy") then
            local text = "Items that you can buy:\n\nName: Boots of haste, Price: 3 points.\nName: Amulet of loss, Price: 5 points.\nName: Soft boots, Price: 20 points.\n\nYou have " .. getPlayerVipPoints(cid) .. " vip points."
            doPlayerPopupFYI(cid, text)
            return TRUE
        elseif(param == "sell") then
            local txt = "Items that you can sell:\n\nName: Boots of haste, Price: 3 points.\nName: Amulet of loss, Price: 5 points.\nName: Soft boots, Price: 20 points.\n\nYou have " .. getPlayerVipPoints(cid) .. " vip points."
            doPlayerPopupFYI(cid, txt)
            return TRUE
        else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Say (!itemlist buy) or (!itemlist sell) to see the items that you can buy or sell.")
        return TRUE
        end
    end
end

These are the items that you can buy/sell

Code:
local items =
    {
    ["boots of haste"] = {id = 2195, count = 1, points = 3},
    ["amulet of loss"] = {id = 2173, count = 1, points = 5},
    ["soft boots"] = {id = 6132, count = 1, points = 20}
    }

Code:
id -- itemid
count -- item count that you will buy or sell
points -- cost in vip points

Code:
 vipStorage = 61155 --vip storage (Don't use it for a quest or something like that) Of course, you can change it.
requiredGroup = 3 --Group ID required to use /addvip, /removevip and /getvip

Words:

  • /addvip (Add vip points to a player. Ex: /addvip Darkhaos, 10)
  • /removevip (Remove vip points to a player. Ex: /removevip Darkhaos, 10)
  • /getvip (Get vip points from a player. Ex: /getvip Darkhaos <- this will send you a message "Player Darkhaos have 10 vip points")
  • !buyitem (buy items with vip points. Ex: !buyitem boots of haste)
  • !sellitem (Sell item by vip points. Ex: !sellitem boots of haste.)
  • !itemlist buy/sell (See the item list that you can buy or sell. Ex: !itemlist buy or !itemlist sell)






Is it possible to make it into an NPC?
 
Back
Top