Ir para conteúdo

Bug Script Surf Pokemon


deglorio

Posts Recomendados

Minha action de Surf é essa abaixo. Porém ela está com um bug, é possivel deslogar o char quando estou usando o surf.

Alguém me ajuda a resolver?

 

 

function onUse(cid, item, frompos, item2, topos)
local configs = {
[4647] = {x = -2, y = 0}, -- 4647 é o id da borda oeste (lado esquerdo do player) ----- Deixa assim
[4645] = {x = 2, y = 0}, -- 4645 é o id da borda leste (lado direito do player) ----- Deixa assim
[4646] = {x = 0, y = 2}, -- 4646 é o id da borda sul (abaixo do player) ----- Deixa assim
[4644] = {x = 0, y = -2}, -- 4644 é o id da borda norte (acima do player) ----- Deixa assim
}

local playerpos = getCreaturePosition(cid)
local pokes = {
["Poliwag"] = {lookType=278, speed = 400},
["Tentacruel"] = {lookType=185, speed = 400},
["Blastoise"] = {lookType=184, speed = 400},
["Dewgong"] = {lookType=183, speed = 400},
["Kabutops"] = {lookType=189, speed = 400},
["Omastar"] = {lookType=188, speed = 400},
["Gyarados"] = {lookType=187, speed = 400},
["Poliwrath"] = {lookType=190, speed = 400},
["Shiny Gyarados"] = {lookType=529, speed = 410},
["Shiny Seadra"] = {lookType=522, speed = 400},
["Shiny Tentacruel"] = {lookType=522, speed = 400},
["Squirtle"] = {lookType=273, speed = 400},
["Shiny Blastoise"] = {lookType=523, speed = 400},
["Wartotle"] = {lookType=275, speed = 400},
['Tentacool'] = {lookType=274, speed = 400},
['Staryu'] = {lookType=266, speed = 400},
['Starmie'] = {lookType=267, speed = 400},
['Golduck'] = {lookType=271, speed = 400},
['Poliwhirl'] = {lookType=137, speed = 400},
['Tentacool'] = {lookType=277, speed = 400},
['Goldeen'] = {lookType=268, speed = 400},
['Seaking'] = {lookType=269, speed = 400},
['Seadra'] = {lookType=270, speed = 400},
['Snorlax'] = {lookType=300, speed = 400},
['Vaporeon'] = {lookType=191, speed = 400},
}

if #getCreatureSummons(cid) <= 0 and getPlayerStorageValue(cid, 63215) <= 0 then
return doPlayerSendCancel(cid, "You need a pokemon to surf.")
end

l = false
for i,x in pairs(pokes) do
if getPlayerStorageValue(cid, 63215) <= 0 and i:lower() == getCreatureName(getCreatureSummons(cid)[1]):lower() then
l = true
end
end

if not l and getPlayerStorageValue(cid, 63215) <= 0 then
return doPlayerSendCancel(cid, "This pokemon can't surf.")
end

if getPlayerStorageValue(cid, 63215) <= 0 then
doTeleportThing(cid, {x=playerpos.x+configs[item2.itemid].x, y=playerpos.y+configs[item2.itemid].y, z=playerpos.z})
setPlayerStorageValue(cid, 63215, 1)
doSetCreatureOutfit(cid, pokes[getCreatureName(getCreatureSummons(cid)[1])], -1)
doCreatureSay(cid, "Let's surf, "..getCreatureName(getCreatureSummons(cid)[1]), 1)
setPlayerStorageValue(cid, 61209, getCreatureMaxHealth(getCreatureSummons(cid)[1]))
setPlayerStorageValue(cid, 61210, getCreatureHealth(getCreatureSummons(cid)[1]))
doChangeSpeed(cid, pokes[getCreatureName(getCreatureSummons(cid)[1])].speed)
doRemoveCreature(getCreatureSummons(cid)[1])
else
doTeleportThing(cid, {x=playerpos.x-configs[item2.itemid].x, y=playerpos.y-configs[item2.itemid].y, z=playerpos.z})
setPlayerStorageValue(cid, 63215, 0)
doRemoveCondition(cid, CONDITION_OUTFIT)
local item = getPokeOutLive(cid)[1]
doCreatureSay(cid, "Im tired of surf, " .. getItemAttribute(item, "poke"):match("This is (.-)'s pokeball."), 1)
pk = doSummonCreature(getItemAttribute(item, "poke"):match("This is (.-)'s pokeball."), getThingPosition(cid))
doConvinceCreature(cid, pk)
registerCreatureEvent(pk, "DiePoke")
registerCreatureEvent(cid, "PlayerPokeDeath")
registerCreatureEvent(cid, "LogoutPoke")
setCreatureMaxHealth(pk, getPlayerStorageValue(cid, 61209))
doCreatureAddHealth(pk, getPlayerStorageValue(cid, 61209))
doCreatureAddHealth(pk, getPlayerStorageValue(cid, 61210)-getPlayerStorageValue(cid, 61209))
doChangeSpeed(cid, getCreatureBaseSpeed(cid)-getCreatureSpeed(cid))
end
return TRUE
end

 

