Ir para conteúdo

Featured Replies

Postado
  • Autor
Em 17/02/2016 20:22:53, Sekk disse:

Como assim um item de tranferência de pontos?

Um Item que ao dar trade com outro player, transfere os points tlg? em certa quantidade...

Em 17/02/2016 20:47:13, vankk disse:

Eu achei um script na internet, e dei uma leve editada, da uma conferida, porém, é NPC:

 


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

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)
	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` + '"..amount.."' WHERE `id` = '"..pid.."' ;")
end

function greetCallback(cid)
	Topic[cid] = 0
	return true
end

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)
			selfSay("To who this will be transfered?",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])
			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())

 

Queria que fosse Item, pra dar dos players vender points entre si. 

  • Respostas 20
  • Visualizações 1.1k
  • Created
  • Última resposta

Top Posters In This Topic

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo