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

Feature [creatureEvent] onMove very advanced

There is no real "better" arguement, it is rather a style thing and where you use it.
In the case where you said we should use not instead of == 0 it will not work.

var = 0
var == 0 is true
not var is false

Afaik when I did things back in like 2008 it was if variable == 0 then if the variable is false then...
Today I use if not variable insted of if variable == false or 0.

If the variable is supposed to be true, just use if variable then
 
As I said multiple times now: not 0 -> will evaluate to false and not true because every value except nil and false are true in lua.
 
Last edited:
Code:
1>  game.cpp
1>..\game.cpp(1670): error C2447: '{' : falta el encabezado de función (¿lista formal de estilo anterior?)
I'm getting this error, help pls
 
Sorry revive this topic, but im trying to use this feature, without succes...

I compile ite normaly, but in game when i push a item to ground i get a crash error:

theforgottenserver: game.cpp:1629: ReturnValue Game::internalMoveItem(Creature*, Cylinder*, Cylinder*, int32_t, Item*, uint32_t, Item**, uint32_t): Assertion `fromCylinder == item->getParent()' failed.
Aborted

Anybody can help me?

Code:
ReturnValue Game::internalMoveItem(Creature* actor, Cylinder* fromCylinder, Cylinder* toCylinder,
    int32_t index, Item* item, uint32_t count, Item** _moveItem, uint32_t flags /*= 0*/)
{
    if(!toCylinder)
        return RET_NOTPOSSIBLE;

    if(!item->getParent())
    {
        assert(fromCylinder == item->getParent());
        return internalAddItem(actor, toCylinder, item, INDEX_WHEREEVER, FLAG_NOLIMIT);
    }

The line 1629 is "assert(fromCylinder == item->getParent());" located in "ReturnValue Game::internalMoveItem"

0.4 rev 3884

Thanks
 
Last edited:
Sorry revive this topic, but im trying to use this feature, without succes...

I compile ite normaly, but in game when i push a item to ground i get a crash error:



Anybody can help me?

Code:
ReturnValue Game::internalMoveItem(Creature* actor, Cylinder* fromCylinder, Cylinder* toCylinder,
    int32_t index, Item* item, uint32_t count, Item** _moveItem, uint32_t flags /*= 0*/)
{
    if(!toCylinder)
        return RET_NOTPOSSIBLE;

    if(!item->getParent())
    {
        assert(fromCylinder == item->getParent());
        return internalAddItem(actor, toCylinder, item, INDEX_WHEREEVER, FLAG_NOLIMIT);
    }

The line 1629 is "assert(fromCylinder == item->getParent());" located in "ReturnValue Game::internalMoveItem"

0.4 rev 3884

Thanks
show the script you're using
if you're removing the item and using return true, the client will crash
 
TFS 0.4 (8.60)

I compiled the sources with no errors, but the scripts just don't do anything.

Using the example code from the thread author to disable throwing an item to the ground:
Lua:
function onMoveItem(cid, item, fromPosition, toPosition, fromItem, toItem, fromGround, toGround, status)
    if item.itemid == 2466 then
        if (status.inInv == 0 and status.inInvBag == 3 and status.inDepot == 3) or (status.inDepot == 0 and status.inInv == 3 and status.inInvBag == 3 ) or (status.inInvBag == 0 and status.inDepot == 3 and status.inInv == 3) then
            doPlayerSendCancel(cid,"you can't throw this item on ground.")
            return false
        end
    end
    return true
end

Then this in creaturescripts.xml
HTML:
   <event type="move" name="GroundThrow" event="script" value="groundthrow.lua"/>

And for last i registered in login.lua: (is this the right place to put the line?)
Lua:
function onLogin(cid)
    registerCreatureEvent(cid, "GroundThrow") <-----  RIGHT HERE
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then

And still, nothing happens. Can anybody help?
 
I got this error: o.o

...trunk.r3884\game.cpp In member function `bool Game::playerMoveItem(uint32_t, const Position&, uint16_t, int16_t, const Position&, uint8_t)':
...trunk.r3884\game.cpp `RET_NOTMOVEABLE' was not declared in this scope
...trunk.r3884\dev-cpp\Makefile.win [Build Error] [obj//game.o] Error 1

TFS 0.4 rev 3884
 
I got this error: o.o

...trunk.r3884\game.cpp In member function `bool Game::playerMoveItem(uint32_t, const Position&, uint16_t, int16_t, const Position&, uint8_t)':
...trunk.r3884\game.cpp `RET_NOTMOVEABLE' was not declared in this scope
...trunk.r3884\dev-cpp\Makefile.win [Build Error] [obj//game.o] Error 1

TFS 0.4 rev 3884
try using RET_NOTMOVABLE instead of RET_NOTMOVEABLE
or search thing.h for something that pertains to RET_NOTMOVABLE (with just a different spelling) and use that value
 
@Static_

Well, this solved this problem, but when goig to build the .exe, I got this errors:

[Linker error] undefined reference to `Game::internalAddItem(Creature*, Cylinder*, Item*, int, unsigned int, bool)'
[Linker error] undefined reference to `Game::internalRemoveItem(Creature*, Item*, int, bool, unsigned int)'
[Linker error] undefined reference to `Game::findItemOfType(Cylinder*, unsigned short, bool, int)'
[Linker error] undefined reference to `Game::internalMoveItem(Creature*, Cylinder*, Cylinder*, int, Item*, unsigned int, Item**, unsigned int)'
lots this erros
...dev-cpp\Makefile.win [Build Error] [TheForgottenServer.exe] Error 1
 
error to compile on tfs 0.3.6

make[1]: Entering directory `/root/source-origens_ok-14-06-2023'
g++ -DHAVE_CONFIG_H -I. -I/usr/include/libxml2 -I/usr/include/lua5.1 -D__USE_MYSQL__ -D__ENABLE_SERVER_DIAGNOSTIC__ -D__ROOT_PERMISSION__ -D_THREAD_SAFE -D_REENTRANT -Wall -g -O1 -MT creature.o -MD -MP -MF .deps/creature.Tpo -c -o creature.o creature.cpp
creature.cpp: In member function ‘virtual bool Creature::eek:nDeath()’:
creature.cpp:664: error: ‘class CreatureEvent’ has no member named ‘executePrepareDeath’
make[1]: *** [creature.o] Error 1
make[1]: Leaving directory `/root/source-origens_ok-14-06-2023'
make: *** [all] Error 2

can help ?
 

Similar threads

Replies
7
Views
938
Back
Top