Ir para conteúdo

Comprar Items Do Shop Do Seu Ot Por Comando


Subwat

Posts Recomendados

esse sistema funciona da seguinte maneira,vocÊ digita !buyitem ele compra o item do shopping do seu ot por POINTS do shopping!

 

talkaction

 

function onSay(cid,words,param)
	special sword if (param == 'special sword') then
	local config = {itemid = 8932,cost = 20,name = 'a special Sword'}
	if CurrentPoints(getPlayerAccount(cid)) < config.cost then
	doPlayerSendCancel(cid, "Sorry, You need " .. config.cost .. " points to buy " .. config.name .. ".")
	elseif doRemovePremiumPoints(getPlayerAccount(cid), config.cost) == true then
	doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_GREEN,"You have bought " .. config.name .. ".")
	doPlayerAddItem(cid, config.itemid, 1)
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_RED)
	else
	doPlayerSendCancel(cid, "Sorry, You need " .. config.cost .. " points to buy " .. config.name .. ".")
end
	return true
end
end special sword
else
doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_RED,'parametro incorreto.')
end		
return true
end

 

 

TAG:

<talkaction words="!buyitem" event="script" value="buy.lua" />

 

vai em LIB no arquivo 050-function cole isto no final:

 

 

function doRemovePremiumPoints(accountName, points)
points = tostring(points)
       return db.executeQuery('UPDATE `accounts` SET `premium_points` = `premium_points` -' .. points .. ' WHERE `name` = ' .. db.escapeString(accountName) .. ' LIMIT 1;')
end

function CurrentPoints(accountName)
playerpoints = db.getResult('SELECT `premium_points` FROM `accounts` WHERE `name` = ' .. db.escapeString(accountName) .. ' LIMIT 1;')
return playerpoints:getDataInt("premium_points")
end

function doPlayerGiveItem(cid, itemid, amount, subType)
local item = 0 if(isItemStackable(itemid)) then
item = doCreateItemEx(itemid, amount)
if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
	return false
end
else
for i = 1, amount do
item = doCreateItemEx(itemid, subType)

 

 

 

 

PRONTO.

 

créditos:

Subwat

Daniel Devotti

Editado por Subwat
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...