• 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/c++] how to stop monster from walking in creaturesctipt?

vejin

I'm not an expert.
Joined
May 6, 2010
Messages
54
Reaction score
2
Location
Ultima
Hello, I'm using TFS 1.0 on debian.
I need to write a script which stops monster when 'something happens' (it is not important).
Important thing is, how to stop that monster?
I tried something like this:

when storage value = 2 then
dospeedchange(cid, 0)

doesn't work, because there is delta, so I need to check the speed and then add a '-' before the value

when storage bla bla then
local speed = getplayerspeed(cid)
dospeedchange(cid, -speed)

there is a problem, getplayerspeed (or getcreaturespeed I don't remember now) returns boolean value (true or false) and the question is.... this function checks if player has speed or hasn't speed?! how to compare it?

also tried with maynotmove(cid) but it was removed from source before I downloaded git.
also tried with checking speed of monster from .xml file on my own but when monster updated target list and storage value was not 2 then monster got extremely fast

sorry for wrong names of functions, I think it is not necessary to keep all identical with actual functions.
 
Well in TFS 1.0 the only way is to:
Code:
local monster = Monster(cid)
monster:changeSpeed(-monster:getSpeed())
 
@Nothxbye: 'simply add it'... well, yeah. If I were able to add this function (my c++ skills are on copy/paste level) I wouldn't ask this on forum. Ofc I tried it already and this function from tfs 0.3.6 needs to be completely rewritten to add to my 1.0. (yes, I copied and pasted it and its declarations in proper places)

@Printer: and what happens when storage value is not 2 and monster speed is 0? I could just add it but when new player (without storage value = 2) appears, monster will get double speed, because getcreaturespeed doesn't return a number value, just bool

@EDIT maybe it will just be good if someone could post a c++ script of a lua function setspeed but not with that 'delta' just setting speed(cid, 0) will set speed to 0 and (cid, 700) will set speed to 700.
 
Last edited:
Back
Top