doCreatureSetNoMove(player, true)
but try to add it to one of the scripts I posted on your other thread.For example,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 ?
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 functiondoCreatureSetNoMove(player, true)
but try to add it to one of the scripts I posted on your other thread.
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
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
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
noMove
for every creature (set by doCreatureSetNoMove(cid, true)
) and it's checked in game.cpp
: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;
}
creature.cpp
:bool Creature::startAutoWalk(std::list<Direction>& listDir)
{
if(getPlayer() && getPlayer()->getNoMove())
{
getPlayer()->sendCancelWalk();
return false;
}