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

NPC that transfer premium points!

kito2

www.masteria.net
Joined
Mar 9, 2009
Messages
3,764
Solutions
1
Reaction score
227
Location
Chile, Santiago
Hi there, could someone make an NPC that transfer your premium points to other players, they should retrieve you like X amount, and then they will transfer a 90% of the value (comision for using the system).

Would be very nice!
 
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}
 
function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)            npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)            npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                    npcHandler:onThink() end
 
 --[[Edit]]--
  local per = 90 -- percentege that will be sent to player 
 
 
 --[[functions]]--
function getPoints(cid) 
    local res = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `name` = '"..getPlayerAccount(cid).."' LIMIT 1 ;")
	local value = 0
	if(res:getID() ~= -1) then
		value = res:getDataInt("premium_points")
		res:free()
	end
return value
end
function transfer(from,to,amount,perc) --percent equal the amount that will be tranferred
local pid = (getAccountIdByName(string.lower(to)))
local player = getAccountIdByName(string.lower(getCreatureName(from)))
 db.executeQuery("UPDATE `accounts` set `premium_points`=`premium_points` - '"..amount.."' WHERE `id` = '"..player.."' ;")
 db.executeQuery("UPDATE `accounts` set `premium_points`=`premium_points` + '"..math.floor(amount * (perc/100)).."' WHERE `id` = '"..pid.."' ;")
 
end
 
function greetCallback(cid)
	Topic[cid] = 0
	return true
end
--[[Script start]]--
 
function creatureSayCallback(cid, type, msg)
 
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    if (msgcontains(msg, 'transfere') or msgcontains(msg, 'yes')) and Topic[cid] ~= 1 and Topic[cid] ~= 2 then
	 selfSay("Ok, You have "..getPoints(cid).." premium points, how much you want to transfer?",cid)
         Topic[cid] = 1
 
    elseif Topic[cid] == 1 then 
 
            if not tonumber(msg) then
				selfSay("You must type the amount of points, try again!",cid)
			else
				msg = math.floor(math.abs(msg))
				t= {}
 
					if tonumber(msg) > getPoints(cid) then
						return selfSay("You only have "..getPoints(cid)..", try again!",cid)
					end
 
		        table.insert(t,msg)
		        table.insert(t,math.floor(msg * (per/100)))
		        selfSay("To who this will be transfered? Remember that the comission is {".. 100-per.."%}, so you will just transfer {"..math.floor(msg * (per/100)).."} points, and {"..msg - math.floor(msg * (per/100)).."} points will go to  me.",cid)
				Topic[cid] = 2
			end
 
	elseif Topic[cid] == 2 then 
        if getPoints(cid) < t[2] then
			selfSay("You only have "..getPoints(cid)..", try again!",cid) 
			Topic[cid] = 1
			return true
		end
		if getAccountIdByName(msg) > 0 then
			transfer(cid,msg,t[1],per)
			selfSay("You have successfuly transfered "..t[2].." points to "..msg..".",cid)
			Topic[cid] = 0
		else
			selfSay("Player doesnt exist, try again!",cid)
		end
	end
 
	return true
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top