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

CreatureEvent [Lua&C++]Absolute anti clon system!

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Reaction score
106
Location
Brazil
This system require this creraturescript:
http://otland.net/f35/creaturescript-onmoveitem-moveitem-frompos-position-cid-96742/


When you install this creaturescript just add this code and you will never worry about item clon in your server:
Code:
function onMoveItem(moveItem, frompos, position, cid)
	if cid and isPlayer(cid) then
		doSavePlayer(cid)
	end
        return true
end
function onTradeAccept(cid, target, item)
     doSavePlayer(cid)
     doSavePlayer(target) 
     return true
end

If you want save the player house too...
int32_t LuaScriptInterface::luadoSaveHouse(lua_State* L)
{
//doSaveHouse(houseId)
bool displayError = true;
if(lua_gettop(L) > 1)
displayError = popNumber(L);

House* house = Houses::getInstance()->getHouse(popNumber(L));
if(!house)
{
if(displayError)
errorEx(getError(LUA_ERROR_HOUSE_NOT_FOUND));

lua_pushboolean(L, false);
return 1;
}
Database* db = Database::getInstance();
DBTransaction trans(db);
if(!trans.begin())
return false;

IOMapSerialize::getInstance()->saveHouse(db,house);
lua_pushboolean(L, trans.commit());

return 1;
}
 
Last edited:
A quick solution, but not very efficient
does this work with trading too? if so, that's smart
how is it supposed to work with player trade if trading uses internalMoveItem and not playerMoveItem?
 
A quick solution, but not very efficient

how is it supposed to work with player trade if trading uses internalMoveItem and not playerMoveItem?
I haven't read the C++ function, mr smart
 
[11:2:59.205] [Error - CreatureScript Interface]
[11:2:59.206] data/creaturescripts/scripts/custom/dup.lua:eek:nMoveItem
[11:2:59.207] Description:
[11:2:59.208] data/creaturescripts/scripts/custom/dup.lua:3: attempt to call glo
bal 'doSavePlayer' (a nil value)
[11:2:59.209] stack traceback:
[11:2:59.211] data/creaturescripts/scripts/custom/dup.lua:3: in function <data
/creaturescripts/scripts/custom/dup.lua:1>
 
@up

If you're using 0.2 then it won't work.
What the error is saying is that the function doSavePlayer() does not exist.

This function is available in 0.3/0.4.
(I MAY BE WRONG, BUT I'M PRETTY CERTAIN)

EDIT:

I noticed that the function is written differently in the doc/LUA_FUNCTIONS file.

Try this: doPlayerSave(cid)
 
does this work with trading too? if so, that's smart
i Think the my onMoveItem is call on trade but if didn't...:
Code:
function onTradeAccept(cid, target, item)
     doSavePlayer(cid)
     doSavePlayer(target) 
end

[11:2:59.205] [Error - CreatureScript Interface]
[11:2:59.206] data/creaturescripts/scripts/custom/dup.luanMoveItem
[11:2:59.207] Description:
[11:2:59.208] data/creaturescripts/scripts/custom/dup.lua:3: attempt to call glo
bal 'doSavePlayer' (a nil value)
[11:2:59.209] stack traceback:
[11:2:59.211] data/creaturescripts/scripts/custom/dup.lua:3: in function <data
/creaturescripts/scripts/custom/dup.lua:1>
Only works on tfs 0.3.4+ and 0.4.x
 
It's not like doSaveHouse is a hard thing to make. It's just that it would be veeeeery ineffiecient to save the houses to database everytime...

How about OT using 2 Consoles, one that stores shit so if OT crash it will remain ? Or might that be too complicated/ineffiecient as well? xD
 
It's not like doSaveHouse is a hard thing to make. It's just that it would be veeeeery ineffiecient to save the houses to database everytime...

How about OT using 2 Consoles, one that stores shit so if OT crash it will remain ? Or might that be too complicated/ineffiecient as well? xD

Well i know the whole systems is inneficient. however there are people desperate for a quick solution.
The save house is only to save things if player remove something on the house...
But i can create another thing, not a console but a file :w00t:. When crashes server read the file and etc... if you close using /shutdown the server delete the file.
 
But that probably is slower than saving to SQL xD
Well maybe it wont be very inefficient to save house once you move an item ;p
Just make sure that you also use onMoveItem to check if he moved item from inside house to outside house and not only if he picks it up !
 
But that probably is slower than saving to SQL xD
Well maybe it wont be very inefficient to save house once you move an item ;p
Just make sure that you also use onMoveItem to check if he moved item from inside house to outside house and not only if he picks it up !
ow every 2 sec save the house when move a item inside a house :p
 
i Think the my onMoveItem is call on trade but if didn't...:
Only works on tfs 0.3.4+ and 0.4.x
I'm using 0.4 lol, but what evan said fixed it for me, the right one is doPlayerSave(cid), btw there is a serious issue (maybe my fault?), but no one can take loot from creatures =/
 
Last edited by a moderator:
I'm using 0.4 lol, but what evan said fixed it for me, the right one is doPlayerSave(cid), btw there is a serious issue (maybe my fault?), but no one can take loot from creatures =/
just fiex... is the return true missing. but the creaturescript do not work well in tfs 0.4...
better not use on 0.4 you can crash your server
 
does not work, he first saved and then move the item, so the player gets the item and the other too.


And something strange is happening, it is not saving the coordinates of the player only items of the body, someone tell me why? using doPlayerSave (cid)
 
Ou mock pra essa função ficar melhor e realmente evitar o clone e até evitaria rollback na parte de perda de itens, seria você criar uma função que identifica se o item que esta sendo arrastado está em house se tiver em house salva essa especifica house isso em c++,e mesma coisa se o player jogar o item na house, identifica e salva a house, isso concerteza seria perfeito, por que no entanto esse sistema tem 1 falha se o player arrastar o item da house , a house não salva, salva apenas o jogador e dupa item, alem de que da rollback se o jogador jogar o item na house,
a função ai pra salvar a house é pra salvar a house que o cara é dono isso é invalido se ele tiver usando a house de amigo etc..
 
Back
Top