Ir para conteúdo
Entre para seguir isso  
alisonjf

[8.1] Taxi System

Recommended Posts

alisonjf    2
alisonjf

Nome: Cart System

Versão: 8.1

Tipo de Script: Action

Servidor Testado: Evolutions

Créditos (Autor): 100% SaLeM

--------------------------------------------------------------------------

 

Esse script faz com que você ande num carro. Muito legal, não muito útil pra um server mas é muito legal.

Aqui vão os codes:

 

-------------------------------------------------------------------------

 

1. Na pasta data/npc crie um arquivo chamado taxi.xml e coloque isso dentro:

<npc name="Taxi" script="data/npc/scripts/taxi.lua" autowalk="0" floorchange="0" access="6" level="1" maglevel="1">
   <health now="150" max="150"/>
   <look typeex="7266" head="114" body="113" legs="113" feet="113" addons="3" corpse="2212"/>
   <parameters>
       <parameter key="message_greet" value="Brooom brom brom brom bom!!" />
   <parameter key="message_farewell" value="-Engine stopped-" />
   </parameters>
</npc>

 

 

 

2. Na pasta data/npc/scripts crie um arquivo chamado taxi.lua e insira:

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)             npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)     npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                         npcHandler:onThink() end
-- OTServ event handling functions end
local talkstate = -1
local npcpos = {}
local newpos = {}
local npc = nil
local flight = 0
local height = {}
local started = nil
local speed = 250
local rand = nil
function creatureSayCallback(cid, type, msg)
 msg = string.lower(msg)
 target = isPlayer(getPlayerByName(getPlayerName(cid)))
 if target ~= FALSE then
   if(npcHandler.focus ~= cid) then
     return FALSE
   end
   talkstate = getPlayerStorageValue(cid,30068) - 3
   if (msg == 'bye') or (msg == 'cya') or (msg == 'getdown') then
     mayNotMove(cid, 0)
     flight = 1
     speed = 250
     setPlayerStorageValue(cid,30069, 0)
     talkstate = -1
     setPlayerStorageValue(cid,30068, talkstate + 3)
   elseif (talkstate == -2) then
     if isNumber(msg) == TRUE then
       if tonumber(msg) == rand then
         selfSay("YOU CHOSE ME. Say 'ride'.")
         talkstate = 0
         setPlayerStorageValue(cid,30068, talkstate + 3)
       else
         talkstate = -1
         return FALSE
       end
     end
   elseif (talkstate == -1) then
     if (msg == 'ride') then
       math.randomseed(getNpcCid())
       math.random(0,9999999);math.random(0,9999999);math.random(0,9999999);
       rand = math.random(0,9999999)
       selfSay("Please, say this number: " .. tostring(rand))
       talkstate = -2
       setPlayerStorageValue(cid,30068, talkstate + 3)
     else
       selfSay("First get up by saying: 'ride'.")
     end
   elseif (msg == 'ride') then
     if (talkstate == 0) then
       selfSay("Ready!! Set these hotkeys: forward, backward, right, left, stop, getdown, fast, slow, floorup and floordown.")
       npc = getNpcCid()
       npcpos.x,npcpos.y,npcpos.z = selfGetPosition(npc)
       doTeleportThing(cid,npcpos,1)  
       mayNotMove(cid, 1)
       talkstate = 1
       setPlayerStorageValue(cid,30068, talkstate + 3)
     else
       selfSay("Already riding!!")
     end
   elseif (msg == 'forward') then
     if (talkstate == 0) then
       selfSay("First get up by saying: 'ride'.")
     else
         talkstate = 2
     setPlayerStorageValue(cid,30068, talkstate + 3)
     end
   elseif (msg == 'right') then
     if (talkstate == 0) then
       selfSay("First get up by saying: 'ride'.")
     else
         talkstate = 3
     setPlayerStorageValue(cid,30068, talkstate + 3)
     end
   elseif (msg == 'backward') then
     if (talkstate == 0) then
       selfSay("First get up by saying: 'ride'.")
     else
         talkstate = 4
     setPlayerStorageValue(cid,30068, talkstate + 3)
     end
   elseif (msg == 'left') then
     if (talkstate == 0) then
       selfSay("First get up by saying: 'ride'.")
     else
         talkstate = 5
     setPlayerStorageValue(cid,30068, talkstate + 3)
     end
   elseif (msg == 'floorup') then
     if (talkstate == 0) then
       selfSay("First get up by saying: 'ride'.")
     else
       height = getPlayerPosition(cid)
       if height.z > 1 then
         flight = -1
     setPlayerStorageValue(cid,30067, flight + 3)
       else 
         selfSay("Max height")
       end
     end
   elseif (msg == 'floordown') then
     if (talkstate == 0) then
       selfSay("First get up by saying: 'ride'.")
     else
       height = getPlayerPosition(cid)
       if height.z < 7 then
         flight = 1
     setPlayerStorageValue(cid,30067, flight + 3)
       else 
         selfSay("Min height")
       end
     end
   elseif (msg == 'fast') then
     if (talkstate == 0) then
       selfSay("First get up by saying: 'ride'.")
     else
       if speed > 100 then
         velreal = speed
         velreal = velreal - 100
         if velreal > 100 then
           speed = velreal
         else
           speed = 100
         end
         setPlayerStorageValue(cid,30066, speed)
       else 
         selfSay("Max speed")
       end
     end
   elseif (msg == 'slow') then
     if (talkstate == 0) then
       selfSay("First get up by saying: 'ride'.")
     else
       if speed < 1000 then
         velreal = speed
         velreal = velreal + 100
         if velreal < 1000 then
           speed = velreal
         else
           speed = 1000
         end
         setPlayerStorageValue(cid,30066, speed)
       else 
         selfSay("Min speed")
       end
     end
   elseif (msg == 'stop') then
     if (talkstate == 0) then
       selfSay("First get up by saying: 'ride'.")
     else
         setPlayerStorageValue(cid,30069, 0)
         talkstate = 69
     setPlayerStorageValue(cid,30068, talkstate + 3)
     end
   end
   talkstate = getPlayerStorageValue(cid,30068) - 3
   if (talkstate >= 0) then
     started = getPlayerStorageValue(cid,30069)
       param = {}
       npc = getNpcCid()
       param.npc = npc
       param.pla = getPlayerName(cid)
     if (talkstate > 1) and (talkstate ~= 69) and (target ~= FALSE) and (started == 0) then
       setPlayerStorageValue(cid,30069, 1)
       local eventServ = addEvent(walk, speed, param)
     end
   end
 else
   talkstate = 0
 end
 return TRUE
