2 horas atrás, VitorSubhi disse:
Apresentação: Após ver que muitos usuários tinham interesse em um sistema de Trade de Points in-game resolvi trazer um sistema totalmente completo para vocês.
Funcionamento:
- Player 1 após adquirir os Points, pode iniciar uma negociação com o Player 2 através do comando /tradepoints Player 2, Quantidade.
- Será aberto uma Janela de Trade com o item referente aos Points.
- Após ambos aceitarem a negociação será realizado a troca de Points pelo item requisitado.
Algumas Imagens:
Instalação:
- Sources > Luascript.cpp
- Sources > Luascript.cpp
int32_t LuaInterface::luaDoTradeOrbs(lua_State* L) { ScriptEnviroment* env = getEnv(); int quantidade = popNumber(L); Player* target = env->getPlayerByUID(popNumber(L)); Player* player = env->getPlayerByUID(popNumber(L)); if(!player || !target) { errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND)); lua_pushboolean(L, false); return 1; } Item* Orb = new Item(7722);; Orb->addRef(); char buffer[150]; sprintf(buffer, "You see %d Collapser Orbs.", quantidade); Orb->setSpecialDescription(buffer); Orb->setSubType(1); player->transferContainer.__addThing(NULL, Orb); player->transferContainer.setParent(player); if(!g_game.internalStartTrade(player, target, Orb)) Orb->onTradeEvent(ON_TRADE_CANCEL, player, NULL); g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_WRAPS_BLUE); return false; }
- Sources > Luascript.h
- Server > Data > Lib > 050-function
function getAccountPoints(cid) local res = db.getResult('select `premium_points` from accounts where name LIKE \''..getPlayerAccount(cid)..'\'') return res:getDataInt("premium_points") < 0 and 0 or res:getDataInt("premium_points") end function doPlayerAddPoints(cid, quant) return db.query("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) + quant .."' WHERE `name` LIKE '"..getPlayerAccount(cid).."'") end function doAccountRemovePoints(cid, count) return db.query("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) - count .."' WHERE `name` LIKE '"..getPlayerAccount(cid).."'") end
- Server > Data > Creaturescripts > Scripts >Trade_Orbs.lua
function CompleteTrade(fromplayer, toplayer, points) if getPlayerItemCount(toplayer, 7722) >= 1 and getAccountPoints(fromplayer) >= points then doAccountRemovePoints(fromplayer, points) doPlayerRemoveItem(toplayer, 7722, 1) doPlayerAddPoints(toplayer, points) doPlayerSendTextMessage(toplayer, MESSAGE_STATUS_WARNING, "You have received ".. points .." Collapser Orbs.") return true end end function CollapserOrbs(item) return tonumber(string.match(getItemDescriptions(item.uid).special, "You see (%w+) Collapser Orbs.")) end function onTradeAccept(cid, target, item, targetItem) if isPlayer(cid) and isPlayer(target) then if item.itemid == 7722 then local points = CollapserOrbs(item) addEvent(CompleteTrade, 1, cid, target, points) end if targetItem.itemid == 7722 then local points = CollapserOrbs(targetItem) addEvent(CompleteTrade, 1, target, cid, points) end end return true end
- Server > Data > Creaturescripts > Creaturescripts.xml
- Server > Data > Creaturescripts > Scripts > Login.lua
- Server > Data > Talkactions > Scripts > Points_Trade.lua
function onSay(cid, words, param, channel) local t = string.explode(param, ",") local target = getCreatureByName(t[1]) local points = tonumber(t[2]) if(param == '') then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.") end if (target ~= nil) and isPlayer(target) and not isPlayerGhost(target) then if (points ~= nil) and (type(points) == 'number') and (points>0) then if (getAccountPoints(cid) >= points) then doTradeOrbs(cid, target, points) else doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You do not have enough points.") end else doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.") end else doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.") end return true end
- Server > Data > Talkactions > Talkactions.xml
Créditos:
Todo o sistema foi feito completamente por mim: Vítor Subhi.
Bom conteúdo, mas eu não sei mexer em source kkk











info
Grupo: Campones
Registrado: 16/06/15
Posts: 4
Reputação: +8
Apresentação: Após ver que muitos usuários tinham interesse em um sistema de Trade de Points in-game resolvi trazer um sistema totalmente completo para vocês.
Funcionamento:
Algumas Imagens:
Instalação:
Créditos:
Todo o sistema foi feito completamente por mim: Vítor Subhi.
Editado Abril 15 por VitorSubhi
Tratamento de Erros!