• 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.

TalkAction Riding car one file only

Doggynub

LUA / C++
Joined
Sep 28, 2008
Messages
2,541
Reaction score
186
As it says, it is a car you ride and move it.

How to navigate :

Kepp pressing CTRL + up,down,left,right arrows


Commands :

!car move : summon car and start moving with default speed
!car speed : speed up car
!car slow : slow down car
!car stop : stop car


[0.4] :
Lua:
--<< Configurable >>--
local storages = { speed = 314622, status = 352993 }			-- Empty storages

local cfg = 	{	min_speed = 400,  						-- better not increase than that [ the least speed for a car ]
					max_speed = 50,							-- better not decrease than this [ the maximum speed for a car ]
					Increase_per_command = 60, 				-- The speed increase or decrease value per each command (!car speed // !car slow)
					Car_Explode = true 						-- Keep it true , so your map isnt filled with cars
				}
-->> END <<--

--<< Functions >>--

function isWalkable(pos, creature, proj, pz)-- by Nord
	if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
	if getTopCreature(pos).uid > 0 and creature then return false end
	if getTileInfo(pos).protection and pz then return false, true end
	local n = not proj and 3 or 2
	for i = 0, 255 do
		pos.stackpos = i
		local tile = getTileThingByPos(pos)
		if tile.itemid ~= 0 and not isCreature(tile.uid) then
			if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
				return false
			end
		end
	end
	return true
end

function getCarSpeed(cid) return getPlayerStorageValue(cid,storages.speed) end
function setCarSpeed(cid,value) return setPlayerStorageValue(cid,storages.speed, getPlayerStorageValue(cid,storages.speed) + value) end
function setCarStatus(cid,value) return setPlayerStorageValue(cid,storages.status,value) end
function carMove(cid) return getPlayerStorageValue(cid,storages.status) > 0 and true or false end

function move(cid,time)
	local dir = getCreatureLookDir(cid)
	local id = isInArray({1,3},getCreatureLookDir(cid)) and 7267 or 7266
	local place = getPositionByDirection(getThingPos(cid),dir,1)
	if isWalkable(place,true,true,true) then
		doRemoveItem( getTileItemById(getThingPos(cid),7267).uid > 0 and getTileItemById(getThingPos(cid),7267).uid or getTileItemById(getThingPos(cid),7266).uid )
		doTeleportThing(cid,place,false)
		addEvent(doSendMagicEffect,time+10,place,34)
		doCreateItem(id,1,place)
		if carMove(cid) then
			addEvent(move,time,cid,getCarSpeed(cid))
		else
			doRemoveCondition(cid,CONDITION_INFIGHT)
			doRemoveItem( getTileItemById(getThingPos(cid),7267).uid > 0 and getTileItemById(getThingPos(cid),7267).uid or getTileItemById(getThingPos(cid),7266).uid )
		end
	else
		doCreatureSetNoMove(cid, 0)
		doPlayerSendTextMessage(cid,27,"You have hit somthng.")
		setCarStatus(cid,0)
		doRemoveCondition(cid,CONDITION_INFIGHT)
		if cfg.Car_Explode then
			doRemoveItem( getTileItemById(getThingPos(cid),7267).uid > 0 and getTileItemById(getThingPos(cid),7267).uid or getTileItemById(getThingPos(cid),7266).uid )
			doSendAnimatedText(getThingPos(cid),"Crashed",TEXTCOLOR_RED)
			doSendMagicEffect(getThingPos(cid),31)
		end
	end
end

--<< Functions Ends <<--

local fight = createConditionObject(CONDITION_INFIGHT,-1)
function onSay(cid, words, param, channel)
	if param == "speed" then
		if carMove(cid) then
			if getCarSpeed(cid) > cfg.max_speed then
				setCarSpeed(cid,-(cfg.Increase_per_command))
				addEvent(doSendAnimatedText,10,getThingPos(cid),"Speeding",TEXTCOLOR_GREEN)
			else
				setCarSpeed(cid,cfg.max_speed)
				doPlayerSendCancel(cid,"The car is in its maximum speed.")
			end
		else
			doPlayerSendCancel(cid,"You should start moving first.")
		end
	elseif param == "slow" then
		if carMove(cid) then
			if getCarSpeed(cid) < cfg.min_speed then
				setCarSpeed(cid,cfg.Increase_per_command)
				addEvent(doSendAnimatedText,10,getThingPos(cid),"Slowing",TEXTCOLOR_GREEN)
			else
				setCarSpeed(cid,cfg.min_speed)
				doPlayerSendCancel(cid,"The car is in its minumium speed.")
			end
		else
			doPlayerSendCancel(cid,"You should start moving first.")
		end
	elseif param == "stop" then
		if carMove(cid) then
			setCarStatus(cid,0)
			doSendAnimatedText(getThingPos(cid),"Stopped!",TEXTCOLOR_RED)
			
		else
			doPlayerSendCancel(cid,"Car is already stopped.")
		end
	elseif param == "move" then
			if not carMove(cid) then
				if getTileItemById(getThingPos(cid),7267).uid < 1 and  getTileItemById(getThingPos(cid),7266).uid < 1 then 
					local item = isInArray({1,3},getCreatureLookDir(cid)) and 7267 or 7266
					doCreateItem(item,1,getThingPos(cid))
				end
				setPlayerStorageValue(cid,storages.speed,cfg.min_speed)
				setCarStatus(cid,1)
				doCreatureSetNoMove(cid, 1)
				move(cid,getCarSpeed(cid))
				doAddCondition(cid,fight)
			else
				doPlayerSendCancel(cid,"Car is already moving.")
			end
	end
		
	return true
end
XML:
<talkaction words="!car"  event="script" value="vip/car.lua"/>


[0.3.6] :
Lua:
--<< Configurable >>--
local storages = { speed = 314622, status = 352993 } -- Empty storages
 
local cfg = {	min_speed = 400,  						-- better not increase than that [ the least speed for a car ]
					max_speed = 50,							-- better not decrease than this [ the maximum speed for a car ]
					Increase_per_command = 60, 				-- The speed increase or decrease value per each command (!car speed // !car slow)
					Car_Explode = true -- Keep it true , so your map isnt filled with cars
				}
-->> END <<--
 
--<< Functions >>--
 
function isWalkable(pos, creature, proj, pz)-- by Nord
	if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
	if getTopCreature(pos).uid > 0 and creature then return false end
	if getTileInfo(pos).protection and pz then return false, true end
	local n = not proj and 3 or 2
	for i = 0, 255 do
		pos.stackpos = i
		local tile = getTileThingByPos(pos)
		if tile.itemid ~= 0 and not isCreature(tile.uid) then
			if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
				return false
			end
		end
	end
	return true
end
 
function getCarSpeed(cid) return getPlayerStorageValue(cid,storages.speed) end
function setCarSpeed(cid,value) return setPlayerStorageValue(cid,storages.speed, getPlayerStorageValue(cid,storages.speed) + value) end
function setCarStatus(cid,value) return setPlayerStorageValue(cid,storages.status,value) end
function carMove(cid) return getPlayerStorageValue(cid,storages.status) > 0 and true or false end
 
function move(cid,time)
	local dir = getCreatureLookDir(cid)
	local id = isInArray({1,3},getCreatureLookDir(cid)) and 7267 or 7266
	local place = getPosByDir(getThingPos(cid),dir,1)
	if isWalkable(place,true,true,true) then
		doRemoveItem( getTileItemById(getThingPos(cid),7267).uid > 0 and getTileItemById(getThingPos(cid),7267).uid or getTileItemById(getThingPos(cid),7266).uid )
		doTeleportThing(cid,place,false)
		addEvent(doSendMagicEffect,time+10,place,34)
		doCreateItem(id,1,place)
		if carMove(cid) then
			addEvent(move,time,cid,getCarSpeed(cid))
		else
			doRemoveCondition(cid,CONDITION_INFIGHT)
			doRemoveItem( getTileItemById(getThingPos(cid),7267).uid > 0 and getTileItemById(getThingPos(cid),7267).uid or getTileItemById(getThingPos(cid),7266).uid )
		end
	else
		doCreatureSetNoMove(cid, 0)
		doPlayerSendTextMessage(cid,27,"You have hit somthng.")
		setCarStatus(cid,0)
		doRemoveCondition(cid,CONDITION_INFIGHT)
		if cfg.Car_Explode then
			doRemoveItem( getTileItemById(getThingPos(cid),7267).uid > 0 and getTileItemById(getThingPos(cid),7267).uid or getTileItemById(getThingPos(cid),7266).uid )
			doSendAnimatedText(getThingPos(cid),"Crashed",TEXTCOLOR_RED)
			doSendMagicEffect(getThingPos(cid),31)
		end
	end
end
 
--<< Functions Ends <<--
 
local fight = createConditionObject(CONDITION_INFIGHT,-1)
function onSay(cid, words, param, channel)
	if param == "speed" then
		if carMove(cid) then
			if getCarSpeed(cid) > cfg.max_speed then
				setCarSpeed(cid,-(cfg.Increase_per_command))
				addEvent(doSendAnimatedText,10,getThingPos(cid),"Speeding",TEXTCOLOR_GREEN)
			else
				setCarSpeed(cid,cfg.max_speed)
				doPlayerSendCancel(cid,"The car is in its maximum speed.")
			end
		else
			doPlayerSendCancel(cid,"You should start moving first.")
		end
	elseif param == "slow" then
		if carMove(cid) then
			if getCarSpeed(cid) < cfg.min_speed then
				setCarSpeed(cid,cfg.Increase_per_command)
				addEvent(doSendAnimatedText,10,getThingPos(cid),"Slowing",TEXTCOLOR_GREEN)
			else
				setCarSpeed(cid,cfg.min_speed)
				doPlayerSendCancel(cid,"The car is in its minumium speed.")
			end
		else
			doPlayerSendCancel(cid,"You should start moving first.")
		end
	elseif param == "stop" then
		if carMove(cid) then
			setCarStatus(cid,0)
			doSendAnimatedText(getThingPos(cid),"Stopped!",TEXTCOLOR_RED)
 
		else
			doPlayerSendCancel(cid,"Car is already stopped.")
		end
	elseif param == "move" then
			if not carMove(cid) then
				if getTileItemById(getThingPos(cid),7267).uid < 1 and  getTileItemById(getThingPos(cid),7266).uid < 1 then 
					local item = isInArray({1,3},getCreatureLookDir(cid)) and 7267 or 7266
					doCreateItem(item,1,getThingPos(cid))
				end
				setPlayerStorageValue(cid,storages.speed,cfg.min_speed)
				setCarStatus(cid,1)
				doCreatureSetNoMove(cid, 1)
				move(cid,getCarSpeed(cid))
				doAddCondition(cid,fight)
			else
				doPlayerSendCancel(cid,"Car is already moving.")
			end
	end
 
	return true
end
 
Last edited:
So what is the car sprite? ..

Code:
somthng."

It's something :p

Good script though ^_^
 
humm , you jsut make !car move and the car will spawn[7267,7266]
 
Do you need a certain sprite for it though?
 
Very nice, but can u help me with this error?


[27/12/2010 19:24:16] [Error - TalkAction Interface]
[27/12/2010 19:24:16] data/talkactions/scripts/vip/car.lua:eek:nSay
[27/12/2010 19:24:16] Description:
[27/12/2010 19:24:16] data/talkactions/scripts/vip/car.lua:38: attempt to call global 'getPositionByDirection' (a nil value)
[27/12/2010 19:24:16] stack traceback:
[27/12/2010 19:24:16] data/talkactions/scripts/vip/car.lua:38: in function 'move'
[27/12/2010 19:24:16] data/talkactions/scripts/vip/car.lua:108: in function <data/talkactions/scripts/vip/car.lua:66>
 
humm okay second i will post a 0.3.6 one.

Soon i will make a crashing cars event :D << if i have free time >>
 
Very good, but here's a bug where when I hit the car and pk remove.

I removed the two lines with doRemoveCondition (cid, CONDITION_INFIGHT) but now after using the car the "battle" has no end.
If you can can put the scrip in a way where you do not miss when hitting battle but end up in normal time?

Solution: Remove Line: doAddCondition(cid,fight) ^^

Thx
 
Last edited:
Why did i added add condition fight??? Cause if a player logged while riding you will get errors in console, and the car wont be removed.
 
One solution would be a way that can not attack and be attacked in the car.
Outro bug is riding in the car and give exani hur "up somewhere, when it goes up, it's a car underneath.
Another bug is that when the car trunk and the hole in the ladder, gets a lot of cars in place of the ladder, the ladder disappears.

i'm br,sorry for poor english :x
Translated by Google Tradutor x;
 
Last edited:
dude it is just a fun script where you can try it in your server maybe allow it in certain place with no levers w/e
 
Everytime I say !car move, it just says crashed. I am standing in a open area too.. can you help me?
 
Back
Top