lua question
Posted: Wed Feb 21, 2018 4:25 pm
so i have modified the SummonItem lusa function so that it accepts another parameter
so teh forth parmameter would be a string and can only be "bank" or it will be ignored
my modification is below
i do not think i did the compare of the state 4 correctly to see if it == "bank"
fwi i also created new functions in server for AddItemToBank(item_id, 1) so i know this works correctly
what would be the correct if statement for that
so teh forth parmameter would be a string and can only be "bank" or it will be ignored
my modification is below
Code: Select all
int EQ2Emu_lua_SummonItem(lua_State* state){
if(!lua_interface)
return 0;
Spawn* spawn = lua_interface->GetSpawn(state);
int32 item_id = lua_interface->GetInt32Value(state, 2);
bool send_messages = (lua_interface->GetInt8Value(state, 3) == 1);
if (spawn && spawn->IsPlayer()){
Client* client = spawn->GetZone()->GetClientBySpawn(spawn);
if (client && item_id > 0){
if (lua_interface->GetStringValue(state, 4) == "bank")
lua_interface->SetBooleanValue(state, client->AddItemToBank(item_id, 1));
else
lua_interface->SetBooleanValue(state, client->AddItem(item_id, 1));
if (send_messages) {
Item* item = master_item_list.GetItem(item_id);
if (item) {
client->Message(CHANNEL_COLOR_YELLOW, "You receive \\aITEM %u 0:%s\\/a.", item->details.item_id, item->name.c_str());
string popup_text = "You receive " + item->name;
client->SendPopupMessage(10, popup_text.c_str(), "ui_harvested_normal", 3, 0xFF, 0xFF, 0xFF);
}
}
return 1;
}
}
lua_interface->SetBooleanValue(state, false);
return 1;
}Code: Select all
if (lua_interface->GetStringValue(state, 4) == "bank")
lua_interface->SetBooleanValue(state, client->AddItemToBank(item_id, 1));
else
lua_interface->SetBooleanValue(state, client->AddItem(item_id, 1));what would be the correct if statement for that