flaviiojr
Active Member
- Joined
- Jan 20, 2017
- Messages
- 230
- Solutions
- 13
- Reaction score
- 39
I don't know, but should be main backpackI will test a doubt the loot will go to the backpack that owns the item or will always go to the main backpack
I don't know, but should be main backpackI will test a doubt the loot will go to the backpack that owns the item or will always go to the main backpack
- registerMethod("Player", "AddAutoLootItem", LuaScriptInterface::luaPlayerAddAutoLootItem);
- registerMethod("Player", "RemoveAutoLootItem", LuaScriptInterface::luaPlayerRemoveAutoLootItem);
- registerMethod("Playe
check it out, man, something you did wrong ...After this, i have:
luascript.cpp:48:62: error: no ‘int LuaScriptInterface: :luaPlayerAddAutoLootItem(lua_State*)’ member function declared in class ‘LuaScr iptInterface’
int LuaScriptInterface::luaPlayerAddAutoLootItem(lua_State* L)
^
error: no ‘int LuaScriptInterface: :luaPlayerRemoveAutoLootItem(lua_State*)’ member function declared in class ‘Lua ScriptInterface’
int LuaScriptInterface::luaPlayerRemoveAutoLootItem(lua_State* L)
^
error: no ‘int LuaScriptInterface: :luaPlayerGetAutoLootItem(lua_State*)’ member function declared in class ‘LuaScr iptInterface’
int LuaScriptInterface::luaPlayerGetAutoLootItem(lua_State* L)
^
error: no ‘int LuaScriptInterface ::luaPlayerGetAutoLootList(lua_State*)’ member function declared in class ‘LuaSc riptInterface’
int LuaScriptInterface::luaPlayerGetAutoLootList(lua_State* L)
^
luascript.cpp: In member function ‘void LuaScriptInterf ace::registerFunctions()’:
luascript.cpp:2578:46: error: ‘luaPlayerAddAutoLootIte ’ is not a member of ‘LuaScriptInterface’
registerMethod("Player", "AddAutoLootItem", LuaScriptInterface::luaPlayerAddAu
^
/luascript.cpp:2579:52: error: ‘luaPlayerRemoveAutoLootI tem’ is not a member of ‘LuaScriptInterface’
registerMethod("Player", "RemoveAutoLootItem", LuaScriptInterface::luaPlaye
^
luascript.cpp:2580:49: error: ‘luaPlayerGetAutoLootIte ’ is not a member of ‘LuaScriptInterface’
registerMethod("Player", "GetAutoLootItem", LuaScriptInterface::luaPlayerGe
^
luascript.cpp:2581:49: error: ‘luaPlayerGetAutoLootLis ’ is not a member of ‘LuaScriptInterface’
registerMethod("Player", "GetAutoLootList", LuaScriptInterface::luaPlayerGe
After this, i have:
luascript.cpp:48:62: error: no ‘int LuaScriptInterface: :luaPlayerAddAutoLootItem(lua_State*)’ member function declared in class ‘LuaScr iptInterface’
int LuaScriptInterface::luaPlayerAddAutoLootItem(lua_State* L)
^
error: no ‘int LuaScriptInterface: :luaPlayerRemoveAutoLootItem(lua_State*)’ member function declared in class ‘Lua ScriptInterface’
int LuaScriptInterface::luaPlayerRemoveAutoLootItem(lua_State* L)
^
error: no ‘int LuaScriptInterface: :luaPlayerGetAutoLootItem(lua_State*)’ member function declared in class ‘LuaScr iptInterface’
int LuaScriptInterface::luaPlayerGetAutoLootItem(lua_State* L)
^
error: no ‘int LuaScriptInterface ::luaPlayerGetAutoLootList(lua_State*)’ member function declared in class ‘LuaSc riptInterface’
int LuaScriptInterface::luaPlayerGetAutoLootList(lua_State* L)
^
luascript.cpp: In member function ‘void LuaScriptInterf ace::registerFunctions()’:
luascript.cpp:2578:46: error: ‘luaPlayerAddAutoLootIte ’ is not a member of ‘LuaScriptInterface’
registerMethod("Player", "AddAutoLootItem", LuaScriptInterface::luaPlayerAddAu
^
/luascript.cpp:2579:52: error: ‘luaPlayerRemoveAutoLootI tem’ is not a member of ‘LuaScriptInterface’
registerMethod("Player", "RemoveAutoLootItem", LuaScriptInterface::luaPlaye
^
luascript.cpp:2580:49: error: ‘luaPlayerGetAutoLootIte ’ is not a member of ‘LuaScriptInterface’
registerMethod("Player", "GetAutoLootItem", LuaScriptInterface::luaPlayerGe
^
luascript.cpp:2581:49: error: ‘luaPlayerGetAutoLootLis ’ is not a member of ‘LuaScriptInterface’
registerMethod("Player", "GetAutoLootList", LuaScriptInterface::luaPlayerGe
check it out, man, something you did wrong ...
static int luaPlayerAddAutoLootItem(lua_State* L);
static int luaPlayerRemoveAutoLootItem(lua_State* L);
static int luaPlayerGetAutoLootItem(lua_State* L);
static int luaPlayerGetAutoLootList(lua_State* L);
[/B]
Omg, i don't see this! hahaI think is it
luascript.h
Code:static int luaPlayerAddAutoLootItem(lua_State* L); static int luaPlayerRemoveAutoLootItem(lua_State* L); static int luaPlayerGetAutoLootItem(lua_State* L); static int luaPlayerGetAutoLootList(lua_State* L); [/B]
I think is it
luascript.h
Code:static int luaPlayerAddAutoLootItem(lua_State* L); static int luaPlayerRemoveAutoLootItem(lua_State* L); static int luaPlayerGetAutoLootItem(lua_State* L); static int luaPlayerGetAutoLootList(lua_State* L); [/B]
bothsorry, I was confused, just add this line in luascript.h or all the code that was quoted?
- static int luaPlayerAddAutoLootItem(lua_State* L);
- static int luaPlayerRemoveAutoLootItem(lua_State* L);
- static int luaPlayerGetAutoLootItem(lua_State* L);
- static int luaPlayerGetAutoLootList(lua_State* L);
int LuaScriptInterface::luaPlayerAddAutoLootItem(lua_State* L)
{
// player:addAutoLootItem(itemId)
Player* player = getUserdata<Player>(L, 1);
if (!player) {
lua_pushnil(L);
return 1;
}
uint16_t itemId;
if (isNumber(L, 2)) {
itemId = getNumber<uint16_t>(L, 2);
} else {
itemId = Item::items.getItemIdByName(getString(L, 2));
if (itemId == 0) {
lua_pushnil(L);
return 1;
}
}
player->addAutoLootItem(itemId);
pushBoolean(L, true);
return 1;
}
you have to define the function in luascript.cpp
- int LuaScriptInterface::luaPlayerAddAutoLootItem(lua_State* L)
- {
- // player:addAutoLootItem(itemId)
- Player* player = getUserdata<Player>(L, 1);
- if (!player) {
- lua_pushnil(L);
- return 1;
- }
- uint16_t itemId;
- if (isNumber(L, 2)) {
- itemId = getNumber<uint16_t>(L, 2);
- } else {
- itemId = Item::items.getItemIdByName(getString(L, 2));
- if (itemId == 0) {
- lua_pushnil(L);
- return 1;
- }
- }
- player->addAutoLootItem(itemId);
- pushBoolean(L, true);
- return 1;
- }
Post luascript.cpp and luascript.h in pastebin.com and paste link here...help-me ? i made it: static void luascript(){ and this script } or dont is it ?
Post luascript.cpp and luascript.h in pastebin.com and paste link here...
static int luaPlayerGetAutoLootList(lua_State* L);
{
// player:getAutoLootList()
Player* player = getUserdata<Player>(L, 1);
if (player) {
std::set<uint32_t> value = player->autoLootList;
if (value.size() == 0) {
lua_pushnil(L);
return 1;
}
int index = 0;
lua_createtable(L, value.size(), 0);
for(auto i : value) {
lua_pushnumber(L, i);
lua_rawseti(L, -2, ++index);
}
} else {
lua_pushnil(L);
}
return 1;
}
int luaPlayerGetAutoLootList(lua_State* L)
{
// player:getAutoLootList()
Player* player = getUserdata<Player>(L, 1);
if (player) {
std::set<uint32_t> value = player->autoLootList;
if (value.size() == 0) {
lua_pushnil(L);
return 1;
}
int index = 0;
lua_createtable(L, value.size(), 0);
for(auto i : value) {
lua_pushnumber(L, i);
lua_rawseti(L, -2, ++index);
}
} else {
lua_pushnil(L);
}
return 1;
}
also remove the ;
result should be this:
C++:int luaPlayerGetAutoLootList(lua_State* L) { // player:getAutoLootList() Player* player = getUserdata<Player>(L, 1); if (player) { std::set<uint32_t> value = player->autoLootList; if (value.size() == 0) { lua_pushnil(L); return 1; } int index = 0; lua_createtable(L, value.size(), 0); for(auto i : value) { lua_pushnumber(L, i); lua_rawseti(L, -2, ++index); } } else { lua_pushnil(L); } return 1; }
/src/luascript.h: In function ‘int luaPlayerAddAutoLootItem(lua_State*)’:
/src/luascript.h:186:22: error: ‘getUserdata’ was not declared in this scope
Player* player = getUserdata<Player>(L, 1);
^
/src/luascript.h:186:40: error: expected primary-expression before ‘>’ token
Player* player = getUserdata<Player>(L, 1);
^
/src/luascript.h:186:45: error: left operand of comma operator has no effect [-Werror=unused-value]
Player* player = getUserdata<Player>(L, 1);
^
/src/luascript.h:193:22: error: ‘isNumber’ was not declared in this scope
if (isNumber(L, 2)) {
^
/src/luascript.h:194:18: error: ‘getNumber’ was not declared in this scope
itemId = getNumber<uint16_t>(L, 2);
^
/src/luascript.h:194:36: error: expected primary-expression before ‘>’ token
itemId = getNumber<uint16_t>(L, 2);
^
/src/luascript.h:194:41: error: left operand of comma operator has no effect [-Werror=unused-value]
itemId = getNumber<uint16_t>(L, 2);
^
/src/luascript.h:196:18: error: incomplete type ‘Item’ used in nested name specifier
itemId = Item::items.getItemIdByName(getString(L, 2));
^
/src/luascript.h:196:60: error: ‘getString’ was not declared in this scope
itemId = Item::items.getItemIdByName(getString(L, 2));
^
/src/luascript.h:202:11: error: invalid use of incomplete type ‘class Player’
player->addAutoLootItem(itemId);
^
/src/luascript.h:41:7: error: forward declaration of ‘class Player’
class Player;
^
/src/luascript.h:203:24: error: ‘pushBoolean’ was not declared in this scope
pushBoolean(L, true);
^
/src/luascript.h: In function ‘int luaPlayerRemoveAutoLootItem(lua_State*)’:
/src/luascript.h:210:22: error: ‘getUserdata’ was not declared in this scope
Player* player = getUserdata<Player>(L, 1);
^
/src/luascript.h:210:40: error: expected primary-expression before ‘>’ token
Player* player = getUserdata<Player>(L, 1);
^
/src/luascript.h:210:45: error: left operand of comma operator has no effect [-Werror=unused-value]
Player* player = getUserdata<Player>(L, 1);
^
/src/luascript.h:217:22: error: ‘isNumber’ was not declared in this scope
if (isNumber(L, 2)) {
^
/src/luascript.h:218:18: error: ‘getNumber’ was not declared in this scope
itemId = getNumber<uint16_t>(L, 2);
^
/src/luascript.h:218:36: error: expected primary-expression before ‘>’ token
itemId = getNumber<uint16_t>(L, 2);
^
/src/luascript.h:218:41: error: left operand of comma operator has no effect [-Werror=unused-value]
itemId = getNumber<uint16_t>(L, 2);
^
/src/luascript.h:220:18: error: incomplete type ‘Item’ used in nested name specifier
itemId = Item::items.getItemIdByName(getString(L, 2));
^
/src/luascript.h:220:60: error: ‘getString’ was not declared in this scope
itemId = Item::items.getItemIdByName(getString(L, 2));
^
/src/luascript.h:227:11: error: invalid use of incomplete type ‘class Player’
player->removeAutoLootItem(itemId);
^
/src/luascript.h:41:7: error: forward declaration of ‘class Player’
class Player;
^
/src/luascript.h:228:24: error: ‘pushBoolean’ was not declared in this scope
pushBoolean(L, true);
^
/src/luascript.h: In function ‘int luaPlayerGetAutoLootItem(lua_State*)’:
/src/luascript.h:236:22: error: ‘getUserdata’ was not declared in this scope
Player* player = getUserdata<Player>(L, 1);
^
/src/luascript.h:236:40: error: expected primary-expression before ‘>’ token
Player* player = getUserdata<Player>(L, 1);
^
/src/luascript.h:236:45: error: left operand of comma operator has no effect [-Werror=unused-value]
Player* player = getUserdata<Player>(L, 1);
^
/src/luascript.h:243:22: error: ‘isNumber’ was not declared in this scope
if (isNumber(L, 2)) {
^
/src/luascript.h:244:18: error: ‘getNumber’ was not declared in this scope
itemId = getNumber<uint16_t>(L, 2);
^
/src/luascript.h:244:36: error: expected primary-expression before ‘>’ token
itemId = getNumber<uint16_t>(L, 2);
^
/src/luascript.h:244:41: error: left operand of comma operator has no effect [-Werror=unused-value]
itemId = getNumber<uint16_t>(L, 2);
^
/src/luascript.h:246:18: error: incomplete type ‘Item’ used in nested name specifier
itemId = Item::items.getItemIdByName(getString(L, 2));
^
/src/luascript.h:246:60: error: ‘getString’ was not declared in this scope
itemId = Item::items.getItemIdByName(getString(L, 2));
^
/src/luascript.h:253:15: error: invalid use of incomplete type ‘class Player’
if (player->getAutoLootItem(itemId)) {
^
/src/luascript.h:41:7: error: forward declaration of ‘class Player’
class Player;
^
/src/luascript.h:254:28: error: ‘pushBoolean’ was not declared in this scope
pushBoolean(L, true);
^
/src/luascript.h:256:29: error: ‘pushBoolean’ was not declared in this scope
pushBoolean(L, false);
^
/src/luascript.h: In function ‘int luaPlayerGetAutoLootList(lua_State*)’:
/src/luascript.h:266:22: error: ‘getUserdata’ was not declared in this scope
Player* player = getUserdata<Player>(L, 1);
^
/src/luascript.h:266:40: error: expected primary-expression before ‘>’ token
Player* player = getUserdata<Player>(L, 1);
^
/src/luascript.h:266:45: error: left operand of comma operator has no effect [-Werror=unused-value]
Player* player = getUserdata<Player>(L, 1);
^
/src/luascript.h:269:9: error: ‘set’ is not a member of ‘std’
std::set<uint32_t> value = player->autoLootList;
^
/src/luascript.h:269:9: note: suggested alternative:
In file included from /usr/include/boost/lexical_cast.hpp:170:0,
from /root/Otxserver-New/src/database.h:23,
from /root/Otxserver-New/src/luascript.h:35,
from /root/Otxserver-New/src/baseevents.h:23,
from /root/Otxserver-New/src/actions.h:23,
from /root/Otxserver-New/src/actions.cpp:22:
/usr/include/boost/container/container_fwd.hpp:79:7: note: ‘boost::container::set’
class set;
^
In file included from /root/Otxserver-New/src/baseevents.h:23:0,
from /root/Otxserver-New/src/actions.h:23,
from /root/Otxserver-New/src/actions.cpp:22:
/src/luascript.h:269:26: error: expected primary-expression before ‘>’ token
std::set<uint32_t> value = player->autoLootList;
^
/src/luascript.h:269:28: error: ‘value’ was not declared in this scope
std::set<uint32_t> value = player->autoLootList;
^
/src/luascript.h:269:42: error: invalid use of incomplete type ‘class Player’
std::set<uint32_t> value = player->autoLootList;
^
/src/luascript.h:41:7: error: forward declaration of ‘class Player’
class Player;
^
/src/luascript.h:278:22: error: unable to deduce ‘auto&&’ from ‘value’
for(auto i : value) {
^
player.cpp - Pastebin.com -> player.cppPost luascript.cpp and luascript.h in pastebin.com and paste link here...
also remove the ;
result should be this:
C++:int luaPlayerGetAutoLootList(lua_State* L) { // player:getAutoLootList() Player* player = getUserdata<Player>(L, 1); if (player) { std::set<uint32_t> value = player->autoLootList; if (value.size() == 0) { lua_pushnil(L); return 1; } int index = 0; lua_createtable(L, value.size(), 0); for(auto i : value) { lua_pushnumber(L, i); lua_rawseti(L, -2, ++index); } } else { lua_pushnil(L); } return 1; }
root@vps164667:~/Otxserver-New/cmake# screen -r
/root/Otxserver-New/src/luascript.cpp:119:22: error: ‘getUserdata’ was not declared in this scope
Player* player = getUserdata<Player>(L, 1);
^
/root/Otxserver-New/src/luascript.cpp:119:40: error: expected primary-expression before ‘>’ token
Player* player = getUserdata<Player>(L, 1);
^
/root/Otxserver-New/src/luascript.cpp:119:45: error: left operand of comma operator has no effect [-Werror=unused-value]
Player* player = getUserdata<Player>(L, 1);
^
/root/Otxserver-New/src/luascript.cpp:126:22: error: ‘isNumber’ was not declared in this scope
if (isNumber(L, 2)) {
^
/root/Otxserver-New/src/luascript.cpp:127:18: error: ‘getNumber’ was not declared in this scope
itemId = getNumber<uint16_t>(L, 2);
^
/root/Otxserver-New/src/luascript.cpp:127:36: error: expected primary-expression before ‘>’ token
itemId = getNumber<uint16_t>(L, 2);
^
/root/Otxserver-New/src/luascript.cpp:127:41: error: left operand of comma operator has no effect [-Werror=unused-value]
itemId = getNumber<uint16_t>(L, 2);
^
/root/Otxserver-New/src/luascript.cpp:129:60: error: ‘getString’ was not declared in this scope
itemId = Item::items.getItemIdByName(getString(L, 2));
^
/root/Otxserver-New/src/luascript.cpp:137:28: error: ‘pushBoolean’ was not declared in this scope
pushBoolean(L, true);
^
/root/Otxserver-New/src/luascript.cpp:139:29: error: ‘pushBoolean’ was not declared in this scope
pushBoolean(L, false);
^
/root/Otxserver-New/src/luascript.cpp: In function ‘int luaPlayerGetAutoLootList(lua_State*)’:
/root/Otxserver-New/src/luascript.cpp:149:22: error: ‘getUserdata’ was not declared in this scope
Player* player = getUserdata<Player>(L, 1);
^
/root/Otxserver-New/src/luascript.cpp:149:40: error: expected primary-expression before ‘>’ token
Player* player = getUserdata<Player>(L, 1);
^
/root/Otxserver-New/src/luascript.cpp:149:45: error: left operand of comma operator has no effect [-Werror=unused-value]
Player* player = getUserdata<Player>(L, 1);
^
In file included from /root/Otxserver-New/src/luascript.cpp:26:0:
/root/Otxserver-New/src/player.h:1380:22: error: ‘std::set<unsigned int> Player::autoLootList’ is protected
std::set<uint32_t> autoLootList;
^
/root/Otxserver-New/src/luascript.cpp:152:44: error: within this context
std::set<uint32_t> value = player->autoLootList;
^
man, you wrong! The files area luascript.cpp and h