Ir para conteúdo

Featured Replies

Postado

Gente, não sei de quando é o tópico que eu vi, mas  enfim, preciso da ajuda de vcs!

 

To querendo um sistema tipo

!transfer Player, 10 -- esse comando abre um trade direto com o Player pra trocar 10 premium points. No trade, aparece um item que eu escolho em um código, ai o cara aceita, eu perco 10 premium points na DB e o cara recebe esses 10 points.

 

No tópico que eu vi, o cara falou pra adicionar isso na source:

 

luascript.h

static int32_t luaDoStartTrade(lua_State* L);

luascript.cpp

//doStartTrade(cid, target, item)
lua_register(m_luaState, "doStartTrade", LuaInterface::luaDoStartTrade);
int32_t LuaInterface::luaDoStartTrade(lua_State* L)
{
    ScriptEnviroment* env = getEnv();

    Item* item = env->getItemByUID(popNumber(L));
    if(!item)
    {
        errorEx(getError(LUA_ERROR_ITEM_NOT_FOUND));
        lua_pushboolean(L, false);
        return 1;
    }

    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;
    }


    if(g_game.internalStartTrade(player, target, item))
    {
        lua_pushboolean(L, true);
        return 1;
    }
    return 1;
}

 

Adicionei e compilei, deu certo, nenhum erro, blz, ai os scripts são esses q ele passou:

talkaction

Spoiler

function onSay(cid, words, param, param2, channel)

local t = string.explode(param, ",")
local target = getCreatureByName(t[1])
local points = tonumber(t[2])
local item = 2233
local storage = 21223

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 getPlayerVipPoints(cid) > points then
			local addItem = doPlayerAddItem(cid, item, 1)
			doStartTrade(cid, target, addItem)
			doItemSetAttribute(addItem, "description", "Transferência de "..points.." premium points.")
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você deu trade no jogador "..getPlayerName(target)..", com a intenção de trocar "..points.." premium points.")
			doPlayerSendTextMessage(target, MESSAGE_INFO_DESCR, "O Jogador "..getPlayerName(cid).." deu trade em você, e está disposto a trocar "..points.." premium points.")
			setPlayerStorageValue(cid, storage, points)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você não tem essa quantidade de premium 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

 

 

creaturescripts

Spoiler

function onTradeAccept(cid, target, item)

local storage = 21223

local sto = getPlayerStorageValue(cid, storage)
if sto > 0 then
	doPlayerRemoveVipPoints(cid, sto)
	doPlayerAddVipPoints(target, sto)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você trocou "..sto.." premium points, Parabéns.")
	doPlayerSendTextMessage(target, MESSAGE_STATUS_CONSOLE_BLUE, "Você realizou uma troca e adquiriu "..sto.." premium points, Parabéns.")
	setPlayerStorageValue(cid, storage, 0)
end

return true
end

 

 

 

Eu não sei o que registrar no creaturescripts.xml e nem se precisa registrar no login.lua '-' alguem me ajuda pfv?

Obs.: Eu acho que não tenho as funções

doPlayerRemoveVipPoints(cid)

doPlayerAddVipPoints(target)

 

Qual eu posso usar no lugar q tem o mesmo objetivo? uahaush, me ajudem pfv

 

@Fir3element @Vodkart @xWhiteWolf

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.9k

Informação Importante

Confirmação de Termo