end

function walk(param)
player = getPlayerByName(param.pla)
target = isPlayer(player)
talkstate = getPlayerStorageValue(player,30068) - 3
speed = getPlayerStorageValue(player,30066)
flight = getPlayerStorageValue(player,30067) - 3
 if target ~= FALSE then
   if talkstate == 2 then
     target = isPlayer(player)
     if target ~= FALSE then
       npcpos = getPlayerPosition(player)
       newpos = {x = npcpos.x, y = npcpos.y - 1, z = npcpos.z + (flight)}
       flight = 0
       setPlayerStorageValue(player,30067, flight + 3)
       trajenpc = 7266
       doSetItemOutfit(param.npc, trajenpc,-1)
       doTeleportThing(player,newpos,0)
       newpos = getPlayerPosition(player)
       doTeleportThing(param.npc,newpos,0)
     else
       talkstate = 0

     end
   elseif talkstate == 3 then
     target = isPlayer(player)
     if target ~= FALSE then
       npcpos = getPlayerPosition(player)
       newpos = {x = npcpos.x + 1, y = npcpos.y, z = npcpos.z + (flight)}
       flight = 0
       setPlayerStorageValue(player,30067, flight + 3)
       trajenpc = 7267
       doSetItemOutfit(param.npc, trajenpc,-1)
       doTeleportThing(player,newpos,0)
       newpos = getPlayerPosition(player)
       doTeleportThing(param.npc,newpos,0) 
     else
       talkstate = 0

     end
   elseif talkstate == 4 then
     target = isPlayer(player)
     if target ~= FALSE then
       npcpos = getPlayerPosition(player)
       newpos = {x = npcpos.x, y = npcpos.y + 1, z = npcpos.z + (flight)}
       flight = 0
       setPlayerStorageValue(player,30067, flight + 3)
       trajenpc = 7266
       doSetItemOutfit(param.npc, trajenpc,-1)
       doTeleportThing(player,newpos,0)
       newpos = getPlayerPosition(player)
       doTeleportThing(param.npc,newpos,0)
     else
       talkstate = 0
     end
   elseif talkstate == 5 then
     target = isPlayer(player)
     if target ~= FALSE then
       npcpos = getPlayerPosition(player)
       newpos = {x = npcpos.x - 1, y = npcpos.y, z = npcpos.z + (flight)}
       flight = 0
       setPlayerStorageValue(player,30067, flight + 3)
       trajenpc = 7267
       doSetItemOutfit(param.npc, trajenpc,-1)
       doTeleportThing(player,newpos,0)
       newpos = getPlayerPosition(player)
       doTeleportThing(param.npc,newpos,0)  
     else
       talkstate = 0
     end
   end
   started = getPlayerStorageValue(player,30069)
   if (target ~= FALSE) and (started == 1) then
     local eventServ = addEvent(walk, speed, param)
   end
 else
   talkstate = 0
 end
 return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

-- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!

-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())

 

 

 

3. Na pasta data/creaturescripts/scripts abra o arquivo login.lua e então adicione (É necessário ter a função onLogion):

-------------------------
--Lets the player use the car
setPlayerStorageValue(cid,30069,0)
setPlayerStorageValue(cid,30068,2)
setPlayerStorageValue(cid,30067,3)
setPlayerStorageValue(cid,30066,250)
--------------------------  

 

 

 

 

4. Como funciona?

 

- Diga "hi" ao npc. Ele o mandará dizer "ride". Fale, e depois repita o número que ele te passou (isso serve pra previnir de subir em mais de um táxi). Então, fale "ride" de novo e você será levado ao táxi. Agora, use qualquer uma das hotkeys abaixo e seja feliz:

 

Hotkeys:

 

forward: pra frente

 

backward: pra tras

 

right: direita

 

left: esquerda

 

stop: o carro para

 

getdown: você pode descer do carro e ele para

 

fast: aumenta a velocidade

 

slow: diminui a velocidade

 

floorup: enquanto você está andando você pode subir 1 andar

 

floordown: enquanto você está andando você pode descer 1 andar

 

 

E pronto!

E não se esqueça que esse carro anda em qualquer lugar (água, grama, poison, fire, paredes), então se você quiser fazer ruas coloque items que não dê para andar em cima.

Não se esqueça de verificar se os storage values estão livres (não estão sendo usados por outra quest, npc, etc)!

--------------------------------------------------------------------------

 

Gostaram: Doem OT$ :)

Reclamações/Dúvidas: Postem

Compartilhar este post


Link para o post
Jovial    2
Jovial

Obrigado pela contribuição.

 

Aprovado.

Compartilhar este post


Link para o post
celinhoxp    0
celinhoxp

Belo tutorial, Bem explicado.

O video tah massinha. Gostei; Criatico ;#

 

Aprovado.

Compartilhar este post


Link para o post
BlueAvenger    0
BlueAvenger

O.o, gostei demais. Belo script cara, está de parabens! muito legal, e vc disse não ser bastante ultil eu achei legal e ultil para eventos de corrida Olha kem sabe pode ser uma boa idéia xD, parabens!

 

 

Aprovado~

Compartilhar este post


Link para o post
541320    0
541320

Putz super irado!!!

adorei =) vo até colocar no meu projeto

Aprovado

Compartilhar este post


Link para o post
Adrieli.Fernanda    0
Adrieli.Fernanda

