本文整理汇总了C++中CGameContext::Console方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameContext::Console方法的具体用法?C++ CGameContext::Console怎么用?C++ CGameContext::Console使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGameContext
的用法示例。
在下文中一共展示了CGameContext::Console方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConTogglePause
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;
}
示例2: ConSetTeamAll
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();
}
示例3: ConMap
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
}
示例4: ConSetTeam
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);
}
示例5: ConVote
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);
}
示例6: ConSetTeam
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();
}
示例7: ConToggleFly
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");
}
}
示例8: ConVis
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);
}
}
示例9: ConUnmute
// 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);
}
示例10: ConCredits
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");
}
示例11: ConSayTime
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);
}
示例12: ConCredits
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][email protected]\' 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.");
}
示例13: ConMe
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");
}
示例14: ConSkin
//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);
}
示例15: ConCredits
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");
}