diff --git a/GlobalMethods.h b/GlobalMethods.h index 3f1bd70..e77238b 100644 --- a/GlobalMethods.h +++ b/GlobalMethods.h @@ -926,15 +926,15 @@ namespace LuaGlobalFunctions int SendMail(lua_State* L) { int i = 0; - std::string subject = luaL_checkstring(L, ++i); - std::string text = luaL_checkstring(L, ++i); - uint32 receiverGUIDLow = luaL_checkunsigned(L, ++i); - Player* senderPlayer = sEluna->CHECKOBJ(L, ++i); - uint32 stationary = luaL_optunsigned(L, ++i, MAIL_STATIONERY_DEFAULT); - uint32 delay = luaL_optunsigned(L, ++i, 0); - int32 argAmount = lua_gettop(L); + std::string subject = sEluna->CHECKVAL(L, ++i); + std::string text = sEluna->CHECKVAL(L, ++i); + uint32 receiverGUIDLow = sEluna->CHECKVAL(L, ++i); + uint32 senderGUIDLow = sEluna->CHECKVAL(L, ++i, 0); + uint32 stationary = sEluna->CHECKVAL(L, ++i, MAIL_STATIONERY_DEFAULT); + uint32 delay = sEluna->CHECKVAL(L, ++i, 0); + int argAmount = lua_gettop(L); - MailSender sender(MAIL_NORMAL, senderPlayer ? senderPlayer->GetGUIDLow() : 0, (MailStationery)stationary); + MailSender sender(MAIL_NORMAL, senderGUIDLow, (MailStationery)stationary); MailDraft draft(subject, text); #ifndef MANGOS @@ -961,7 +961,7 @@ namespace LuaGlobalFunctions luaL_error(L, "Item entry %d has invalid amount %d", entry, amount); continue; } - if (Item* item = Item::CreateItem(entry, amount, senderPlayer ? senderPlayer : 0)) + if (Item* item = Item::CreateItem(entry, amount)) { #ifdef MANGOS item->SaveToDB(); diff --git a/LuaFunctions.cpp b/LuaFunctions.cpp index daa8528..5408465 100644 --- a/LuaFunctions.cpp +++ b/LuaFunctions.cpp @@ -92,7 +92,7 @@ void RegisterGlobals(lua_State* L) lua_register(L, "Kick", &LuaGlobalFunctions::Kick); // Kick(player) - Kicks given player lua_register(L, "Ban", &LuaGlobalFunctions::Ban); // Ban(banMode(integer), nameOrIP(string), duration(string), reason(string), player(whoBanned)) - Banmode: 0 account, 1 character, 2 IP lua_register(L, "SaveAllPlayers", &LuaGlobalFunctions::SaveAllPlayers); // SaveAllPlayers() - Saves all players - lua_register(L, "SendMail", &LuaGlobalFunctions::SendMail); // SendMail(subject, text, receiverLowGUID[, sender, stationary, delay, itemEntry, itemAmount, itemEntry2, itemAmount2...]) - Sends a mail to player with lowguid. use nil to use default values on optional arguments. Sender is an optional player object. UNDOCUMENTED + lua_register(L, "SendMail", &LuaGlobalFunctions::SendMail); // SendMail(subject, text, receiverLowGUID[, senderLowGUID, stationary, delay, itemEntry, itemAmount, itemEntry2, itemAmount2...]) - Sends a mail to player with lowguid. use nil to use default values on optional arguments. UNDOCUMENTED lua_register(L, "AddTaxiPath", &LuaGlobalFunctions::AddTaxiPath); // AddTaxiPath(pathTable, mountA, mountH[, price, pathId]) - Adds a new taxi path. Returns the path's ID. Will replace an existing path if pathId provided and already used. path table structure: T = {{map, x, y, z[, actionFlag, delay, arrivalEvId, departEvId]}, {...}, ...} UDOCUMENTED lua_register(L, "AddCorpse", &LuaGlobalFunctions::AddCorpse); // AddCorpse(corpse) - Adds the player's corpse to the world. More specifically, the cell. lua_register(L, "RemoveCorpse", &LuaGlobalFunctions::RemoveCorpse); // RemoveCorpse(corpse) - Removes the player's corpse from the world.