Jump to content
×
×
  • Create New...
  • 0

Função checar item na Bag


Go to solution Solved by FlamesAdmin,

Question

Versão do Servidor: TFS - 1.0
Tipo de Script: actions
Código:
 

    

Boa noite, alguem poderia me dizer qual a função devo colocar nesses scripts pra que o player so possa usar o Item se ele estiver na bag (atualmente se estiver no chão mais de uma pessoa pode usar).

Obgd desde já ❤️

 

O primeiro é de uma bike.

Spoiler

function onUse(cid, item, fromPosition, itemEx, toPosition)
local sBike = 16053
local t = {
[16053] = {article='a', name='bike',  s=5000, condition=bikeCondition},
}

function BikeSpeedOn(cid,nSpeed)
    setPlayerStorageValue(cid,sBike,getCreatureSpeed(cid))
    doChangeSpeed(cid,-getCreatureSpeed(cid))
    doChangeSpeed(cid,nSpeed)
end

function BikeSpeedOff(cid)
    doChangeSpeed(cid,-getCreatureSpeed(cid))
    doChangeSpeed(cid,getPlayerStorageValue(cid,sBike))
end

local v, r = getCreaturePosition(cid), t[item.itemid]
local s = r.s
local pos = {x = v.x, y = v.y, z = v.z}
if r then

if getPlayerStorageValue(cid, 17001) == 1 or getPlayerStorageValue(cid, 63215) == 1 or getPlayerStorageValue(cid, 17000) == 1 then
    return doPlayerSendCancel(cid, "Voce nao pode montar na (BIKE) se estiver no ride/fly/surf.")
end

if getPlayerStorageValue(cid, s) <= 0 then
    setPlayerStorageValue(cid, s, 1)
    BikeSpeedOn(cid,1000)
    if getPlayerSex(cid) == 1 then
        doSetCreatureOutfit(cid, {lookType = 2566, lookHead = 0, lookAddons = 0, lookLegs = 0, lookBody = 0, lookFeet = 0}, -1)
    else
        doSetCreatureOutfit(cid, {lookType = 2565, lookHead = 0, lookAddons = 0, lookLegs = 0, lookBody = 0, lookFeet = 0}, -1)
    end
elseif getPlayerStorageValue(cid, s) == 1 then
    setPlayerStorageValue(cid, s, 0)
    BikeSpeedOff(cid)
    return doRemoveCondition(cid, CONDITION_OUTFIT)
else
    return doPlayerSendCancel(cid, 'You can\'t do this.')
end
else
    return doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE, 'Report bugs in Bike system.')
end
end

 

O segundo Outfit por item.

Spoiler

function onUse(cid, item, frompos, fromPosition, topos, itemEx, toPosition)
  if getPlayerLevel(cid) >= 30 then
   questOut = getPlayerStorageValue(cid, 31503)
    if questOut == -1 then
     setPlayerStorageValue(cid, 1816, 1)
      doPlayerSendTextMessage(cid, 22, "Você Ganhou Um Novo Outfit.")
          doPlayerRemoveItem(cid, 20981, 1)
       setPlayerStorageValue(cid, 31503, 1)
        else
         doPlayerSendCancel(cid, "Você já possui essa outfit.")
          end
           else
            doPlayerSendTextMessage(cid, 22, "Você Não tem Level suficiente para Pegar a Recompesa 30+.")
             end
              end

 

Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 1
  • Solution

Se você tiver a função onMoveItem no seu servidor, em creaturescripts:

function onMoveItem(cid, item, fromPosition, toPosition, fromItem, toItem, fromGround, toGround, status)

local fromContainer = fromItem
  local toContainer = toItem

  if item.itemid == IDBIKE and isBiking(cid) then
    doPlayerSendCancel(cid, "Você não pode mover este item.")
    return false
  end

end


<event type="moveitem" name="MoveItem" event="script" value="player/moveItem.lua"/>

Adicione isso no some functions.lua da lib

function isBiking(cid)
	return getPlayerStorageValue(cid, 32001) == 1
end

function cancelBike(cid, NotOutfit)
	if not NotOutfit then
		doRemoveCondition(cid, CONDITION_OUTFIT)
	end
	setPlayerStorageValue(cid, 32001, -1)
end

Muda seu script da bike por esse:

local sBike = 2547
local t = {
  [16053] = {article='', name='', text='', dtext='', s=32001, condition=bikeCondition},
}

function BikeSpeedOn(cid,nSpeed)
  setPlayerStorageValue(cid,sBike,getCreatureSpeed(cid))
  doChangeSpeed(cid,-getCreatureSpeed(cid))
  doChangeSpeed(cid,nSpeed)
end

function BikeSpeedOff(cid)
  doChangeSpeed(cid,-getCreatureSpeed(cid))
  doChangeSpeed(cid,getPlayerStorageValue(cid,sBike))
end