Dou REP+ xD

Link para o comentário
Compartilhar em outros sites

Mais o normal é poder logar mesmo, não tem porque proibir alguem de logar no surf (a menos que estaja dando bug ou seja do seu interesse), mas se mesmo assim voce quizer proibir o player de logar enquanto estiver no surf tenta usa isso: (pelo que vi voce esta usando o script do MatheusMkalo, então fiz baseado no dele)

 

Se estiver usando o do Mkalo mesmo vai tem um arquivo chamado goback.lua la no seu creaturescript, vá ate ele e substitua por este:

 

function onLogout(cid)
   if getPlayerStorageValue(cid, 63215) >= 1 then
   doPlayerSendCancel(cid, 'You can not logout in while surfing.')
   return FALSE
   end
local health,maxhealth = getSummonLifes(cid)
   if getPlayerStorageValue(cid, 61204) >= 1 and getPlayerStorageValue(cid, 63215) <= 0 and getPlayerStorageValue(cid, 62314) <= 0 and getPlayerStorageValue(cid, 59987) <= 0 then
       setPlayerStorageValue(cid, 61205, health)
       setPlayerStorageValue(cid, 61206, maxhealth)
       setPlayerStorageValue(cid, 61204, 0)
       setPlayerStorageValue(cid, 61207, 1)
   end

   if getPlayerStorageValue(cid, 62314) >= 1 then
       pos = getCreaturePosition(cid)
       for i = 1,8 do
           doRemoveTile(getPosDirs(getCreaturePosition(cid), i))
       end
       doRemoveTile(getCreaturePosition(cid))
       setPlayerStorageValue(cid, 61941, pos.x)
       setPlayerStorageValue(cid, 61942, pos.y)
       setPlayerStorageValue(cid, 61943, pos.z) 
   end
return TRUE
end

