Ir para conteúdo

[Exercícios - Aula 7 (Parte 2)] Respostas


Roksas

Posts Recomendados

14y2xlc.jpg

Saudações galerinha, num nível já alto da Escolinha, aprendemos diversas coisas da linguagem, e neste tópico estarei postando as respostas dos alunos e correções.

divisor.png

Allan Harlen:

 

-- [[ 3 Tarefa 7 Aular Parte 2 ]] --

function onUse(cid, item, frompos, item2, topos)

-- <action actionid="id" event="script" value="nomedoscript.lua"/> --

if getPlayerStorageValue(cid) == 5000 then
doPlayerSendCancel(cid, "Já clicou aki expert :)")
return true
end

local outfit = getPlayerSex(cid) == 0 and {lookType = 1393} or {lookType = 1394}

doCreatureChangeOutfit(cid, outfit)
doPlayerSendTextMessage(cid, 15, "Ops!")
doSummonCreature("Demon", getThingPos(cid))
doSendMagicEffect(getThingPos(cid), 15)
return true
end


-- [[ 1 Tarefa 7 Aula Part 2]] --
-- <action itemid="id" event="script" value="nomedoscript.lua"/> --

function onUse(cid, item, frompos, item2, topos)
if not isPremium(cid) then
doPlayerSendCancel(cid, "Vocé não é vip para completar essa quest")
return true
end

if getPlayerFreeCap(cid) > 5000 then
doPlayerSendCancel(cid, "Manow Sua capacidade ta no max")
elseif getPlayerLevel(cid) > 50 then
doPlayerSendCancel(cid, "Vocé não tem level suficiente para completar essa quest")
return true
end

doPlayerAddItem(cid, 2160, 50)
doPlayerSendTextMessage(cid, "vocé ganhou 50 crystal coins")
doSendMagicEffect(getTileThingByPos(cid), 15)
return true
end

-- [[ 2 Tarefa 7 Aular Part 2 ]] --

function onSay(cid, words, param, channel)

-- <talkaction words="!home" event="script" value="escolinha.lua"/> --

local config = {
premiumdays = 10,
battle = true    -- se precisa estar sem battle (true). Se colocar false, poderá usar teleport no meio de batalhas
}

if getPlayerPremiumDays(cid) > config.premiumdays then
return true
end

if config.battle and getCreatureCondition(cid, CONDITION_INFIGHT) then
doPlayerSendCancel(cid, "ta duelo fdp")
return true
end

doPlayerRemovePremiumDays(cid, config.premiumdays)
doTeleportThing(cid, getPlayerTown(cid))
doSendMagicEffect(getThingPos(cid), 15)
doPlayerSendTextMessage(cid, 15, "Námoral mermo vocé perdeu 10 de vip atoa ")
return true
end
Nota: 8,00
OBS: Scripts muitos bons, mas se esqueceu da identação e usou algumas funções de forma incorreta de acordo com seus parâmetros :/

 

Matheus Ribeiro:

 


--[[ TAG :  <action actionid="44044" event="script" value="nomedoscript.lua"/>
lembrando que tem que colocar o actionid no item atravez do mapa editor ]]
 
function onUse(cid)
 
         if getPlayerFreeCap(cid) >= 26.50 then
            if getPlayerLevel(cid) >= 10 then
               if getPlayerPremiumDays(cid) >= 1 then
               
                  doPlayerAddItem(cid, 8042, 1)
                  else
                      doPlayerSendCancel(cid, "you are not a premium player")
               end
             else
                 doPlayerSendCancel(cid, "you do not have enough level")    
             end
         else
             doPlayerSendCancel(cid, "you can not take much weight")               
         end
end
 
-------------------------------------------------------------
 
--TAG <talkaction words="!home" event="script" value="nomedoscript.lua"/>
 
function onSay(cid)
 
         if getCreatureCondition(cid, CONDITION_INFIGHT) == false then
            doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
            doPlayerRemovePremiumDays(cid, 1)
            else
                doPlayerSendCancel(cid, "you're in battle")
         end
 
end
 
--------------------------------------------------------------
--[[ TAG :  <action actionid="55055" event="script" value="nomedoscript.lua"/>
lembrando que tem que colocar o actionid no item atravez do mapa editor ]]
 
 
function onUse(cid)
 
doCreatureChangeOutfit(cid, 128)
doSummonCreature('demon', getCreaturePosition(cid))
 
end

Nota: 8,50
OBS: Muito bom cara, você está quase identando corretamente, procure utilizar o return, entender ele.

Pablo Rodrigues:

 

Setima Aula [Parte 2]

1º Questão

    <action itemid="10351" event="script" value="lcmg.lua"/>

function onUse(cid)

 local level = 20
 local cap = 100
 local money = 10000

 if not isPremium(cid) then
  doPlayerSendCancel(cid, "Sómente vip pode pegar o prêmio.")
  return true
 end

 if getPlayerLevel(cid) >= level then
  doPlayerSendCancel(cid, "Você so pode pegar o prêmio ate level "..level..".")
  return true
 end
 
 if getPlayerFreeCap(cid) <= cap then
  doPlayerSendCancel(cid, "Você precissa ter "..cap.." ou mais de capacidade.")
 return true
 end
 
 doPlayerAddMoney(cid, money)
 doPlayerSendTextMessage(cid, 20, "Tome seu prêmio.")
 return true
end



2º Questão

    <talkaction words="!home" event="script" value="totemple.lua"/>

function onSay(cid, words, param, channel)
local day = 2
pos = {x=100, y=40, z=7}
 
 if not isPremium(cid) then
  return doPlayerSendCancel(cid, "Sómente vip pode Teleportar.")
 end
 if getPlayerPremiumDays(cid) <= day then
   return doPlayerSendCancel(cid, "Você percissa ter no minimo "..day.." de premium.")
 end
 
 if getCreatureCondition(cid, CONDITION_INFIGHT) then
  return doPlayerSendCancel(cid, "Você esta em battle.")
 end
 doTeleportThing(cid,pos)
 doPlayerRemovePremiumDays(cid, 1)
 doPlayerSendTextMessage(cid, 20, "Você perdeu um dia de vip para teleportar.")
 return true
 end



3º Questão

        <action uniqueid="30071" event="script" value="ops.lua"/>      

function onUse(cid, item, frompos, item2, topos)
local pos = getThingPos(cid)

doSetCreatureOutfit(cid, {lookType = 129}, -1)
doSummonCreature("Demon", pos)
doPlayerSendTextMessage(cid, 20, "OPS!")
return true
endn
Nota: 8,50
OBS: Usou funções corretamente, principalmente o return, só se perdeu um pouco na identação, nice!

 

É isso aí galerinha, em breve a próxima aula.

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...