quinta-feira, 9 de fevereiro de 2012

Trade System


  • 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:
Código PHP:
function onSay(cidwordsparamid getItemIdByName(paramidby getItemNameById(paramlocal data string.explode(param","iddata getItemIdByName(data[1])

function 
doreturnadd(cidlocal directory "data//trade//tradelist.txt"           local newcontent

local file 
io.open(directory,"r"local content file:read(-1newcontent string.gsub (content"end"'doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "'.. getCreatureName(cid) ..' - '.. data[1] ..' - '.. data[2] ..'")'1file:close()
local file io.open(directory,"w+"file:write(newcontentfile:close(newcontentonFile("update"directory"end"end
if tonumber(data[2]) == nil then
doPlayerSendTextMessage
(cidMESSAGE_STATUS_CONSOLE_BLUE"Coloque o preço.")
return 
TRUE
end 
if getPlayerStorageValue(cid,4535) == 1 then
doPlayerSendTextMessage
(cidMESSAGE_STATUS_CONSOLE_BLUE"Voce ja colocou um item a venda.")
return 
TRUE
end
    
if(iddata == LUA_ERROR) == TRUE then
doPlayerSendTextMessage
(cidMESSAGE_STATUS_CONSOLE_BLUE"Este item não existe.")
return 
TRUE elseif getPlayerItemCount(cididdata) <= 0 then
doPlayerSendTextMessage
(cidMESSAGE_STATUS_CONSOLE_BLUE"Você não possui este item.")
return 
TRUE elseif(iddata == LUA_ERROR) == FALSE then
doPlayerSendTextMessage
(cidMESSAGE_STATUS_CONSOLE_BLUE"Você deixou na lista de vendas sua ".. data[1] .." pelo preço de ".. data[2] .." gold coins."doPlayerRemoveItem(cididdata1setPlayerStorageValue(cid45351setPlayerStorageValue(cid4538getItemIdByName(data[1])) setPlayerStorageValue(cid4539data[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:
Código PHP:
function onSay(cidwordsparampid getPlayerByName(param)
function 
doreturnadd(cidlocal directory "data//trade//tradelist.txt"           local newcontent

local file 
io.open(directory,"r"local content file:read(-1newcontent string.gsub (content'doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "'.. getCreatureName(pid) ..'''REMOVIDO'1file:close()
local file io.open(directory,"w+"file:write(newcontentfile:close(newcontentonFile("update"directory'doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "'.. getCreatureName(pid) ..''end
if isPlayer(paramthen if getPlayerMoney(cid) >= getPlayerStorageValue(pid,4539then if getPlayerStorageValue(pid,4538) ~= -1 then if getPlayerStorageValue(pid,4535) ~= -1 then
doPlayerRemoveMoney
(cidgetPlayerStorageValue(pid,4539)) doPlayerAddItem(cidgetPlayerStorageValue(pid,4538), 1doPlayerAddMoney(pidgetPlayerStorageValue(pid,4539)) doPlayerRemoveItem(pidgetPlayerStorageValue(pid,4538), 1setPlayerStorageValue(pid4538, -1setPlayerStorageValue(pid4535, -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(cidparam .." 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(cidwordsparamdoPlayerSendTextMessage(cidMESSAGE_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 chamadotradelist.txt e adicione as seguintes informações:
Código PHP:
function onSay(cidwordsparamdoPlayerSendTextMessage(cidMESSAGE_STATUS_CONSOLE_BLUE"QUEM VENDE - NOME DO ITEM - PREÇO:"end  
Vá no arquivo, talkactions/talkactions.xml e adicione:
Código PHP:
    <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"/>  

Nenhum comentário:

Postar um comentário