static bool PWarnRemoveName(ChatHandler* handler, const char* args) { if(!*args) return false; char* name = strtok((char*)args, " "); if(!PlayerExists(handler, name)) { sendCMDError(handler, "Player not found"); return false; } if(!WarnNameExists(handler, name)) { sendCMDError(handler, "This player does not have any warnings"); handler->SetSentErrorMessage(true); return false; } CharacterDatabase.PExecute("DELETE FROM `player_warnings` WHERE `reported`='%s'", name); handler->PSendSysMessage("All %s's warnings removed", name); return true; }
bool Socket::HandleNameInput() { Player* mob = nullptr; std::string input; World* world = World::GetPtr(); Server* server = world->GetServer(); input = PopCommand(); //new player: if (input=="new") { Write("Welcome, what name would you like?\n"); AllocatePlayer(); mob = GetPlayer(); SetConnectionType(CON_Newname); return true; } //checks to see if the username is valid if (!IsValidUserName(input)) { Write("Invalid name, try again.\n"); return true; } //check to see if the player exists if (!PlayerExists(input)) { Write("That player doesn't exist.\nWhat is your name? Type new for a new character.\n"); return true; } mob = server->GetLinkdeadUser(input); if (mob) { _mobile = mob; Write(TELNET_ECHO_OFF); Write("\n"); Write("Password?\n"); SetConnectionType(CON_Password); return true; } AllocatePlayer(); mob = GetPlayer(); //set the players name to the one specified and try to load the file. mob->SetName(input); mob->Load(); Write(TELNET_ECHO_OFF); Write("\n"); Write("Password?\n"); SetConnectionType(CON_Password); return true; }
void Adventure::AddPlayer(string character_name, bool add_client_to_instance) { if(!PlayerExists(character_name)) { int client_id = database.GetCharacterID(character_name.c_str()); if(add_client_to_instance) { database.AddClientToInstance(instance_id, client_id); } players.push_back(character_name); } }
bool Socket::HandleNameInput() { Player* mob = nullptr; std::string input; //we associate a player with the socket object so we can store data and later load. AllocatePlayer(); mob = GetPlayer(); input = PopCommand(); //new player: if (input=="new") { Write("Welcome, what name would you like?\n"); SetConnectionType(ConnectionType::Newname); return true; } //checks to see if the username is valid if (!IsValidUserName(input)) { Write("Invalid name, try again.\n"); return true; } //check to see if the player exists if (!PlayerExists(input)) { Write("That player doesn't exist.\nWhat is your name? Type new for a new character.\n"); return true; } //set the players name to the one specified and try to load the file. mob->SetName(input); mob->Load(); Write(TELNET_ECHO_OFF); Write("\n"); Write("Password?\n"); SetConnectionType(ConnectionType::Password); return true; }
static bool PWarnListName(ChatHandler* handler, const char* args) { if(!*args) return false; char* plrname = strtok((char*)args, " "); if(!PlayerExists(handler, plrname)) { sendCMDError(handler, "Player not found"); return false; } handler->PSendSysMessage("Displaying all %s's warnings:", plrname); if(!GetWarnList(handler, 2, plrname)) { sendCMDError(handler, "|cffFF0000NULL|r"); return false; } return true; }
bool Socket::HandleNewnameInput() { std::string input; Player* mobile = GetPlayer(); input = PopCommand(); if (!IsValidUserName(input)) { Write("That is not a valid username. Usernames must contain 4-12 characters.\nWhat name would you like?\n"); return true; } if (PlayerExists(input)) { Write("That player already exists, please try again.\nWhat name would you like?\n"); return true; } Write("Please choose a password. Please make your password between 5 and 20 characters long.\nStrong passwords contain both lower and uppercase letters, numbers, letters and a dash ('-').\nEnter your new password?\n"); Write(TELNET_ECHO_OFF); //name was valid, set it in the player class. mobile->SetName(input); SetConnectionType(ConnectionType::Newpass); return true; }
static bool PWarnPlayer(ChatHandler* handler, const char* args) { if(!*args) return false; uint8 priorityAsID; Player* player = handler->GetSession()->GetPlayer(); char* plrname = strtok((char*)args, " "); char* tail = *args == '"' ? (char*)args : strtok(NULL, ""); if (!tail) return false; char* reason = handler->extractQuotedArg(tail); char* priority = strtok(NULL, " "); if(player->GetName() == plrname) { sendCMDError(handler, "You can't warn yourself"); return false; } if(!PlayerExists(handler, plrname)) { sendCMDError(handler, "Player not found"); return false; } if(!reason) { sendCMDError(handler, "Warning a player requires a reason and must be between quotes"); return false; } if(!priority) { sendCMDError(handler, "You forgot to set warning priority"); return false; } if(!CheckIfReportedSamePlayer(player, plrname)) { sendCMDError(handler, "You alrady warned this player"); return false; } if(!atoi(priority)) { sendCMDError(handler, "Priority must be a numeric number"); handler->SetSentErrorMessage(true); return false; } priorityAsID = atoi(priority); if(priorityAsID < 0 || priorityAsID > 3) { sendCMDError(handler, "Priority must be between 1 and 3 concerning low, medium or high"); return false; } switch(priorityAsID) { case 1: priority = "low"; break; case 2: priority = "medium"; break; case 3: priority = "high"; break; } InsertWarnInDB(player, plrname, reason, priorityAsID); SendGlobalAnnounce(player, plrname, reason); handler->PSendSysMessage("Player [%s] warned for \'%s\' with %s priority.", plrname, reason, priority); return true; }