• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

FREE RIDE CAR -bY SaLeM-

SaLeM

New Member
Joined
Oct 14, 2007
Messages
97
Reaction score
0
Location
Spain
Hiho!

Well, since I'm moving to WoW and not playing Tibia anymore, I've decided to release my fantastic TAXI NPC, aka FREE RIDE CAR.

It consists of an NPC who reacts to your talk actions (such as "Forward", "Backward", "Right" and "Left"). It will carry you on its back, and you'll be able to ride it wherever you want.

Here you have my YouTube video demonstration:

http://es.youtube.com/watch?v=nW3aGWmvd_Y
http://es.youtube.com/watch?v=ujYW5_lSr7c

And here is the script:

-Create a Taxi.xml file in your DATA/NPC folder.

-Paste this inside:

PHP:
<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>

-After that, create a Taxi.lua file in your DATA/NPC/SCRIPTS folder.

-Paste this inside:

PHP:
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())

-Now add this to your login.lua file in your DATA/CREATURESCRIPTS/SCRIPTS folder. Must be inside the onLogin function:

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

-How it works? Just say "hi" to the NPC. He will ask you to say "ride". Say it, and now repeat the number he gives to you (this is to prevent getting up on more than one taxi xD xD). Then, say "ride" again, and you'll be pushed on the taxi. Now use any of the hotkeys below, and weee!!

HOTKEYS:

forward : you go ahead

backward : you go back

right : right way

left : left way

stop : the car stops

getdown : you can move out of the car, and this one stops

fast : increase speed

slow : decrease speed

floorup : while you are moving, you can go up 1 floor

floordown : while you are moving, you can go down 1 floor


And you're done! :)

Also take note that this car goes through EVERY WHERE (this includes any wall, water or ground tile), so if you plan to limit the car's roads, you'll have to make some item not to be walkable (this is easy thanks to the Walkback script on MOVEMENTS folder. Just copy and edit it so you are pushed back when you ride over an item.) Empty black tiles also work as a limit for the car, so you can make circuits just by surrounding both sides of the road with empty tiles (MapEditor).

*Please, take note that you need to keep free storage values 30069, 30068, 30067, 30066, since this script use them.

ALL CREDITS TO ME!! ^^
 
Last edited:
Code:
-------------------------
--Lets the player use the car
setPlayerStorageValue(cid,30069,0)
setPlayerStorageValue(cid,30068,2)
setPlayerStorageValue(cid,30067,3)
setPlayerStorageValue(cid,30066,250)
--------------------------

how do i add this in


Code:
function onLogin(cid)
	registerCreatureEvent(cid, "PlayerDeath")
	dofile("./config.lua")
	if sqlType == "mysql" then
		env = assert(luasql.mysql())
		con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
	else -- sqlite
		env = assert(luasql.sqlite3())
		con = assert(env:connect(sqliteDatabase))
	end
	if serverStarted == FALSE then
		assert(con:execute("UPDATE `players` SET `online` = 0;"))
		serverStarted = TRUE
	end 
	assert(con:execute("UPDATE `players` SET `online` = `online`+1 WHERE `id` = "..getPlayerGUID(cid)..";"))
	con:close()
	env:close()
	return TRUE
end
 
This way:

PHP:
function onLogin(cid)
	registerCreatureEvent(cid, "PlayerDeath")
	dofile("./config.lua")
	if sqlType == "mysql" then
		env = assert(luasql.mysql())
		con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
	else -- sqlite
		env = assert(luasql.sqlite3())
		con = assert(env:connect(sqliteDatabase))
	end
	if serverStarted == FALSE then
		assert(con:execute("UPDATE `players` SET `online` = 0;"))
		serverStarted = TRUE
	end 
	assert(con:execute("UPDATE `players` SET `online` = `online`+1 WHERE `id` = "..getPlayerGUID(cid)..";"))
	con:close()
	env:close()
-------------------------
--Lets the player use the car
setPlayerStorageValue(cid,30069,0)
setPlayerStorageValue(cid,30068,2)
setPlayerStorageValue(cid,30067,3)
setPlayerStorageValue(cid,30066,250)
--------------------------
	return TRUE
end


^^
 
The video is AWESOME!!! i wanna be like u man...you're a genius!...but i dont have the folder creaturescrpt...i have an ot Evolutions 8.1 XML (not sql), so, my question is...where i must to put this?

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

AND I DONT HAVE THE ARCHIVE login.lua (AND IDK WHAT IS THAT Xd) PLX NOW I SAW YOUR VIDEO AND I WANT IT NOW!!!!!!!! xD xD xD you're a nice scrpiter man!!!.

PLX MSG ME FASTT!!!
 
Last edited:
I'm afraid this script is only for The Forgotten Server, since many of the functions I used in it are different from other servers.

:)
 
SaLeM, I'm very proud to see that u putted effort and loads of time in it, You are going to be one good Lua scripter in the future mate!

Rep++
 
Very impressive but first a few questions.

1. Does it allow people to go through walls?
2. If a player goes underground into an 'earth tile' can they still move around?
3. Do you still intend to make the GPS and password features?
4. Does the cart reset back to its starting location when the player is finished with it?
 
Last edited:
This script is awesome :thumbup:!

gogog and make more nice scripts like this, rep+++

yours Evil Hero,
 
1. Does it allow people to go through walls?
SaLeM said:
this car goes through EVERY WHERE (this includes any wall, water or ground tile)
As I said, use an special item to limit the car, it's quite easy.

2. If a player goes underground into an 'earth tile' can they still move around?

I don't understand, do you mean going downstairs from the main floor? If so, yes, it still moves.

3. Do you still intend to make the GPS and password features?

Indeed, I made the password system, but now it seems to be impossible to include it in this script, since I made this script for NPCs, not for items, so they can't be owned. Regarding GPS, forget it xD. Given that you can't own the car, which location would it show to you?

4. Does the cart reset back to its starting location when the player is finished with it?

I thought about it, but What if the user wants to use it back to the city? The car would disappear, and he would be trapped.

Evil Hero said:
This script is awesome !

^^
 
Last edited:
salem, i love this script but my data folder doesnt have a login.lua lol
so where do i put the last part at?
 
salem, i love this script but my data folder doesnt have a login.lua lol
so where do i put the last part at?

-First:

Are you sure you don't have a login.lua file? Check it at "/data/creaturescripts/scripts/"

-Second:

If you don't find it in there, you may create one. Make a new login.lua file in "/data/creaturescripts/scripts/". Then paste this inside:

PHP:
function onLogin(cid)
-------------------------
--Lets the player use the car
setPlayerStorageValue(cid,30069,0)
setPlayerStorageValue(cid,30068,2)
setPlayerStorageValue(cid,30067,3)
setPlayerStorageValue(cid,30066,250)
--------------------------
  return TRUE
end

And you are done :)
 
I say ride and the npc say:
First get up by saying: 'ride'.
I put the functions in login.lua in creaturescript
but dnot functionally
my server in a mixed evolutions, yurots, devland and theforgotten...
all functionally on it...
 
Back
Top