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

Vip system (transfer points to other players)

ToloXXX

New Member
Joined
Dec 14, 2014
Messages
93
Reaction score
4
Does anyone have a a talkaction script to transfer vip points to other players?

For example we currently have a vip system which players donate for points use the points to buy off for special gear and others items server offers, We have an npc which uses the system to add and take away points, we also have a check vip points status which shows how much points you have. All we are missing is a transfer so when they say !transfer Jake, 3 it takes aways 3 points from your current data and send it to player you want to send it to. We are running .0.3.6 forgottnserver cliente 8.6 database runned on a server.
 
I could possibly help..

Is your vip points stored as a storage value, or in a special spot in the database?
 
I could possibly help..

Is your vip points stored as a storage value, or in a special spot in the database?

yea special spot, I can show you some script so you can see

I could possibly help..

Is your vip points stored as a storage value, or in a special spot in the database?

function getPlayerVipPoints(cid)
local Info = db.getResult("SELECT `vip_points` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1")
if Info:getID() ~= LUA_ERROR then
local Points= Info:getDataInt("vip_points")
Info:free()
return Points
end
return LUA_ERROR
end

function doPlayerAddVipPoints(cid, points)
local dif = getPlayerVipPoints(cid) + points
if dif >= 0 then
db.executeQuery("UPDATE `accounts` SET `vip_points` = `vip_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
return TRUE
end
return FALSE
end

function doPlayerRemoveVipPoints(cid, points)
local dif = getPlayerVipPoints(cid) - points
if dif >= 0 then
db.executeQuery("UPDATE `accounts` SET `vip_points` = `vip_points` - " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
return TRUE
end
return FALSE
end
function getAccountPoints(cid)
local res = db.getResult('select `vip_points` from accounts where name = \''..getPlayerAccount(cid)..'\'')
if(res:getID() == -1) then
return false
end
local ret = res:getDataInt("vip_points")
res:free()
return tonumber(ret)
end

function getAccountPremiumPoints(cid)
local res = db.getResult('select `vip_points` from accounts where name = \''..getPlayerAccount(cid)..'\'')
if(res:getID() == -1) then
return 0
end
local ret = res:getDataInt("vip_points")
res:free()
return tonumber(ret)
end

function doAccountAddPremiumPoints(cid, count)
return db.executeQuery("UPDATE `accounts` SET `vip_points` = `vip_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end

function doAccountRemovePremiumPoints(cid, count)
return db.executeQuery("UPDATE `accounts` SET `vip_points` = `vip_points` - " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end


thats what i have so far in my function so all scripts can work
 
Last edited by a moderator:
try this
XML:
<talkaction words="!transferpoints;/transferpoints" event="script" value="transferpoints.lua"/>
Lua:
local function transferVipPoints(cid, target, points)
   if not isPlayer(cid) or not isPlayer(target) then
       return false
   end
   if doPlayerRemoveVipPoints(cid, points) == TRUE then
       doPlayerAddVipPoints(target, points)
       return true
   end
   return false
end

function onSay(cid, words, param, channel)
   if param == "" then
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required. Example: /transferpoints 3, Xikini")
       return true
   end

   local t = string.explode(param, ",")
   if t[2] == "" then
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required. Example: /transferpoints 3, Xikini")
       return true
   end
  
   local points = tonumber(t[1])
   if not points then
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, t[1] .." is not a known number. Example: /transferpoints 3, Xikini")
       return true
   end
  
   local check2 = string.lower(t[2])
   local target = 0
   for _, pid in ipairs(getPlayersOnline()) do
       if getCreatureName(pid) == check2 then
           target = pid
           break
       end
   end
   if target == 0 then
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. check2 .. " is not online or does not exist.")
       return true
   elseif target == cid then
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot transfer points to yourself.")
       return true
   end
  
   if transferVipPoints(cid, target, points) == true then
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Successfully transfered " .. t[1] .. " points to " .. check2 .. ".")
   else
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Transfer not successful. You do not have " .. t[1] .. " points to transfer.")
   end
   return true
end

Sorry, forgot 1 thing.
Lua:
local points = tonumber(t[1])
if not points then
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, t[1] .." is not a known number. Example: /transferpoints 3, Xikini")
   return true
end
if points < 1 then
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Points to transfer must be a value above 0. Example: /transferpoints 3, Xikini")
   return true
end
 
Last edited by a moderator:
try this
XML:
<talkaction words="!transferpoints;/transferpoints" event="script" value="transferpoints.lua"/>
Lua:
local function transferVipPoints(cid, target, points)
   if not isPlayer(cid) or not isPlayer(target) then
       return false
   end
   if doPlayerRemoveVipPoints(cid, points) == TRUE then
       doPlayerAddVipPoints(target, points)
       return true
   end
   return false
end

function onSay(cid, words, param, channel)
   if param == "" then
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required. Example: /transferpoints 3, Xikini")
       return true
   end

   local t = string.explode(param, ",")
   if t[2] == "" then
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required. Example: /transferpoints 3, Xikini")
       return true
   end
 
   local points = tonumber(t[1])
   if not points then
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, t[1] .." is not a known number. Example: /transferpoints 3, Xikini")
       return true
   end
 
   local check2 = string.lower(t[2])
   local target = 0
   for _, pid in ipairs(getPlayersOnline()) do
       if getCreatureName(pid) == check2 then
           target = pid
           break
       end
   end
   if target == 0 then
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. check2 .. " is not online or does not exist.")
       return true
   elseif target == cid then
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot transfer points to yourself.")
       return true
   end
 
   if transferVipPoints(cid, target, points) == true then
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Successfully transfered " .. t[1] .. " points to " .. check2 .. ".")
   else
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Transfer not successful. You do not have " .. t[1] .. " points to transfer.")
   end
   return true
