Créditos: 20% para Soulblaster -> ajudou a garantir compatibilidade com usuários Neverland;
80% para mim por ter feito a versão original e ajudado a montar a versão para Neverland;
HiHo!
Criei uma função em c++ que será usada nas actions. A função se chama: getPlayerPremmy e é usada: getPlayerPremmy(cid). Ela irá retornar 0 se o player for P.A. e retornar -1 se o player não for P.A. Mãos à obra!
C++
em actions.cpp
ache:
//getPlayerFood(uid) lua_register(luaState, "getPlayerFood", ActionScript::luaActionGetPlayerFood);
acima desse code adicione:
//getPlayerPremmy(uid) lua_register(luaState, "getPlayerPremmy", ActionScript::luaActionGetPlayerPremmy);
Agora no final de actions.cpp adicione: (YurOTS)
int ActionScript::luaActionGetPlayerPremmy(lua_State *L){ unsigned int cid = (unsigned int)internalGetNumber(L); //pega u id do player(cid) ActionScript *action = getActionScript(L); //pega a action const KnownThing* tmp = action->GetPlayerByUID(cid); if(tmp) { Player *player = (Player*)(tmp->thing); if(player && player->premiumTicks && player->premiumTicks > 0) { lua_pushnumber(L, 0); } else { lua_pushnumber(L, -1); } } else { lua_pushnumber(L, -1); std::cout << "getPlayerPremmy: player not found" << std::endl; return 1; } return 1;}
Agora no final de actions.cpp adicione: (NeverLand 4.2+)
int ActionScript::luaActionGetPlayerPremmy(lua_State *L){ unsigned int cid = (unsigned int)internalGetNumber(L); //pega u id do player(cid) ActionScript *action = getActionScript(L); //pega a actionconst KnownThing* tmp = action->GetPlayerByUID(cid);if(tmp) { Player *player = (Player*)(tmp->thing); if(player && player->premmium) { lua_pushnumber(L, 0); } else { lua_pushnumber(L, -1); } }else { lua_pushnumber(L, -1); std::cout << "getPlayerPremmy: player not found" << std::endl; return 1;} return 1;}
Agora em actions.h
procure por:
static int luaActionGetPlayerFood(lua_State *L);
Em cima disto adicione:
static int luaActionGetPlayerPremmy(lua_State *L);
Recompile tudo...
Actions
Crie um script chamado function.lua com esse code:
function onUse(cid, item, frompos, item2, topos)teleportlugar = {x=160, y=54, z=7}ppos = getPlayerPosition(cid)if item.itemid == 1945 then premmy = getPlayerPremmy(cid) if premmy == 0 then doTeleportThing(cid,teleportlugar) doTransformItem(item.uid,item.itemid+1) else doSendMagicEffect(ppos,2) doPlayerSendCancel(cid,"A não! Não sou P.A.!") doTransformItem(item.uid,item.itemid+1) endelseif item.itemid == 1946 then premmy = getPlayerPremmy(cid) if premmy == 0 then doTeleportThing(cid,teleportlugar) doTransformItem(item.uid,item.itemid-1) else doSendMagicEffect(ppos,2) doPlayerSendCancel(cid,"A não! Não sou P.A.!") doTransformItem(item.uid,item.itemid-1) endendreturn 1end
Adicionar a alavanca e o UID dela pelo mapeditor. Escolha a que você quiser...
Depois vá em data/actions e abra o arquivo actions.xml
No final (antes de </actions>) adicione:
<action uniqueid="ID_DA_ALAVANCA_QUE_VOCÊ_COLOCOU_PELO_MAPEDITOR" script="function.lua" />
Espero ter ajudado...
FlW
CyA!