• 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 Function clipboardCopy(text) Can be used with positions

Doggynub

LUA / C++
Joined
Sep 28, 2008
Messages
2,541
Reaction score
186
Well thought of this when i saw this thread http://otland.net/f35/coordinates-159038/

This function copy the text to the clipboard (ie: as if you made ctrl+c to the text)

luascript.h

find
[cpp]
static int32_t luaStdSHA512(lua_State* L);[/cpp]
and place this under
[cpp]
static int32_t luaClipboardCopy(lua_State* L);[/cpp]

luascript.cpp
find
[cpp]
//setCreatureMaxMana(cid, mana)[/cpp]
paste this above
[cpp]
//clipboardCopy(text)
lua_register(m_luaState, "clipboardCopy", LuaInterface::luaClipboardCopy);
[/cpp]

then find
[cpp]
int32_t LuaInterface::luaSetCreatureMaxMana(lua_State* L)
[/cpp]
and paste this above
[cpp]
int32_t LuaInterface::luaClipboardCopy(lua_State* L)
{
//clipboardCopy(text)
std::string text = popString(L);
if(text != "")
{
const char* output = text.c_str();
const size_t len = strlen(output) + 1;
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, len);
memcpy(GlobalLock(hMem), output, len);
GlobalUnlock(hMem);
OpenClipboard(0);
EmptyClipboard();
if(SetClipboardData(CF_TEXT, hMem) != NULL)
lua_pushboolean(L,true);
else
lua_pushboolean(L,false);


CloseClipboard();
}

return 1;
}
[/cpp]

You can use like that
Lua:
function onLook(cid, thing, position, lookDistance)
	if getPlayerGroupId(cid) >= 4 then
		local str = string.gsub("{x = |x|, y = |y|, z = |z|, stackpos = |stackpos|}","|(.-)|",function(a) return position[a] end)
		if not clipboardCopy(str) then
			print("error in copying to clipboard, no data copied.")
		end
	end
	return true
end
 
Back
Top