Assim No Meu Ot Não Tem A Pasta creaturescripts O Que Eu Faço...Tenta Me Ajudar Aíííííí Please

Compartilhar este post


Link para o post
[I]aGo    0
[I]aGo

Tenta usar o Server TFS (the forgothen server)

Compartilhar este post


Link para o post
Deragon    25
Deragon

O TFS Pode ter a rev. mais atualizada, porém seus script são muito mais complexos mas também com funções bem superiores a de outros servers...

Aconselho-te a usar o B-FOX 6.8 que se enontra na secção de downloads deste fórum... basta procurar!

Compartilhar este post


Link para o post
ESS    0
ESS

Muito loko meu

Parabéns Provado!

Compartilhar este post


Link para o post
Pontirolli    0
Pontirolli

3. Na pasta data/creaturescripts/scripts abra o arquivo login.lua e então adicione (É necessário ter a função onLogion):

-------------------------
--Lets the player use the car
setPlayerStorageValue(cid,30069,0)
setPlayerStorageValue(cid,30068,2)
setPlayerStorageValue(cid,30067,3)
setPlayerStorageValue(cid,30066,250)
--------------------------  

 

 

Bom eu não achei essa pasta no meu ot meu ajuda ai plxx

Compartilhar este post


Link para o post
PO QUAL A SENHA    0
PO QUAL A SENHA

tipo eu fiz tudo corretamente mais quando eu falo o numero q o npc pede ele da erro...data/npc/scripts/taxi.lua:36:attempt to call global 'IsNumber'<a nil value>

 

como arrumo isso se puderem ajuda vlws

Compartilhar este post


Link para o post
plomentes    0
plomentes

Muito legal, mais poderia explicar melhor, e também facilitar nos códigos, usando outras funções.

E como ja falaram, poderia também ser usada pelas setas do teclado, que facilita muito!

Compartilhar este post


Link para o post
caips    0
caips

uAHUHahA

esse carro

é feito os sprites? ou usa alguma coisa que ja exista?

podia postar umas SS's

Compartilhar este post


Link para o post
gl1707    0
gl1707

Aprovado.

Muito Legal Para Usar Em Eventos ;)

Compartilhar este post


Link para o post
GOD Winter    0
GOD Winter

Muito loko vei!

Mas n achei akele data/creaturescripts/scripts

como eu achu? O.o

Compartilhar este post


Link para o post
joja    0
joja

 
[19/09/2008  20:30:00] Lua Script Error: [CreatureScript Interface] 
[19/09/2008  20:30:00] data/creaturescripts/scripts/login.lua
[19/09/2008  20:30:00] luaSetPlayerStorageValue(). Player not found
[19/09/2008  20:30:00] Lua Script Error: [CreatureScript Interface] 
[19/09/2008  20:30:00] data/creaturescripts/scripts/login.lua
[19/09/2008  20:30:00] luaSetPlayerStorageValue(). Player not found
[19/09/2008  20:30:00] Lua Script Error: [CreatureScript Interface] 
[19/09/2008  20:30:01] data/creaturescripts/scripts/login.lua
[19/09/2008  20:30:01] luaSetPlayerStorageValue(). Player not found
[19/09/2008  20:30:01] Lua Script Error: [CreatureScript Interface] 
[19/09/2008  20:30:01] data/creaturescripts/scripts/login.lua

 

 

:(

 

Se possível postar uma solução.

Compartilhar este post


Link para o post
leandro_70    0
leandro_70

Muito bom ele parabéns,também testei no Evolutions pra nao dar problemas ;x

Compartilhar este post


Link para o post
Sorc LokoO    0
Sorc LokoO

O Meu Deus Cada

Coisa q esse Povo Inventa

Muito Massa =D

Curti o Taxi =D

Compartilhar este post


Link para o post
Bangue    0
Bangue

parabens

 

muito bom mesmo :D

Compartilhar este post


Link para o post
Visitante
Este tópico está impedido de receber novos posts.
Entre para seguir isso  
  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×