function onUse(cid, item, fromPosition, itemEx, toPosition)

  local v, r = getCreaturePosition(cid), t[item.itemid]
  local s = r.s
  local pos = {x = v.x, y = v.y, z = v.z}

  if r then
    if getPlayerStorageValue(cid, 25000) == 5 then
      return
    end
    if getPlayerStorageValue(cid, 23000) == 5 then
      return
    end

    if getPlayerStorageValue(cid, 17001) >= 1 or getPlayerStorageValue(cid, 63215) >= 1 or
    getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 75846) >= 1 or
    getPlayerStorageValue(cid, 6598754) >= 1 or getPlayerStorageValue(cid, 6598755) >= 1 then   --alterado v1.9
      return doPlayerSendCancel(cid, "You can't do that right now.")
    end

    local underwater = {231, 670, 671, 5405, 5406, 5407, 5408, 5409, 5410, 5427, 5428, 5429, 5430, 5431, 5432, 5433, 5434, 5435, 5436, 5437, 5438}

    if isInArray(underwater, getTileInfo(getThingPos(cid)).itemid)  then
      return doPlayerSendCancel(cid, "Você não pode usar bike nesse local.")
    end

    if getPlayerStorageValue(cid, 22545) >= 1 then
      doPlayerSendCancel(cid, "Não pode usar isso aqui.")
      return true
    end

    if getPlayerStorageValue(cid, 10) >= 1 or getPlayerStorageValue(cid, 10) >= 1 then
      doPlayerSendCancel(cid, "Não pode usar bike na loja de roupas.")
      return true
    end

    if getPlayerStorageValue(cid, 154585) >= 1 then
      return doPlayerSendCancel(cid, "Desculpe, isso não é possível.")
    end

    if ( getPlayerItemCount(cid, 13984)  <= 0 ) then
      return doPlayerSendCancel(cid, 'Coloque na mochila para poder usar.')
    end

    if getPlayerStorageValue(cid, s) <= 0 then
      doCreatureSay(cid, r.text, 19)
      setPlayerStorageValue(cid, s, 1)
      BikeSpeedOn(cid,600)
      if getPlayerSex(cid) == 1 then
        doSetCreatureOutfit(cid, {lookType = 2566, lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet}, -1)
      else
        doSetCreatureOutfit(cid, {lookType = 2565, lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet}, -1)
      end

    elseif getPlayerStorageValue(cid, s) == 1 then
      doCreatureSay(cid, r.dtext, 19)
      setPlayerStorageValue(cid, s, 0)
      BikeSpeedOff(cid)
      return doRemoveCondition(cid, CONDITION_OUTFIT)
    else
      return doPlayerSendCancel(cid, 'You can\'t do this.')
    end
  else
    return doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE, 'Report bugs in Bike system.')
  end
  return true
end

 

Edited by FlamesAdmin
Link to post
Share on other sites
  • 1
57 minutos atrás, R e d disse:
Versão do Servidor: TFS - 1.0
Tipo de Script: actions
Código:
  Mostrar conteúdo oculto


 

Boa noite, alguem poderia me dizer qual a função devo colocar nesses scripts pra que o player so possa usar o Item se ele estiver na bag (atualmente se estiver no chão mais de uma pessoa pode usar).

Obgd desde já ❤️

 

O primeiro é de uma bike.

  Mostrar conteúdo oculto

function onUse(cid, item, fromPosition, itemEx, toPosition)
local sBike = 16053
local t = {
[16053] = {article='a', name='bike',  s=5000, condition=bikeCondition},
}

function BikeSpeedOn(cid,nSpeed)
    setPlayerStorageValue(cid,sBike,getCreatureSpeed(cid))
    doChangeSpeed(cid,-getCreatureSpeed(cid))
    doChangeSpeed(cid,nSpeed)
end

function BikeSpeedOff(cid)
    doChangeSpeed(cid,-getCreatureSpeed(cid))
    doChangeSpeed(cid,getPlayerStorageValue(cid,sBike))
end

local v, r = getCreaturePosition(cid), t[item.itemid]
local s = r.s
local pos = {x = v.x, y = v.y, z = v.z}
if r then

if getPlayerStorageValue(cid, 17001) == 1 or getPlayerStorageValue(cid, 63215) == 1 or getPlayerStorageValue(cid, 17000) == 1 then
    return doPlayerSendCancel(cid, "Voce nao pode montar na (BIKE) se estiver no ride/fly/surf.")
end

if getPlayerStorageValue(cid, s) <= 0 then
    setPlayerStorageValue(cid, s, 1)
    BikeSpeedOn(cid,1000)
    if getPlayerSex(cid) == 1 then
        doSetCreatureOutfit(cid, {lookType = 2566, lookHead = 0, lookAddons = 0, lookLegs = 0, lookBody = 0, lookFeet = 0}, -1)
    else
        doSetCreatureOutfit(cid, {lookType = 2565, lookHead = 0, lookAddons = 0, lookLegs = 0, lookBody = 0, lookFeet = 0}, -1)
    end
elseif getPlayerStorageValue(cid, s) == 1 then
    setPlayerStorageValue(cid, s, 0)
    BikeSpeedOff(cid)
    return doRemoveCondition(cid, CONDITION_OUTFIT)
else
    return doPlayerSendCancel(cid, 'You can\'t do this.')
end
else
    return doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE, 'Report bugs in Bike system.')
end
end

 