end





Looks great no errors, the only thing is when you put an exact players name it tells me this:
12:46 Player angel is not online or does not exist.

I used it capitalized and not capitalized his name and still says the same thing.
 
Code:
<talkaction words="!transferpoints;/transferpoints" event="script" separator=" " value="transferpoints.lua"/>
 
try this
XML:
<talkaction words="!transferpoints;/transferpoints" event="script" value="transferpoints.lua"/>
Lua:
local function transferVipPoints(cid, target, points)
   if not isPlayer(cid) or not isPlayer(target) then
       return false
   end
   if doPlayerRemoveVipPoints(cid, points) == TRUE then
       doPlayerAddVipPoints(target, points)
       return true
   end
   return false
end

function onSay(cid, words, param, channel)
   if param == "" then
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required. Example: /transferpoints 3, Xikini")
       return true
   end

   local t = string.explode(param, ",")
   if t[2] == "" then
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required. Example: /transferpoints 3, Xikini")
       return true
   end
 
   local points = tonumber(t[1])
   if not points then
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, t[1] .." is not a known number. Example: /transferpoints 3, Xikini")
       return true
   end
 
   local check2 = string.lower(t[2])
   local target = 0
   for _, pid in ipairs(getPlayersOnline()) do
       if getCreatureName(pid) == check2 then
           target = pid
           break
       end
   end
   if target == 0 then
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. check2 .. " is not online or does not exist.")
       return true
   elseif target == cid then
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot transfer points to yourself.")
       return true
   end
 
   if transferVipPoints(cid, target, points) == true then
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Successfully transfered " .. t[1] .. " points to " .. check2 .. ".")
   else
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Transfer not successful. You do not have " .. t[1] .. " points to transfer.")
   end
   return true
end

Sorry, forgot 1 thing.
Lua:
local points = tonumber(t[1])
if not points then
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, t[1] .." is not a known number. Example: /transferpoints 3, Xikini")
   return true
end
if points < 1 then
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Points to transfer must be a value above 0. Example: /transferpoints 3, Xikini")
   return true
end



I have 1 last request , sorry for not letting you know earlier, is it possible to make it as a trade type? when you trasnfer the points it pops out in the trade section and players trades for the points with what ever they like. THis is to avoid any scams
 
I have 1 last request , sorry for not letting you know earlier, is it possible to make it as a trade type? when you trasnfer the points it pops out in the trade section and players trades for the points with what ever they like. THis is to avoid any scams
You could make the talkaction set an actionID onto a special item.. and when that item is used, it adds that amount of points for that player..

So basically
Code:
player_1 -> adds time onto item
player_1 trades item with player_2
player_2 accepts item
player_2 uses item -> gains time from item
At least that's the only feasible way I can think of.

The talkaction above simply allows a player to GIVE another player time.
 
You could make the talkaction set an actionID onto a special item.. and when that item is used, it adds that amount of points for that player..

So basically
Code:
player_1 -> adds time onto item
player_1 trades item with player_2
player_2 accepts item
player_2 uses item -> gains time from item
At least that's the only feasible way I can think of.

The talkaction above simply allows a player to GIVE another player time.

So I use the commands and a item will appear to trade with the other player?
 
I am pretty sure this function can be used. If not you can look in your distro sources in game.cpp and cnt+f "sendtrade"

doPlayerSendTradeRequest(cid, target, item.uid)

Something like:

Lua:
if getPlayerVip(cid) > amount then
local item_vip = doPlayerAddItem(cid, itemid, 1)
    if item_vip then
        doPlayerRemoveVipDays(cid, amount)
        doItemSetAttribute(item_vip, "aid/uid", amount_days)
        doPlayerSendTradeRequest(cid, target, item_vip)
    end
end

This code wont work its just an example.

Then you need to make an action script for the item that will add the vip days when someone uses it and remove it from their inventory.
 
Back
Top