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

Lua STOP WALK (CID) - how do this?

Dibis

Member
Joined
Dec 1, 2022
Messages
73
Reaction score
16
Location
POLAND
Hello Otlanders!
I need functions or other way to stop walking for players who have storage < 1?
This is possible on TFS 0.3.7 ?
 
Not sure if 0.3.7 has this function doCreatureSetNoMove(player, true) but try to add it to one of the scripts I posted on your other thread.
 
Hello Otlanders!
I need functions or other way to stop walking for players who have storage < 1?
This is possible on TFS 0.3.7 ?
For example,
Lua:
if getPlayerStorageValue(player, 12346) < 0 then
    if((doCreatureSetNoMove(player, 1))== LUA_ERROR) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Error.")
        return 0
    end
    end
 
Not sure if 0.3.7 has this function doCreatureSetNoMove(player, true) but try to add it to one of the scripts I posted on your other thread.

I add this but I can walking ...
I find this, but function working only with TFS 1.x, who can change this for 0.3.7 ?

Lua:
function doCreatureSetNoMove(cid,allow)
if allow then
local speed = Player(cid):getSpeed()
Player(cid):changeSpeed(-speed)
      else
    doChangeSpeed(cid, getSpeed(cid, getPlayerLevel(cid)) - getCreatureSpeed(cid))
end
end

function getSpeed(cid,level)
  value = (220 +(2 *(level -1)))
  return value
end
 
Last edited:
This solution isn't exactly what you asked for, but it will work.
Lua:
local config = {
    storage = 123456,

    msg = true,
    txt = "You cannot walk.",
    type = 21,
}

function onStepIn(cid, item, position, fromPosition)
    if getPlayerStorageValue(cid, config.storage) < 1 then
        doTeleportThing(cid, fromPosition, true)
        if config.msg then doPlayerSendTextMessage(cid, config.type, config.txt) end
    end

    return true
end
 
This solution isn't exactly what you asked for, but it will work.
Lua:
local config = {
    storage = 123456,

    msg = true,
    txt = "You cannot walk.",
    type = 21,
}

function onStepIn(cid, item, position, fromPosition)
    if getPlayerStorageValue(cid, config.storage) < 1 then
        doTeleportThing(cid, fromPosition, true)
        if config.msg then doPlayerSendTextMessage(cid, config.type, config.txt) end
    end

    return true
end

Where I can must add this? In moveevents or creaturescripts?
 
I have developed a script option for creatuscripts:
Lua:
local config = {
    stor = 123456,

    msg = true,
    txt = "You cannot walk.",
    type = 21,
}

local function getSpeed(cid, level) return (220 + (2 * (level - 1))) end

local function canWalk(cid)
    if isPlayer(cid) then
        if getPlayerStorageValue(cid, config.stor) >= 1 then
            doChangeSpeed(cid, getSpeed(cid, getPlayerLevel(cid)))
        else
            doChangeSpeed(cid, 0)
        end
        addEvent(canWalk, 250, cid)
    end

    return true
end

function onLogin(cid)
    canWalk(cid)
    if config.msg then
        if getPlayerStorageValue(cid, config.stor) <= 0 then
            doPlayerSendTextMessage(cid, config.type, config.txt)
        end
    end

    return true
end
 
You dont need to have cid as an argument in the getSpeed function. And probably you have a getPlayerSpeed function,
 
Every solution in Lua will be partially bugged. When player clicks arrow in client, client expects that server will confirm that step [with some delay - ping] and it starts animation.
Server must send packet 'cancel walk' for every 'make step' packet, to move player back to his position in client [stop walk animation].

Ex. in 0.4 rev 3777 there is attribute noMove for every creature (set by doCreatureSetNoMove(cid, true)) and it's checked in game.cpp:
C++:
bool Game::playerMove(uint32_t playerId, Direction dir) // IT'S EXECUTED WHEN PLAYER PRESS ARROW IN CLIENT
{
   Player* player = getPlayerByID(playerId);
   if(!player || player->isRemoved())
      return false;

   player->setIdleTime(0);
   if(player->getNoMove()) // CANNOT MOVE
   {
      player->sendCancelWalk(); // SEND CANCEL WALK
      return false;
   }
and creature.cpp:
C++:
bool Creature::startAutoWalk(std::list<Direction>& listDir)
{
   if(getPlayer() && getPlayer()->getNoMove())
   {
      getPlayer()->sendCancelWalk();
      return false;
   }
EDIT:
all 'no move' codes for 0.4:
 
Last edited:
Back
Top