mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
Remove CreateCorpse, Improve Ban()
This commit is contained in:
@@ -1935,16 +1935,17 @@ namespace LuaGlobalFunctions
|
||||
*
|
||||
* enum BanMode
|
||||
* {
|
||||
* BAN_ACCOUNT,
|
||||
* BAN_CHARACTER,
|
||||
* BAN_IP
|
||||
* BAN_ACCOUNT = 0,
|
||||
* BAN_CHARACTER = 1,
|
||||
* BAN_IP = 2
|
||||
* };
|
||||
*
|
||||
* @param [BanMode] banMode : method of ban, refer to BanMode above
|
||||
* @param string nameOrIP : name of the [Player] or IP of the [Player]
|
||||
* @param string nameOrIP : If BanMode is 0 then accountname, if 1 then charactername if 2 then ip
|
||||
* @param uint32 duration : duration (in seconds) of the ban
|
||||
* @param string reason = "" : ban reason, this is optional
|
||||
* @param string whoBanned = "" : the [Player]'s name that banned the account, character or IP, this is optional
|
||||
* @return int result : status of the ban. 0 if success, 1 if syntax error, 2 if target not found, 3 if ban already exists, nil if unknown result
|
||||
*/
|
||||
int Ban(lua_State* L)
|
||||
{
|
||||
@@ -1954,47 +1955,72 @@ namespace LuaGlobalFunctions
|
||||
const char* reason = Eluna::CHECKVAL<const char*>(L, 4, "");
|
||||
const char* whoBanned = Eluna::CHECKVAL<const char*>(L, 5, "");
|
||||
|
||||
const int BAN_ACCOUNT = 0;
|
||||
const int BAN_CHARACTER = 1;
|
||||
const int BAN_IP = 2;
|
||||
|
||||
BanMode mode = BanMode::BAN_ACCOUNT;
|
||||
|
||||
switch (banMode)
|
||||
{
|
||||
case BAN_ACCOUNT:
|
||||
#ifdef TRINITY
|
||||
if (!Utf8ToUpperOnlyLatin(nameOrIP))
|
||||
return 0;
|
||||
return luaL_argerror(L, 2, "invalid account name");
|
||||
#else
|
||||
if (!AccountMgr::normalizeString(nameOrIP))
|
||||
return 0;
|
||||
return luaL_argerror(L, 2, "invalid account name");
|
||||
#endif
|
||||
mode = BanMode::BAN_ACCOUNT;
|
||||
break;
|
||||
case BAN_CHARACTER:
|
||||
if (!normalizePlayerName(nameOrIP))
|
||||
return 0;
|
||||
return luaL_argerror(L, 2, "invalid character name");
|
||||
mode = BanMode::BAN_CHARACTER;
|
||||
break;
|
||||
case BAN_IP:
|
||||
if (!IsIPAddress(nameOrIP.c_str()))
|
||||
return 0;
|
||||
return luaL_argerror(L, 2, "invalid ip");
|
||||
mode = BanMode::BAN_IP;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
return luaL_argerror(L, 1, "unknown banmode");
|
||||
}
|
||||
|
||||
|
||||
BanReturn result;
|
||||
#ifndef AZEROTHCORE
|
||||
eWorld->BanAccount((BanMode)banMode, nameOrIP, duration, reason, whoBanned);
|
||||
result = eWorld->BanAccount(mode, nameOrIP, duration, reason, whoBanned);
|
||||
#else
|
||||
switch (banMode)
|
||||
{
|
||||
case BAN_ACCOUNT:
|
||||
sBan->BanAccount(nameOrIP, std::to_string(duration) + "s", reason, whoBanned);
|
||||
result = sBan->BanAccount(nameOrIP, std::to_string(duration) + "s", reason, whoBanned);
|
||||
break;
|
||||
case BAN_CHARACTER:
|
||||
sBan->BanAccountByPlayerName(nameOrIP, std::to_string(duration) + "s", reason, whoBanned);
|
||||
result = sBan->BanCharacter(nameOrIP, std::to_string(duration) + "s", reason, whoBanned);
|
||||
break;
|
||||
case BAN_IP:
|
||||
sBan->BanIP(nameOrIP, std::to_string(duration) + "s", reason, whoBanned);
|
||||
result = sBan->BanIP(nameOrIP, std::to_string(duration) + "s", reason, whoBanned);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case BanReturn::BAN_SUCCESS:
|
||||
Eluna::Push(L, 0);
|
||||
break;
|
||||
case BanReturn::BAN_SYNTAX_ERROR:
|
||||
Eluna::Push(L, 1);
|
||||
break;
|
||||
case BanReturn::BAN_NOTFOUND:
|
||||
Eluna::Push(L, 2);
|
||||
break;
|
||||
case BanReturn::BAN_EXISTS:
|
||||
Eluna::Push(L, 3);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -733,7 +733,6 @@ ElunaRegister<Player> PlayerMethods[] =
|
||||
{ "SpawnBones", &LuaPlayer::SpawnBones },
|
||||
{ "RemovedInsignia", &LuaPlayer::RemovedInsignia },
|
||||
{ "SendGuildInvite", &LuaPlayer::SendGuildInvite },
|
||||
{ "CreateCorpse", &LuaPlayer::CreateCorpse },
|
||||
{ "Mute", &LuaPlayer::Mute },
|
||||
{ "SummonPlayer", &LuaPlayer::SummonPlayer },
|
||||
{ "SaveToDB", &LuaPlayer::SaveToDB },
|
||||
|
||||
@@ -2213,15 +2213,6 @@ namespace LuaPlayer
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the [Player]'s corpse
|
||||
*/
|
||||
int CreateCorpse(lua_State* /*L*/, Player* player)
|
||||
{
|
||||
player->CreateCorpse();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewards the given quest entry for the [Player] if he has completed it.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user