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

Solved Racing Quest Problem !

Daniel Kopeć

Member
Joined
Dec 8, 2018
Messages
125
Solutions
4
Reaction score
12
Location
Poland
I found this script on the forum. Race start is working properly. But I don't know how to set the finish line ( End of the race)
Because after reaching the position rewardRoomPos = {x=113, y=126, z=7} -- Position of the reward room the character still performs the event and does not receive a reward.

What's missing from the script or the map? How to correct it?

Lua:
local config = {
        timeToStart = 5, -- Time for the player to start 'driving' after using the switch
        startPos = {x=84, y=132, z=7}, -- Start race position
        startMsg = "Avoid the walls!", -- Message when the race starts
        startLookDirection = SOUTH, -- Look Direction when the race starts
        changeLookType = "yes", -- Change looktype of the player?
        itemIDLookType = 9937, -- Item ID of how the player should look like
        speed = 200, -- Speed
        failItems = {9119, 9118, 9120, 9124}, -- 'Driving' into these items makes the player lose
        failMsg = "You crashed and broke your neck!", -- Message if he loses
        winningItems = {5785, 7890}, -- The items the player should 'drive' into to win
        winningMsg = "You completed the race!", -- Message if the player wins
        rewardRoomPos = {x=113, y=126, z=7} -- Position of the reward room
        }

local function race(cid)
local dir, pos = getCreatureLookDirection(cid), getThingPos(cid)
local newPos = {x=(dir == 1 and pos.x+1 or dir == 3 and pos.x-1 or pos.x), y=(dir == 0 and pos.y-1 or dir == 2 and pos.y+1 or pos.y), z=pos.z, stackpos=1}

    if not isInArray(config.winningItems, getThingFromPos(newPos).itemid) then
        if not isInArray(config.failItems, getThingFromPos(newPos).itemid) then
            doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
            doTeleportThing(cid, newPos)
            addEvent(race, config.speed, cid)
        else
            doSendMagicEffect(getThingPos(cid), 6)
            doRemoveConditions(cid, false)
            doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
            doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
            doPlayerSendTextMessage(cid, 19, config.failMsg)
            doCreatureSetNoMove(cid, 0)
        end
    end
    
    if isInArray(config.winningItems, getThingFromPos(newPos).itemid) then
        doTeleportThing(cid, config.rewardRoomPos)
        doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
        doPlayerSendTextMessage(cid, 22, config.winningMsg)
        doRemoveConditions(cid, false)
        doCreatureSetNoMove(cid, 0)
    end
return true
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
local dir = getCreatureLookDirection(cid)
    doTeleportThing(cid, config.startPos)
    doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
    doPlayerSendTextMessage(cid, 22, config.startMsg)
    doCreatureSetNoMove(cid, 1)
    doCreatureSetLookDirection(cid, config.startLookDirection)
    doSetItemOutfit(cid, config.changeLookType == "yes" and config.itemIDLookType or 0, -1)
    addEvent(race, config.timeToStart*1000, cid)
return true
end

XML:
<action actionid="5000" event="script" value="race.lua"/>

My introductory map:
racequest.png
 
Solution
Tested this now and found ;
Lua:
failItems    = {9119, 9118, 9120, 9124}, -- 'Driving' into these items makes the player lose
winningItems = {5785, 7890}, -- The items the player should 'drive' into to win
You need to place winningItems and failItems on the pathway.
If players never "walk" on either of these items nothing will happen.

If player walks on 5785 player is sent to reward room.
if player walks into 9119 player is sent to exit pos or temple.

Example 1, walking on Win item:
ezgif.com-gif-maker.gif

Example 2, walking on obstacle:
ezgif.com-gif-maker(1).gif

Snavy

Bakasta
Senator
Joined
Apr 1, 2012
Messages
1,244
Solutions
71
Reaction score
555
Location
Hell
Tested this now and found ;
Lua:
failItems    = {9119, 9118, 9120, 9124}, -- 'Driving' into these items makes the player lose
winningItems = {5785, 7890}, -- The items the player should 'drive' into to win
You need to place winningItems and failItems on the pathway.
If players never "walk" on either of these items nothing will happen.

If player walks on 5785 player is sent to reward room.
if player walks into 9119 player is sent to exit pos or temple.

Example 1, walking on Win item:
ezgif.com-gif-maker.gif

Example 2, walking on obstacle:
ezgif.com-gif-maker(1).gif
 
Solution
Top