void CGameContext::ConTogglePause(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *) pUserData; if (!CheckClientID(pResult->m_ClientID)) return; char aBuf[128]; if(!g_Config.m_SvPauseable) { ConToggleSpec(pResult, pUserData); return; } CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID]; if (!pPlayer) return; if (pPlayer->GetCharacter() == 0) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "pause", "You can't pause while you are dead/a spectator."); return; } if (pPlayer->m_Paused == CPlayer::PAUSED_SPEC && g_Config.m_SvPauseable) { ConToggleSpec(pResult, pUserData); return; } if (pPlayer->m_Paused == CPlayer::PAUSED_FORCE) { str_format(aBuf, sizeof(aBuf), "You are force-paused. %ds left.", pPlayer->m_ForcePauseTime/pSelf->Server()->TickSpeed()); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "pause", aBuf); return; } pPlayer->m_Paused = (pPlayer->m_Paused == CPlayer::PAUSED_PAUSED) ? CPlayer::PAUSED_NONE : CPlayer::PAUSED_PAUSED; }
void CGameContext::ConSetTeamAll(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; int Team = clamp(pResult->GetInteger(0), -1, 1); char aBuf[256]; str_format(aBuf, sizeof(aBuf), "moved all clients to team %d", Team); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); for(int i = 0; i < MAX_CLIENTS; ++i) if(pSelf->m_apPlayers[i]) pSelf->m_apPlayers[i]->SetTeam(Team); (void)pSelf->m_pController->CheckTeamBalance(); }
void CGameContext::ConMap(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *) pUserData; if (!CheckClientID(pResult->m_ClientID)) return; if (g_Config.m_SvMapVote == 0) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "map", "Admin has disabled /map"); return; } if (pResult->NumArguments() <= 0) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "map", "Example: /map adr3 to call vote for Adrenaline 3. This means that the map name must start with 'a' and contain the characters 'd', 'r' and '3' in that order"); return; } CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID]; if (!pPlayer) return; #if defined(CONF_SQL) if(g_Config.m_SvUseSQL) if(pPlayer->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick()) return; #endif pSelf->Score()->MapVote(pResult->m_ClientID, pResult->GetString(0)); #if defined(CONF_SQL) if(g_Config.m_SvUseSQL) pPlayer->m_LastSQLQuery = pSelf->Server()->Tick(); #endif }
void CGameContext::ConSetTeam(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; int ClientID = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1); int Team = clamp(pResult->GetInteger(1), -1, 1); int Delay = pResult->NumArguments()>2 ? pResult->GetInteger(2) : 0; if(!pSelf->m_apPlayers[ClientID]) return; char aBuf[256]; str_format(aBuf, sizeof(aBuf), "moved client %d to team %d", ClientID, Team); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); pSelf->m_apPlayers[ClientID]->m_TeamChangeTick = pSelf->Server()->Tick()+pSelf->Server()->TickSpeed()*Delay*60; pSelf->m_pController->DoTeamChange(pSelf->m_apPlayers[ClientID], Team); }
void CGameContext::ConVote(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; // check if there is a vote running if(!pSelf->m_VoteCloseTime) return; if(str_comp_nocase(pResult->GetString(0), "yes") == 0) pSelf->m_VoteEnforce = CGameContext::VOTE_ENFORCE_YES; else if(str_comp_nocase(pResult->GetString(0), "no") == 0) pSelf->m_VoteEnforce = CGameContext::VOTE_ENFORCE_NO; char aBuf[256]; str_format(aBuf, sizeof(aBuf), "forcing vote %s", pResult->GetString(0)); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); }
void CGameContext::ConSetTeam(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; int ClientID = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1); int Team = clamp(pResult->GetInteger(1), -1, 1); char aBuf[256]; str_format(aBuf, sizeof(aBuf), "moved client %d to team %d", ClientID, Team); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); if(!pSelf->m_apPlayers[ClientID]) return; pSelf->m_apPlayers[ClientID]->SetTeam(Team); (void)pSelf->m_pController->CheckTeamBalance(); }
void CGameContext::ConToggleFly(IConsole::IResult *pResult, void *pUserData) { if(!CheckClientID(pResult->m_ClientID)) return; CGameContext *pSelf = (CGameContext *)pUserData; CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID]; if(!pPlayer) return; CCharacter* pChr = pPlayer->GetCharacter(); if(!pChr) return; if(pChr->m_Super) { pChr->m_Fly = !pChr->m_Fly; pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", (pChr->m_Fly) ? "Fly enabled" : "Fly disabled"); } }
void CGameContext::ConVis(IConsole::IResult *pResult, void *pUserData) { if(!CheckRights(pResult->m_ClientID, pResult->GetVictim(), (CGameContext *)pUserData)) return; CGameContext *pSelf = (CGameContext *)pUserData; int Victim = pResult->GetVictim(); if(!pSelf->m_apPlayers[pResult->m_ClientID]) return; char aBuf[128]; if(pSelf->m_apPlayers[Victim]) { pSelf->m_apPlayers[Victim]->m_Invisible = false; CServer* pServ = (CServer*)pSelf->Server(); str_format(aBuf, sizeof(aBuf), "'%s' ClientID=%d is visible.", pServ->ClientName(Victim), Victim); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", aBuf); } }
// unmute by mute list index void CGameContext::ConUnmute(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *) pUserData; char aIpBuf[64]; char aBuf[64]; int Victim = pResult->GetVictim(); if (Victim < 0 || Victim >= pSelf->m_NumMutes) return; pSelf->m_NumMutes--; pSelf->m_aMutes[Victim] = pSelf->m_aMutes[pSelf->m_NumMutes]; net_addr_str(&pSelf->m_aMutes[Victim].m_Addr, aIpBuf, sizeof(aIpBuf)); str_format(aBuf, sizeof(aBuf), "Unmuted %s", aIpBuf); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "mutes", aBuf); }
void CGameContext::ConCredits(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *) pUserData; pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "DDRaceNetwork is maintained by deen."); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "Many ideas from the great community,"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "Help and code by eeeee, HMH, east, CookieMichal, Learath2,"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "Savander, laxa, Tobii, BeaR, Wohoo, nuborn, timakro, Shiki,"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "trml, Soreu, hi_leute_gll, Lady Saavik, Chairn, heinrich5991,"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "swick, oy & others."); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "Based on DDRace by the DDRace developers,"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "which is a mod of Teeworlds by the Teeworlds developers."); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "Check the changes on ddnet.tw"); }
void CGameContext::ConSayTime(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *) pUserData; if (!CheckClientID(pResult->m_ClientID)) return; int ClientID; char aBufname[MAX_NAME_LENGTH]; if (pResult->NumArguments() > 0) { for(ClientID = 0; ClientID < MAX_CLIENTS; ClientID++) if (str_comp(pResult->GetString(0), pSelf->Server()->ClientName(ClientID)) == 0) break; if(ClientID == MAX_CLIENTS) return; str_format(aBufname, sizeof(aBufname), "%s's", pSelf->Server()->ClientName(ClientID)); } else { str_copy(aBufname, "Your", sizeof(aBufname)); ClientID = pResult->m_ClientID; } CPlayer *pPlayer = pSelf->m_apPlayers[ClientID]; if (!pPlayer) return; CCharacter* pChr = pPlayer->GetCharacter(); if (!pChr) return; if(pChr->m_DDRaceState != DDRACE_STARTED) return; char aBuftime[64]; int IntTime = (int) ((float) (pSelf->Server()->Tick() - pChr->m_StartTime) / ((float) pSelf->Server()->TickSpeed())); str_format(aBuftime, sizeof(aBuftime), "%s time is %s%d:%s%d", aBufname, ((IntTime / 60) > 9) ? "" : "0", IntTime / 60, ((IntTime % 60) > 9) ? "" : "0", IntTime % 60); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "time", aBuftime); }
void CGameContext::ConCredits(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *) pUserData; pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "Teeworlds Team takes most of the credits also"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "This mod was originally created by \'3DA\'"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "Now it is maintained & re-coded by:"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "\'[Egypt]GreYFoX@GTi\' and \'[BlackTee]den\'"); pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "credit", "Others Helping on the code: \'heinrich5991\', \'ravomavain\', \'Trust o_0 Aeeeh ?!\', \'noother\', \'<3 fisted <3\' & \'LemonFace\'"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "Documentation: Zeta-Hoernchen & Learath2, Entities: Fisico"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "Code (in the past): \'3DA\' and \'Fluxid\'"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "XXLDDRace by XXLTomate. mkRace by z and disarmer"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "Visit www.disarmer.ru for more information."); }
void CGameContext::ConMe(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *) pUserData; if (!CheckClientID(pResult->m_ClientID)) return; char aBuf[256 + 24]; str_format(aBuf, 256 + 24, "'%s' %s", pSelf->Server()->ClientName(pResult->m_ClientID), pResult->GetString(0)); if (g_Config.m_SvSlashMe) pSelf->SendChat(-2, CGameContext::CHAT_ALL, aBuf, pResult->m_ClientID); else pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "me", "/me is disabled on this server, admin can enable it by using sv_slash_me"); }
//XXLmod void CGameContext::ConSkin(IConsole::IResult *pResult, void *pUserData) { if(!CheckRights(pResult->m_ClientID, pResult->GetVictim(), (CGameContext *)pUserData)) return; const char *Skin = pResult->GetString(0); CGameContext *pSelf = (CGameContext *)pUserData; int Victim = pResult->GetVictim(); CPlayer *pPlayer = pSelf->m_apPlayers[Victim]; if(!pPlayer) return; CCharacter* pChr = pSelf->m_apPlayers[Victim]->GetCharacter();; if(!pChr) return; //change skin str_copy(pSelf->m_apPlayers[Victim]->m_TeeInfos.m_SkinName, Skin, sizeof(pSelf->m_apPlayers[Victim]->m_TeeInfos.m_SkinName)); char aBuf[256]; str_format(aBuf, sizeof(aBuf), "%s's skin changed to %s" ,pSelf->Server()->ClientName(Victim), Skin); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", aBuf); }
void CGameContext::ConCredits(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *) pUserData; pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "TBlock is maintained by [Hamid Jigool] on WwW.TeeCity.iR."); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "Many ideas from the TeeCity community,"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "Help and code by FuroS, AlirezaKaj,"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "and GoD"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "Based on DDNet & XXLTomate by the DDrace developers,"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "which is a mod of Teeworlds by the Teeworlds developers."); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "credit", "Check the changes on TeeCity.iR"); }
void CGameContext::ConInfo(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *) pUserData; pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", "mkRace rev. " GIT_SHORTREV_HASH); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", "mkRace based on XXLDDRace mod by XXLTomate"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", "DDRace Mod. Version: " DDRACE_VERSION); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", "XXLDDRace Mod. Version: " XXL_VERSION); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", "Visit disarmer.ru"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", "For commands /cmdlist"); }
void CGameContext::ConPrivMsg(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *) pUserData; int to = pResult->GetVictim(); if(!CheckClientID(to)) return; if(CheckClientID(pResult->m_ClientID) && pSelf->ProcessSpamProtection(pResult->m_ClientID)) return; char message[512]; str_format(message, sizeof(message), "PM -> %s: ", pSelf->Server()->ClientName(to)); str_append(message, pResult->GetString(0), sizeof(message)); CNetMsg_Sv_Chat Msg; Msg.m_Team = 1; Msg.m_ClientID = CheckClientID(pResult->m_ClientID) ? pResult->m_ClientID : -1; Msg.m_pMessage = message; pSelf->Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, to); if(CheckClientID(pResult->m_ClientID)) { pSelf->Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, pResult->m_ClientID); str_format(message, sizeof(message), "\"%s\" -> \"%s\" : %s", pSelf->Server()->ClientName(pResult->m_ClientID), pSelf->Server()->ClientName(to), pResult->GetString(0)); } else { str_format(message, sizeof(message), "%d -> \"%s\" : %s", pResult->m_ClientID, pSelf->Server()->ClientName(to), pResult->GetString(0)); } pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "pmchat", message); }
void CGameContext::ConShowOthers(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *) pUserData; if (!CheckClientID(pResult->m_ClientID)) return; CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID]; if (!pPlayer) return; if (g_Config.m_SvShowOthers) { if (pResult->NumArguments()) pPlayer->m_ShowOthers = pResult->GetInteger(0); else pPlayer->m_ShowOthers = !pPlayer->m_ShowOthers; } else pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "showotherschat", "Showing players from other teams is disabled by the server admin"); }
void CGameContext::ConSayTime(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *) pUserData; if (!CheckClientID(pResult->m_ClientID)) return; CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID]; if (!pPlayer) return; CCharacter* pChr = pPlayer->GetCharacter(); if (!pChr) return; if(pChr->m_DDRaceState != DDRACE_STARTED) return; char aBuftime[64]; int IntTime = (int) ((float) (pSelf->Server()->Tick() - pChr->m_StartTime) / ((float) pSelf->Server()->TickSpeed())); str_format(aBuftime, sizeof(aBuftime), "Your Time is %s%d:%s%d", ((IntTime / 60) > 9) ? "" : "0", IntTime / 60, ((IntTime % 60) > 9) ? "" : "0", IntTime % 60); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "time", aBuftime); }
void CGameContext::ConHelp(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *) pUserData; if (pResult->NumArguments() == 0) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "help", "/cmdlist will show a list of all chat commands"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "help", "/help + any command will show you the help for this command"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "help", "Example /help settings will display the help about "); } else { const char *pArg = pResult->GetString(0); const IConsole::CCommandInfo *pCmdInfo = pSelf->Console()->GetCommandInfo(pArg, CFGFLAG_SERVER, false); if (pCmdInfo) { if (pCmdInfo->m_pParams) { char aBuf[256]; str_format(aBuf, sizeof(aBuf), "Usage: %s %s", pCmdInfo->m_pName, pCmdInfo->m_pParams); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "help", aBuf); } if (pCmdInfo->m_pHelp) pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "help", pCmdInfo->m_pHelp); } else pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "help", "Command is either unknown or you have given a blank command without any parameters."); } }
void CGameContext::ConRemoveVote(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; const char *pDescription = pResult->GetString(0); // check for valid option CVoteOptionServer *pOption = pSelf->m_pVoteOptionFirst; while(pOption) { if(str_comp_nocase(pDescription, pOption->m_aDescription) == 0) break; pOption = pOption->m_pNext; } if(!pOption) { char aBuf[256]; str_format(aBuf, sizeof(aBuf), "option '%s' does not exist", pDescription); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); return; } // inform clients about removed option CNetMsg_Sv_VoteOptionRemove OptionMsg; OptionMsg.m_pDescription = pOption->m_aDescription; pSelf->Server()->SendPackMsg(&OptionMsg, MSGFLAG_VITAL, -1); // TODO: improve this // remove the option --pSelf->m_NumVoteOptions; char aBuf[256]; str_format(aBuf, sizeof(aBuf), "removed option '%s' '%s'", pOption->m_aDescription, pOption->m_aCommand); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); CHeap *pVoteOptionHeap = new CHeap(); CVoteOptionServer *pVoteOptionFirst = 0; CVoteOptionServer *pVoteOptionLast = 0; int NumVoteOptions = pSelf->m_NumVoteOptions; for(CVoteOptionServer *pSrc = pSelf->m_pVoteOptionFirst; pSrc; pSrc = pSrc->m_pNext) { if(pSrc == pOption) continue; // copy option int Len = str_length(pSrc->m_aCommand); CVoteOptionServer *pDst = (CVoteOptionServer *)pVoteOptionHeap->Allocate(sizeof(CVoteOptionServer) + Len); pDst->m_pNext = 0; pDst->m_pPrev = pVoteOptionLast; if(pDst->m_pPrev) pDst->m_pPrev->m_pNext = pDst; pVoteOptionLast = pDst; if(!pVoteOptionFirst) pVoteOptionFirst = pDst; str_copy(pDst->m_aDescription, pSrc->m_aDescription, sizeof(pDst->m_aDescription)); mem_copy(pDst->m_aCommand, pSrc->m_aCommand, Len+1); } // clean up delete pSelf->m_pVoteOptionHeap; pSelf->m_pVoteOptionHeap = pVoteOptionHeap; pSelf->m_pVoteOptionFirst = pVoteOptionFirst; pSelf->m_pVoteOptionLast = pVoteOptionLast; pSelf->m_NumVoteOptions = NumVoteOptions; }
void CGameContext::ConJoinTeam(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *) pUserData; if (!CheckClientID(pResult->m_ClientID)) return; CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID]; if (pSelf->m_VoteCloseTime && pSelf->m_VoteCreator == pResult->m_ClientID) { pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "join", "You are running a vote please try again after the vote is done!"); return; } else if (g_Config.m_SvTeam == 0) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join", "Admin has disabled teams"); return; } else if (g_Config.m_SvTeam == 2 && pResult->GetInteger(0) == 0 && pPlayer->GetCharacter()->m_LastStartWarning < pSelf->Server()->Tick() - 3 * pSelf->Server()->TickSpeed()) { pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "join", "You must join a team and play with somebody or else you can\'t play"); pPlayer->GetCharacter()->m_LastStartWarning = pSelf->Server()->Tick(); } if (pResult->NumArguments() > 0) { if (pPlayer->GetCharacter() == 0) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join", "You can't change teams while you are dead/a spectator."); } else { CGameTeams& teams = ((CGameControllerDDRace*) pSelf->m_pController)->m_Teams; int team = pResult->GetInteger(0); if (pPlayer->m_Last_Team + pSelf->Server()->TickSpeed() * g_Config.m_SvTeamChangeDelay > pSelf->Server()->Tick()) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join", "You can\'t change teams that fast!"); } else { if(team < 10) { if(team == 0 && teams.m_Core.Team(pPlayer->GetCID()) >= 10) { pPlayer->GetCharacter()->Teams()->m_Core.Team(pPlayer->GetCID(), team); } else if (teams.SetCharacterTeam(pPlayer->GetCID(), team)) { char aBuf[512]; str_format(aBuf, sizeof(aBuf), "%s joined team %d", pSelf->Server()->ClientName(pPlayer->GetCID()), team); pSelf->SendChat(-1, CGameContext::CHAT_ALL, aBuf); pPlayer->m_Last_Team = pSelf->Server()->Tick(); } else { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join", "You cannot join this team"); } } else if(team < MAX_CLIENTS && (teams.m_Core.Team(pPlayer->GetCID()) >= 10 || teams.m_Core.Team(pPlayer->GetCID()) == 0)) { pPlayer->GetCharacter()->Teams()->m_Core.Team(pPlayer->GetCID(), team); } else { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join", "You cannot join this team"); } } } } else { char aBuf[512]; if (!pPlayer->IsPlaying()) { pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "join", "You can't check your team while you are dead/a spectator."); } else { str_format( aBuf, sizeof(aBuf), "You are in team %d", ((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.m_Core.Team( pResult->m_ClientID)); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join", aBuf); } } }
void CGameContext::ConRules(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *) pUserData; bool Printed = false; if (g_Config.m_SvDDRaceRules) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", "Be nice."); Printed = true; } if (g_Config.m_SvRulesLine1[0]) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine1); Printed = true; } if (g_Config.m_SvRulesLine2[0]) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine2); Printed = true; } if (g_Config.m_SvRulesLine3[0]) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine3); Printed = true; } if (g_Config.m_SvRulesLine4[0]) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine4); Printed = true; } if (g_Config.m_SvRulesLine5[0]) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine5); Printed = true; } if (g_Config.m_SvRulesLine6[0]) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine6); Printed = true; } if (g_Config.m_SvRulesLine7[0]) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine7); Printed = true; } if (g_Config.m_SvRulesLine8[0]) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine8); Printed = true; } if (g_Config.m_SvRulesLine9[0]) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine9); Printed = true; } if (g_Config.m_SvRulesLine10[0]) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine10); Printed = true; } if (!Printed) pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", "No Rules Defined, Kill em all!!"); }
void CGameContext::ConSettings(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *) pUserData; if (pResult->NumArguments() == 0) { pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "setting", "to check a server setting say /settings and setting's name, setting names are:"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "setting", "teams, cheats, collision, hooking, endlesshooking, me, "); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "setting", "hitting, oldlaser, timeout, votes, pause and scores"); } else { const char *pArg = pResult->GetString(0); char aBuf[256]; float ColTemp; float HookTemp; pSelf->m_Tuning.Get("player_collision", &ColTemp); pSelf->m_Tuning.Get("player_hooking", &HookTemp); if (str_comp(pArg, "teams") == 0) { str_format( aBuf, sizeof(aBuf), "%s %s", g_Config.m_SvTeam == 1 ? "Teams are available on this server" : (g_Config.m_SvTeam == 0 || g_Config.m_SvTeam == 3) ? "Teams are not available on this server" : "You have to be in a team to play on this server", /*g_Config.m_SvTeamStrict ? "and if you die in a team all of you die" : */ "and if you die in a team only you die"); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "settings", aBuf); } else if (str_comp(pArg, "collision") == 0) { pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "settings", ColTemp ? "Players can collide on this server" : "Players Can't collide on this server"); } else if (str_comp(pArg, "hooking") == 0) { pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "settings", HookTemp ? "Players can hook each other on this server" : "Players Can't hook each other on this server"); } else if (str_comp(pArg, "endlesshooking") == 0) { pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "settings", g_Config.m_SvEndlessDrag ? "Players can hook time is unlimited" : "Players can hook time is limited"); } else if (str_comp(pArg, "hitting") == 0) { pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "settings", g_Config.m_SvHit ? "Player's weapons affect each other" : "Player's weapons has no affect on each other"); } else if (str_comp(pArg, "oldlaser") == 0) { pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "settings", g_Config.m_SvOldLaser ? "Lasers can hit you if you shot them and that they pull you towards the bounce origin (Like DDRace Beta)" : "Lasers can't hit you if you shot them, and they pull others towards the shooter"); } else if (str_comp(pArg, "me") == 0) { pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "settings", g_Config.m_SvSlashMe ? "Players can use /me commands the famous IRC Command" : "Players Can't use the /me command"); } else if (str_comp(pArg, "timeout") == 0) { str_format(aBuf, sizeof(aBuf), "The Server Timeout is currently set to %d seconds", g_Config.m_ConnTimeout); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "settings", aBuf); } else if (str_comp(pArg, "votes") == 0) { pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "settings", g_Config.m_SvVoteKick ? "Players can use Callvote menu tab to kick offenders" : "Players Can't use the Callvote menu tab to kick offenders"); if (g_Config.m_SvVoteKick) str_format( aBuf, sizeof(aBuf), "Players are banned for %d second(s) if they get voted off", g_Config.m_SvVoteKickBantime); pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "settings", g_Config.m_SvVoteKickBantime ? aBuf : "Players are just kicked and not banned if they get voted off"); } else if (str_comp(pArg, "pause") == 0) { pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "settings", g_Config.m_SvPauseable ? g_Config.m_SvPauseTime ? "/pause is available on this server and it pauses your time too" : "/pause is available on this server but it doesn't pause your time" :"/pause is NOT available on this server"); } else if (str_comp(pArg, "scores") == 0) { pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "settings", g_Config.m_SvHideScore ? "Scores are private on this server" : "Scores are public on this server"); } } }
void CGameContext::ConAddVote(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; const char *pDescription = pResult->GetString(0); const char *pCommand = pResult->GetString(1); if(pSelf->m_NumVoteOptions == MAX_VOTE_OPTIONS) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "maximum number of vote options reached"); return; } // check for valid option if(!pSelf->Console()->LineIsValid(pCommand) || str_length(pCommand) >= VOTE_CMD_LENGTH) { char aBuf[256]; str_format(aBuf, sizeof(aBuf), "skipped invalid command '%s'", pCommand); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); return; } while(*pDescription && *pDescription == ' ') pDescription++; if(str_length(pDescription) >= VOTE_DESC_LENGTH || *pDescription == 0) { char aBuf[256]; str_format(aBuf, sizeof(aBuf), "skipped invalid option '%s'", pDescription); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); return; } // check for duplicate entry CVoteOptionServer *pOption = pSelf->m_pVoteOptionFirst; while(pOption) { if(str_comp_nocase(pDescription, pOption->m_aDescription) == 0) { char aBuf[256]; str_format(aBuf, sizeof(aBuf), "option '%s' already exists", pDescription); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); return; } pOption = pOption->m_pNext; } // add the option ++pSelf->m_NumVoteOptions; int Len = str_length(pCommand); pOption = (CVoteOptionServer *)pSelf->m_pVoteOptionHeap->Allocate(sizeof(CVoteOptionServer) + Len); pOption->m_pNext = 0; pOption->m_pPrev = pSelf->m_pVoteOptionLast; if(pOption->m_pPrev) pOption->m_pPrev->m_pNext = pOption; pSelf->m_pVoteOptionLast = pOption; if(!pSelf->m_pVoteOptionFirst) pSelf->m_pVoteOptionFirst = pOption; str_copy(pOption->m_aDescription, pDescription, sizeof(pOption->m_aDescription)); mem_copy(pOption->m_aCommand, pCommand, Len+1); char aBuf[256]; str_format(aBuf, sizeof(aBuf), "added option '%s' '%s'", pOption->m_aDescription, pOption->m_aCommand); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); // inform clients about added option CNetMsg_Sv_VoteOptionAdd OptionMsg; OptionMsg.m_pDescription = pOption->m_aDescription; pSelf->Server()->SendPackMsg(&OptionMsg, MSGFLAG_VITAL, -1); }
void CGameContext::ConJoinTeam(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *) pUserData; if (!CheckClientID(pResult->m_ClientID)) return; CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID]; if (!pPlayer) return; if (pSelf->m_VoteCloseTime && pSelf->m_VoteCreator == pResult->m_ClientID && (pSelf->m_VoteKick || pSelf->m_VoteSpec)) { pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "join", "You are running a vote please try again after the vote is done!"); return; } else if (g_Config.m_SvTeam == 0 || g_Config.m_SvTeam == 3) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join", "Admin has disabled teams"); return; } else if (g_Config.m_SvTeam == 2 && pResult->GetInteger(0) == 0 && pPlayer->GetCharacter() && pPlayer->GetCharacter()->m_LastStartWarning < pSelf->Server()->Tick() - 3 * pSelf->Server()->TickSpeed()) { pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "join", "You must join a team and play with somebody or else you can\'t play"); pPlayer->GetCharacter()->m_LastStartWarning = pSelf->Server()->Tick(); } if (pResult->NumArguments() > 0) { if (pPlayer->GetCharacter() == 0) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join", "You can't change teams while you are dead/a spectator."); } else { if (pPlayer->m_Last_Team + pSelf->Server()->TickSpeed() * g_Config.m_SvTeamChangeDelay > pSelf->Server()->Tick()) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join", "You can\'t change teams that fast!"); } else if(pResult->GetInteger(0) > 0 && pResult->GetInteger(0) < MAX_CLIENTS && ((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.TeamLocked(pResult->GetInteger(0))) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join", "This team is locked using /lock. Only members of the team can unlock it using /lock."); } else if(pResult->GetInteger(0) > 0 && pResult->GetInteger(0) < MAX_CLIENTS && ((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.Count(pResult->GetInteger(0)) >= g_Config.m_SvTeamMaxSize) { char aBuf[512]; str_format(aBuf, sizeof(aBuf), "This team already has the maximum allowed size of %d players", g_Config.m_SvTeamMaxSize); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join", aBuf); } else if (((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.SetCharacterTeam( pPlayer->GetCID(), pResult->GetInteger(0))) { char aBuf[512]; str_format(aBuf, sizeof(aBuf), "%s joined team %d", pSelf->Server()->ClientName(pPlayer->GetCID()), pResult->GetInteger(0)); pSelf->SendChat(-1, CGameContext::CHAT_ALL, aBuf); pPlayer->m_Last_Team = pSelf->Server()->Tick(); } else { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join", "You cannot join this team at this time"); } } } else { char aBuf[512]; if (!pPlayer->IsPlaying()) { pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "join", "You can't check your team while you are dead/a spectator."); } else { str_format( aBuf, sizeof(aBuf), "You are in team %d", ((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.m_Core.Team( pResult->m_ClientID)); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join", aBuf); } } }
void CGameContext::ConForceVote(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; const char *pType = pResult->GetString(0); const char *pValue = pResult->GetString(1); const char *pReason = pResult->NumArguments() > 2 && pResult->GetString(2)[0] ? pResult->GetString(2) : "No reason given"; char aBuf[128] = {0}; if(str_comp_nocase(pType, "option") == 0) { CVoteOptionServer *pOption = pSelf->m_pVoteOptionFirst; while(pOption) { if(str_comp_nocase(pValue, pOption->m_aDescription) == 0) { str_format(aBuf, sizeof(aBuf), "admin forced server option '%s' (%s)", pValue, pReason); pSelf->SendChatTarget(-1, aBuf); pSelf->Console()->ExecuteLine(pOption->m_aCommand); break; } pOption = pOption->m_pNext; } if(!pOption) { str_format(aBuf, sizeof(aBuf), "'%s' isn't an option on this server", pValue); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); return; } } else if(str_comp_nocase(pType, "kick") == 0) { int KickID = str_toint(pValue); if(KickID < 0 || KickID >= MAX_CLIENTS || !pSelf->m_apPlayers[KickID]) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "Invalid client id to kick"); return; } if (!g_Config.m_SvVoteKickBantime) { str_format(aBuf, sizeof(aBuf), "kick %d %s", KickID, pReason); pSelf->Console()->ExecuteLine(aBuf); } else { char aAddrStr[NETADDR_MAXSTRSIZE] = {0}; pSelf->Server()->GetClientAddr(KickID, aAddrStr, sizeof(aAddrStr)); str_format(aBuf, sizeof(aBuf), "ban %s %d %s", aAddrStr, g_Config.m_SvVoteKickBantime, pReason); pSelf->Console()->ExecuteLine(aBuf); } } else if(str_comp_nocase(pType, "spectate") == 0) { int SpectateID = str_toint(pValue); if(SpectateID < 0 || SpectateID >= MAX_CLIENTS || !pSelf->m_apPlayers[SpectateID] || pSelf->m_apPlayers[SpectateID]->GetTeam() == TEAM_SPECTATORS) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "Invalid client id to move"); return; } str_format(aBuf, sizeof(aBuf), "set_team %d -1", SpectateID); pSelf->Console()->ExecuteLine(aBuf); } }
void CGameContext::ConRules(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *) pUserData; bool Printed = false; if (g_Config.m_SvDDRaceRules) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", "No blocking."); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", "No insulting / spamming."); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", "No fun voting / vote spamming."); pSelf->Console()->Print( IConsole::OUTPUT_LEVEL_STANDARD, "rules", "Breaking any of these rules will result in a penalty, decided by server admins."); Printed = true; } if (g_Config.m_SvRulesLine1[0]) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine1); Printed = true; } if (g_Config.m_SvRulesLine2[0]) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine2); Printed = true; } if (g_Config.m_SvRulesLine3[0]) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine3); Printed = true; } if (g_Config.m_SvRulesLine4[0]) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine4); Printed = true; } if (g_Config.m_SvRulesLine5[0]) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine5); Printed = true; } if (g_Config.m_SvRulesLine6[0]) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine6); Printed = true; } if (g_Config.m_SvRulesLine7[0]) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine7); Printed = true; } if (g_Config.m_SvRulesLine8[0]) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine8); Printed = true; } if (g_Config.m_SvRulesLine9[0]) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine9); Printed = true; } if (g_Config.m_SvRulesLine10[0]) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", g_Config.m_SvRulesLine10); Printed = true; } if (!Printed) pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "rules", "No Rules Defined, Kill em all!!"); }