Ir para conteúdo
Entre para seguir isso  
PoRaI

Trade System

Recommended Posts

PoRaI    0
PoRaI

  • Nome do Script: Trade System
  • Nome do Autor: PoRaI
  • Servidor Testado: Nenhum ainda :S, não estou em minha casa mas após chegar eu testo.
  • Descrição: Sistema de trade onde você pode adicionar o item em uma seção de market.

 

O sistema e baseado em um market, você pode anunciar um item é assim possivel... Vender-lo... Crie um arquivo na pasta data/talkaction/scripts, chamado sell.lua e coloque as seguintes informações dentro dele:

function onSay(cid, words, param)
id = getItemIdByName(param)
idby = getItemNameById(param)
local data = string.explode(param, ",")
iddata = getItemIdByName(data[1])

function doreturnadd(cid)
local directory = "data//trade//tradelist.txt"          
local newcontent

local file = io.open(directory,"r")
local content = file:read(-1)
newcontent = string.gsub (content, "end", 'doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "'.. getCreatureName(cid) ..' - '.. data[1] ..' - '.. data[2] ..'")', 1)
file:close()

local file = io.open(directory,"w+")
file:write(newcontent)
file:close(newcontent)
onFile("update", directory, "end")
end

if tonumber(data[2]) == nil then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Coloque o preço.")
return TRUE
end
if getPlayerStorageValue(cid,4535) == 1 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Voce ja colocou um item a venda.")
return TRUE
end

if(iddata == LUA_ERROR) == TRUE then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Este item não existe.")
return TRUE
elseif getPlayerItemCount(cid, iddata) <= 0 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você não possui este item.")
return TRUE
elseif(iddata == LUA_ERROR) == FALSE then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você deixou na lista de vendas sua ".. data[1] .." pelo preço de ".. data[2] .." gold coins.")
doPlayerRemoveItem(cid, iddata, 1)
setPlayerStorageValue(cid, 4535, 1)
setPlayerStorageValue(cid, 4538, getItemIdByName(data[1]))
setPlayerStorageValue(cid, 4539, data[2])
doreturnadd(cid)
return TRUE
end
end

 

em seguinda, na pasta talkactions/scripts novamente... um outro arquivo chamado buy.lua, contendo as seguintes informações:

function onSay(cid, words, param)
pid = getPlayerByName(param)
function doreturnadd(cid)
local directory = "data//trade//tradelist.txt"          
local newcontent

local file = io.open(directory,"r")
local content = file:read(-1)
newcontent = string.gsub (content, 'doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "'.. getCreatureName(pid) ..'', 'REMOVIDO', 1)
file:close()

local file = io.open(directory,"w+")
file:write(newcontent)
file:close(newcontent)
onFile("update", directory, 'doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "'.. getCreatureName(pid) ..'')
end

if isPlayer(param) then
if getPlayerMoney(cid) >= getPlayerStorageValue(pid,4539) then
if getPlayerStorageValue(pid,4538) ~= -1 then
if getPlayerStorageValue(pid,4535) ~= -1 then
doPlayerRemoveMoney(cid, getPlayerStorageValue(pid,4539))
doPlayerAddItem(cid, getPlayerStorageValue(pid,4538), 1)
doPlayerAddMoney(pid, getPlayerStorageValue(pid,4539))
doPlayerRemoveItem(pid, getPlayerStorageValue(pid,4538), 1)
setPlayerStorageValue(pid, 4538, -1)
setPlayerStorageValue(pid, 4535, -1)
else
doPlayerSendCancel(cid,"Ele não está negociando nenhum item.")        
end
else
doPlayerSendCancel(cid,"Ele não está negociando nenhum item.")
end
else
doPlayerSendCancel(cid,"Você não possui dinheiro.")
end
else
doPlayerSendCancel(cid, param .." não está online ou ele não existe.")
end
end[/spoiler]

vá na pasta data e crie uma pasta chamada '[b]trade[/b]' e dentro dela um arquivo chamado tradelist.txt e dentro dele:
[spoiler="tradelist.txt"]function onSay(cid, words, param)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "QUEM VENDE - NOME DO ITEM - PREÇO:")
end

 

Agora você devera criar uma pasta no diretorio "data/..." com o nome de trade e dentro da pasta trade crie um arquivo chamado tradelist.txt e adicione as seguintes informações:

function onSay(cid, words, param)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "QUEM VENDE - NOME DO ITEM - PREÇO:")
end

 

Vá no arquivo, talkactions/talkactions.xml e adicione:

	<talkaction log="yes" access="0" words="/buy" event="script" value="buy.lua"/>
<talkaction log="yes" access="0" words="/sell" event="script" value="sell.lua"/>
<talkaction log="yes" access="0" words="/view" event="script" value="data//trade//tradelist.txt"/>

Editado por PoRaI

Compartilhar este post


Link para o post
Oneshot    24
Oneshot

Aprovado e Movido!

Editado por Garou

Compartilhar este post


Link para o post
JhonnyMotta    0
JhonnyMotta

Script muito bom, parabeens *-*

 

Já vi um script parecido ^^

Compartilhar este post


Link para o post
mortet    0
mortet

Legal Muito bom bem feito e meio simples

Compartilhar este post


Link para o post
James Bond    0
James Bond

Nao funciono aki,

Voce nem explicou como e os comandos....

tipo e !sell nome do item

 

aff

Compartilhar este post


Link para o post
lordbrbr    0
lordbrbr

Otimo script, tive algumas dificuldades mas nada incorrigivel, o principal ta ai. Parabens!

Compartilhar este post


Link para o post
portilho    0
portilho

no Real Server 3.0 tfs 0.3.6, nao esta funcionando porque nao tem a funcao getidbyname, saberia como fazer nele?!

Compartilhar este post


Link para o post
Kekezito_LHP    1
Kekezito_LHP

falta mais esplicaçao =D

Compartilhar este post


Link para o post
MeLaHeLL    0
MeLaHeLL

Arruma essa codificação ae mano, ta tudo bugado, olha o 2º script todo errado com tags SPOILERS nos codes, btw, idea boa.

E nçao funfo, tentando fazer funcionar .. o buy da erro.

Compartilhar este post


Link para o post
Visitante
Este tópico está impedido de receber novos posts.
Entre para seguir isso  
  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×