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

Killua Cart System

Joined
Apr 15, 2014
Messages
75
Reaction score
18
Hello folks I'm a LUA scripter and I'm very active in a brazilian forum... Now I decided to be the same in here.

Well, here is a code I did just today.

What does it do?
It simply makes you character walk trhough a path you choose... While doing so, you cannot battle, walk or logout and you're transformed into a cart.

Installing
Just create Killua Cart System.xml in data/mods and put this code:

[spoil]

Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Walking Cart System" version="1.0" author="Killua (Vitor Bertolucci)" enabled="yes">
<config name="cartSystem"><![CDATA[

interval = 600

--=============================================================
--== Walking Cart System, created by Killua (Vitor Bertolucci)=                           
--== If you are planning to post this code, please contact me =
--== first and/or keep my name in it                      =====
--== Based on TFS 0.4                                    =====                                                 
--== Created on 14/04/2014 (April 14th 2014)              =====
--=============================================================
---------------------------------------------------------------                                     
--==================[[INSTRUCTIONS (read it)]]=================                         
--== Action ID 5191 means NORTH                          =====                               
--== Action ID 5192 means EAST                            =====                                 
--== Action ID 5193 means SOUTH                          =====                               
--== Action ID 5194 means WEST                            =====                               
--== Action ID 5195 means STOP                            =====                               
--== interval means the interval between car steps(1000=1s)=====
--== CHANGE interval VARIABLE IN THE TOP  OF THE CODE    =====
--=============================================================


function moveCart(cid, dir)
    local sto_ = getPlayerStorageValue(cid, 1212123)
    if isInArray({0, 1, 2, 3}, dir) and sto_ == dir then
        doMoveCreature(cid, dir)
        addEvent(moveCart, interval, cid, dir)
    end
end
]]></config>

<event type="login" name="cartsLogin" event="script"><![CDATA[
domodlib('cartSystem')
function onLogin(cid)
    registerCreatureEvent(cid, "cartsStats")
    registerCreatureEvent(cid, "cartsCombat")
    if getPlayerStorageValue(cid,1212123) ~= -1 then
        setPlayerStorageValue(cid,1212123, -1)
        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
    end
    return true
end
]]></event>

<event type="combat" name="cartsCombat" event="script"><![CDATA[
domodlib('cartSystem')
function onCombat(cid, target)
    if getPlayerStorageValue(cid, 1212123) ~= -1 then
        return false
    end
    return true
end
]]></event>

<event type="statschange" name="cartsStats" event="script"><![CDATA[
domodlib('cartSystem')
function onStatsChange(cid, attacker, type, combat, value)
    if getPlayerStorageValue(cid, 1212123) ~= -1 and type == 1 then
        return false
    end
    return true
end
]]></event>

<event type="logout" name="cartsLogout" event="script"><![CDATA[
domodlib('cartSystem')
function onLogout(cid)
    if getPlayerStorageValue(cid, 1212123) ~= -1 then
        doPlayerSendCancel(cid, "You may not logout during your cart walking experience")
        return false
    end
    return true
end
]]></event>

<movement type="StepIn" actionid="5191;5192;5193;5194;5195" event="script"><![CDATA[
domodlib('cartSystem')

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    if item.actionid == 5191 then
        doSetItemOutfit(cid, 7132)
        mayNotMove(cid, true)   
        doPlayerSendTextMessage(cid, 20, "Moving North...")
        doPlayerSetStorageValue(cid, 1212123, 0)
        addEvent(moveCart, interval, cid, 0)
    elseif item.actionid == 5192 then
        doSetItemOutfit(cid, 7131)
        mayNotMove(cid, true)   
        doPlayerSendTextMessage(cid, 20, "Moving East...")
        doPlayerSetStorageValue(cid, 1212123, 1)
        addEvent(moveCart, interval, cid, 1)
    elseif item.actionid == 5193 then
        doSetItemOutfit(cid, 7132)
        mayNotMove(cid, true)   
        doPlayerSendTextMessage(cid, 20, "Moving South...")
        doPlayerSetStorageValue(cid, 1212123, 2)
        addEvent(moveCart, interval, cid, 2)
    elseif item.actionid == 5194 then
        doSetItemOutfit(cid, 7131)
        mayNotMove(cid, true)   
        doPlayerSendTextMessage(cid, 20, "Moving West...")
        doPlayerSetStorageValue(cid, 1212123, 3)
        addEvent(moveCart, interval, cid, 3)
    elseif item.actionid == 5195 then
        mayNotMove(cid, false)
        doRemoveCondition(cid, CONDITION_OUTFIT)
        doPlayerSendTextMessage(cid, 20, "You have reached your destiny, you may leave now...")
        doPlayerSetStorageValue(cid, 1212123, -1)
    end
    return true
end]]></movement>
</mod>


Configuration
To choose the cart direction, just put the desired actionID in a SQM the cart is goin to step. Pay attention to my explanation inside the code where I explain wich actionID means what.

If you couldn't understand how to install or anything, just post right here...
I'm brazilian so my english is not perfet, hope its ok.
 
Last edited:
I have errors @Killua Real

Code:
[14/05/2014 17:26:35] [Error - MoveEvents Interface]
[14/05/2014 17:26:35] buffer:onStepIn
[14/05/2014 17:26:35] Description:
[14/05/2014 17:26:35] (luaSetItemOutfit) Creature not found

Code:
[14/05/2014 17:26:42] [Error - MoveEvents Interface]
[14/05/2014 17:26:42] In a timer event called from:
[14/05/2014 17:26:42] buffer:onStepIn
[14/05/2014 17:26:42] Description:
[14/05/2014 17:26:42] (luaGetCreatureStorage) Creature not found


I fixed it !


doSetItemOutfit(cid, 7131, -1)
 
Last edited:
Would be awesome that it would follow rails and had an smoother transition between SQM like mock script. For the rest is awesome and thanks for sharing.
 
Back
Top