O segundo Outfit por item.

  Mostrar conteúdo oculto

function onUse(cid, item, frompos, fromPosition, topos, itemEx, toPosition)
  if getPlayerLevel(cid) >= 30 then
   questOut = getPlayerStorageValue(cid, 31503)
    if questOut == -1 then
     setPlayerStorageValue(cid, 1816, 1)
      doPlayerSendTextMessage(cid, 22, "Você Ganhou Um Novo Outfit.")
          doPlayerRemoveItem(cid, 20981, 1)
       setPlayerStorageValue(cid, 31503, 1)
        else
         doPlayerSendCancel(cid, "Você já possui essa outfit.")
          end
           else
            doPlayerSendTextMessage(cid, 22, "Você Não tem Level suficiente para Pegar a Recompesa 30+.")
             end
              end

 

    if item.uid ~= getPlayerSlotItem(cid, CONST_SLOT_RING).uid then
        doPlayerSendCancel(cid, "Você deve colocar sua bike no local correto.") -- Mensagem que da ao tentar usar a bike fora do slot
    return TRUE
end

 

Utilize para ambos

Spoiler

local config =
{
    velocidadeDaSuaBike = 6000, -- Velocidade da bike coloquei igual o do OtPokemon 
    outfitMale = 1951, -- Outfit MALE
    outfitFemale = 1950, -- Outfit FEMALE
    storageValue = 243656, -- Não mude
}
 
function onUse(cid, item, itemEx, fromPosition, toPosition)

    if item.uid ~= getPlayerSlotItem(cid, CONST_SLOT_RING).uid then
        doPlayerSendCancel(cid, "Você deve colocar sua bike no local correto.") -- Mensagem que da ao tentar usar a bike fora do slot (by: Lukas)
    return TRUE
end

    if getPlayerStorageValue(cid, 17001) > 0 or getPlayerStorageValue(cid, 17000) > 0 or getPlayerStorageValue(cid, 63215) > 0 then
        doPlayerSendCancel(cid, "Você não pode usar bike em situações especiais.")
    return true
end
 
    if isPlayer(cid) and getCreatureOutfit(cid).lookType == 814 then return false end
        if getPlayerStorageValue(cid, config.storageValue) <= 0 then
            local a = {lookType = config.outfitMale, lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet}
            local b = {lookType = config.outfitFemale, lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet}
            setPlayerStorageValue(cid, 3624, ""..getPlayerStamina(cid).."")
            doChangeSpeed(cid, -getCreatureSpeed(cid))
            doChangeSpeed(cid, config.velocidadeDaSuaBike)
            setPlayerStorageValue(cid, config.storageValue, 1)        
            if getPlayerSex(cid) == 0 then
                doSetCreatureOutfit(cid, b, -1)
            else
                doSetCreatureOutfit(cid, a, -1)
            end
        else
            setPlayerStorageValue(cid, config.storageValue, 0)
            doRemoveCondition(cid, CONDITION_OUTFIT)
            doRegainSpeedLevel(cid)
       end
    return true
end

local config =
{
    velocidadeDaSuaBike = 6000, -- Velocidade da bike coloquei igual o do OtPokemon 
    outfitMale = 1951, -- Outfit MALE
    outfitFemale = 1950, -- Outfit FEMALE
    storageValue = 243656, -- Não mude
}
 
function onUse(cid, item, itemEx, fromPosition, toPosition)

    if item.uid ~= getPlayerSlotItem(cid, CONST_SLOT_RING).uid then
        doPlayerSendCancel(cid, "Você deve colocar sua bike no local correto.") -- Mensagem que da ao tentar usar a bike fora do slot (by: Lukas)
    return TRUE
end

    if getPlayerStorageValue(cid, 17001) > 0 or getPlayerStorageValue(cid, 17000) > 0 or getPlayerStorageValue(cid, 63215) > 0 then
        doPlayerSendCancel(cid, "Você não pode usar bike em situações especiais.")
    return true
end
 
    if isPlayer(cid) and getCreatureOutfit(cid).lookType == 814 then return false end
        if getPlayerStorageValue(cid, config.storageValue) <= 0 then
            local a = {lookType = config.outfitMale, lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet}
            local b = {lookType = config.outfitFemale, lookHead = getCreatureOutfit(cid).lookHead, lookBody = getCreatureOutfit(cid).lookBody, lookLegs = getCreatureOutfit(cid).lookLegs, lookFeet = getCreatureOutfit(cid).lookFeet}
            setPlayerStorageValue(cid, 3624, ""..getPlayerStamina(cid).."")
            doChangeSpeed(cid, -getCreatureSpeed(cid))
            doChangeSpeed(cid, config.velocidadeDaSuaBike)
            setPlayerStorageValue(cid, config.storageValue, 1)        
            if getPlayerSex(cid) == 0 then
                doSetCreatureOutfit(cid, b, -1)
            else
                doSetCreatureOutfit(cid, a, -1)
            end
        else
            setPlayerStorageValue(cid, config.storageValue, 0)
            doRemoveCondition(cid, CONDITION_OUTFIT)
            doRegainSpeedLevel(cid)
       end
    return true
end

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now