function onLogin(cid)
   local pokes = {
   ["Poliwhil"] = {lookType = 137, speed = 1500},
   ["Seaking"] = {lookType = 142, speed = 1500},
   ["Dewgong"] = {lookType = 183, speed = 1500},
   ["Blastoise"] = {lookType = 184, speed = 1500},
   ["Tantacruel"] = {lookType = 185, speed = 1500},
   ["Lapras"] = {lookType = 186, speed = 1500},
   ["Gyarados"] = {lookType = 187, speed = 1500},
   ["Omanstar"] = {lookType = 188, speed = 1500},
   ["Kabutops"] = {lookType = 189, speed = 1500},
   ["Poliwhrat"] = {lookType = 190, speed = 1500},
   ["Vaporeon"] = {lookType = 191, speed = 1500},
   ["Staryu"] = {lookType = 266, speed = 1500},
   ["Starmie"] = {lookType = 267, speed = 1500},
   ["Goldeen"] = {lookType = 268, speed = 1500},
   ["Seadra"] = {lookType = 270, speed = 1500},
   ["Golduck"] = {lookType = 271, speed = 1500},
   ["Squirtle"] = {lookType = 273, speed = 1500},
   ["Wartortle"] = {lookType = 275, speed = 1500},
   ["Tentacool"] = {lookType = 277, speed = 1500},
   ["Poliwag"] = {lookType = 278, speed = 1500},
   ["Snorlax"] = {lookType = 300, speed = 1500},
   }

   local pokesfly = {
   ["Charizard"] = {lookType = 216, speed = 500},
   ["Dragonite"] = {lookType = 221, speed = 500},
   ["Pidgeot"] = {lookType = 222, speed = 500},
   ["Zapdos"] = {lookType = 224, speed = 500},
   ["Aerodactyl"] = {lookType = 227, speed = 500},
   ["Moltres"] = {lookType = 229, speed = 500},
   ["Articuno"] = {lookType = 230, speed = 500},
   ["Mew"] = {lookType = 232, speed = 500},
   ["Mewtwo"] = {lookType = 233, speed = 500},
   ["Elder Charizard"] = {lookType = 295, speed = 500},
   }

   local pokesride = {
   ["Arcanine"] = {lookType = 12, speed = 1050},
   ["Onix"] = {lookType = 126, speed = 1200},
   ["Tauros"] = {lookType = 128, speed = 500},
   ["Ninetails"] = {lookType = 129, speed = 700},
   ["Rapidash"] = {lookType = 130, speed = 1000},
   ["Ponyta"] = {lookType = 131, speed = 350},
   ["Rhyhorn"] = {lookType = 132, speed = 550},
   ["Dodrio"] = {lookType = 133, speed = 600},
   ["Venusaur"] = {lookType = 134, speed = 1100},
   ["Crystal Onix"] = {lookType = 293, speed = 1200},
   ["Doduo"] = {lookType = 135, speed = 300},
   }

   if getPlayerStorageValue(cid, 62314) >= 1 then
       doCreateTile(460, {x=getPlayerStorageValue(cid, 61941), y=getPlayerStorageValue(cid, 61942), z=getPlayerStorageValue(cid, 61943)})
       doTeleportThing(cid, {x=getPlayerStorageValue(cid, 61941), y=getPlayerStorageValue(cid, 61942), z=getPlayerStorageValue(cid, 61943)}) 
       for i = 1,8 do
           doItem(getPosDirs(getCreaturePosition(cid), i), 65119+i)
       end
       local item = getPokeOutLive(cid)[1]
       local a = getItemAttribute(item, "poke"):match("This is (.-)'s pokeball.")
       doSetCreatureOutfit(cid, pokesfly[tostring(a)], -1)
       doChangeSpeed(cid, pokesfly[tostring(a)].speed)
       registerCreatureEvent(cid, "PlayerPokeDeath")  
   end

   if getPlayerStorageValue(cid, 63215) >= 1 then
       local item = getPokeOutLive(cid)[1]
       local a = getItemAttribute(item, "poke"):match("This is (.-)'s pokeball.")
       doSetCreatureOutfit(cid, pokes[tostring(a)], -1)
       doChangeSpeed(cid, pokes[tostring(a)].speed)
       registerCreatureEvent(cid, "PlayerPokeDeath")
   end

   if getPlayerStorageValue(cid, 59987) >= 1 then
       local item = getPokeOutLive(cid)[1]
       local a = getItemAttribute(item, "poke"):match("This is (.-)'s pokeball.")
       doSetCreatureOutfit(cid, pokesride[tostring(a)], -1)
       doChangeSpeed(cid, pokesride[tostring(a)].speed)
       registerCreatureEvent(cid, "PlayerPokeDeath")
   end

   if getPlayerStorageValue(cid, 61207) >= 1 then
       local item = getPokeOutLive(cid)[1]
       doTransformItem(item, pokein)
       doRemoveCondition(cid, CONDITION_OUTFIT)
       doItemSetAttribute(item, "poke", getItemAttribute(item, "poke"):sub(#getItemAttribute(item, "poke")) ~= "]" and getItemAttribute(item, "poke") .. " HP = ["..getPlayerStorageValue(cid, 61205).."/"..getPlayerStorageValue(cid, 61206).."]" or getItemAttribute(item, "poke"))
       setPlayerStorageValue(cid, 61207, 0)
   end

return TRUE
end

function onDeath(cid, deathList)
   local owner = getCreatureMaster(cid)
   doPlayerSendTextMessage(owner, 22, "Your pokemon died.")

   for slot = CONST_SLOT_FIRST, CONST_SLOT_LAST do
       local item = getPlayerSlotItem(owner, slot)
       if isContainer(item.uid) then
           local items = getItemsInContainerById(item.uid, diepoke)
           for _, ui in pairs(items) do
               if getItemAttribute(ui, "poke"):sub(#getItemAttribute(ui, "poke")) == "." then
                   local maxh = tonumber(getItemAttribute(ui, "poke"):match("/(.+)]"))
                   doItemSetAttribute(ui, "poke", getItemAttribute(ui, "poke"):sub(1, findLetter(getItemAttribute(ui, "poke"), ".")) .. " HP = [0/"..getCreatureMaxHealth(cid).."]")
               end
           end
      end

      if item.itemid == pokeout then
           if getItemAttribute(item.uid, "poke"):sub(#getItemAttribute(item.uid, "poke")) == "." then
               local maxh = tonumber(getItemAttribute(item.uid, "poke"):match("/(.+)]"))
               doItemSetAttribute(item.uid, "poke", getItemAttribute(item.uid, "poke"):sub(1, findLetter(getItemAttribute(item.uid, "poke"), ".")) .. " HP = [0/"..getCreatureMaxHealth(cid).."]")
           end
      end
   end
   doRemoveCreature(cid)
   setPlayerStorageValue(owner, 61207, 0)
   setPlayerStorageValue(owner, 61204, 0)
return FALSE
end

 

PS.: Eu não testei, se nao der certo me da um toque que eu vejo pra você

Editado por yahooABC
Link para o comentário
Compartilhar em outros sites

Ainda não eu certo, coloquei oq vc falou no go/back em creature scripts e mesmo assim não deu.

olhe meu go/back do creature script:

 

local pokein, pokeout = 2457,2457
function onDeath(cid, deathList)
   local owner = getCreatureMaster(cid)
   doPlayerSendTextMessage(owner, 21, "You pokemon died.")
   local item = getPlayerItemById(owner, TRUE, pokeout)
   doTransformItem(item.uid, pokein)
   doItemSetAttribute(item.uid, "aid", -1)
   doRemoveCreature(cid)  
return FALSE
end

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...