本文整理汇总了C++中CGameContext::SendChat方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameContext::SendChat方法的具体用法?C++ CGameContext::SendChat怎么用?C++ CGameContext::SendChat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGameContext
的用法示例。
在下文中一共展示了CGameContext::SendChat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConLockTeams
void CGameContext::ConLockTeams(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;
pSelf->m_LockTeams ^= 1;
if(pSelf->m_LockTeams)
pSelf->SendChat(-1, CGameContext::CHAT_ALL, "Teams were locked");
else
pSelf->SendChat(-1, CGameContext::CHAT_ALL, "Teams were unlocked");
}
示例2: ConSayTimeAll
void CGameContext::ConSayTimeAll(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),
"%s\'s current race time is %s%d:%s%d",
pSelf->Server()->ClientName(pResult->m_ClientID),
((IntTime / 60) > 9) ? "" : "0", IntTime / 60,
((IntTime % 60) > 9) ? "" : "0", IntTime % 60);
pSelf->SendChat(-1, CGameContext::CHAT_ALL, aBuftime, pResult->m_ClientID);
}
示例3: ConJail
void CGameContext::ConJail(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *) pUserData;
int Time = pResult->GetInteger(0);
int JailID = pResult->GetVictim();
char aBuf[200];
if(Time < 20 || Time > 2419200)
{
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Jail", "Set a time between 20 and 2419200 (4 weeks)");
return;
}
CCharacter* pChr = pSelf->GetPlayerChar(JailID);
if(pChr)
{
if(pChr->IsAlive())
{
pChr->GetPlayer()->m_AccData.m_Arrested = Time;
if(Time)
{
str_format(aBuf, sizeof aBuf, "'%s' is arrested for %i secounds.", pSelf->Server()->ClientName(JailID), Time);
pSelf->SendChat(-1, CHAT_ALL, aBuf);
pChr->Die(pChr->GetPlayer()->GetCID(), WEAPON_GAME);
}
}
}
}
示例4: ConCLEANEXTRAS
void CGameContext::ConCLEANEXTRAS(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *) pUserData;
int Victim = pResult->GetVictim();
CCharacter* pChr = pSelf->GetPlayerChar(Victim);
if (!pChr)
return;
char aBuf[128];
str_format(aBuf, sizeof aBuf, "Removed all extras From '%s'",
pSelf->Server()->ClientName(Victim));
pSelf->SendChat(-1, CHAT_ALL, aBuf);
//pChr->m_pPlayer->m_Rainbow = false;
//pChr->m_pPlayer->m_Invisible = false;
pChr->m_FreezeHammer = false;
//pChr->m_pPlayer->m_Rainbow = false;
//pChr->m_Rainbow = false;
pChr->m_Rainbow = RAINBOW_NONE;
pSelf->m_apPlayers[Victim]->m_Rainbow = RAINBOW_NONE;
pChr->m_FastReload = false;
pChr->m_ReloadMultiplier = 1000;
pChr->m_Super = false;
pChr->m_HammerType = 0;
pChr->m_Bloody = false;
pChr->m_Invisible = false;
//Msg.m_ColorBody = g_Config.m_PlayerColorBody;
//Msg.m_ColorFeet = g_Config.m_PlayerColorFeet;
}
示例5: 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), "All players were moved to the %s", pSelf->m_pController->GetTeamName(Team));
pSelf->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
for(int i = 0; i < MAX_CLIENTS; ++i)
if(pSelf->m_apPlayers[i])
pSelf->m_apPlayers[i]->SetTeam(Team, false);
(void)pSelf->m_pController->CheckTeamBalance();
}
示例6: ConKillPlayer
void CGameContext::ConKillPlayer(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *) pUserData;
if (!CheckClientID(pResult->m_ClientID))
return;
int Victim = pResult->GetVictim();
if (pSelf->m_apPlayers[Victim])
{
pSelf->m_apPlayers[Victim]->KillCharacter(WEAPON_GAME);
char aBuf[512];
str_format(aBuf, sizeof(aBuf), "%s was killed by %s",
pSelf->Server()->ClientName(Victim),
pSelf->Server()->ClientName(pResult->m_ClientID));
pSelf->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
}
}
示例7: ConUnFreezeHammer
void CGameContext::ConUnFreezeHammer(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *) pUserData;
int Victim = pResult->GetVictim();
CCharacter* pChr = pSelf->GetPlayerChar(Victim);
if (!pChr)
return;
char aBuf[128];
str_format(aBuf, sizeof aBuf, "'%s' lost freeze hammer!",
pSelf->Server()->ClientName(Victim));
pSelf->SendChat(-1, CHAT_ALL, aBuf);
pChr->m_FreezeHammer = false;
}
示例8: ConPolice
void CGameContext::ConPolice(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *) pUserData;
int Switch = pResult->GetInteger(0);
int PoliceID = pResult->GetVictim();
char aBuf[200];
CCharacter* pChr = pSelf->GetPlayerChar(PoliceID);
if (pChr)
{
pSelf->Server()->Police(PoliceID,Switch?1:0);
if(Switch)
str_format(aBuf, sizeof aBuf, "'%s' is a Police now.", pSelf->Server()->ClientName(PoliceID));
else
str_format(aBuf, sizeof aBuf, "'%s' is no longer a Police.", pSelf->Server()->ClientName(PoliceID));
pSelf->SendChat(-1, CHAT_ALL, aBuf);
}
}
示例9: ConDonor
void CGameContext::ConDonor(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *) pUserData;
int Switch = pResult->GetInteger(0);
int DonorID = pResult->GetVictim();
char aBuf[200];
CCharacter* pChr = pSelf->GetPlayerChar(DonorID);
if (pChr)
{
pChr->GetPlayer()->m_AccData.m_Donor = Switch;
if(Switch)
str_format(aBuf, sizeof aBuf, "'%s' is a Donor now.", pSelf->Server()->ClientName(DonorID));
else
str_format(aBuf, sizeof aBuf, "'%s' is no longer a Donor.", pSelf->Server()->ClientName(DonorID));
pSelf->SendChat(-1, CHAT_ALL, aBuf);
}
}
示例10: 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");
}
示例11: ConForcePause
void CGameContext::ConForcePause(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *) pUserData;
// if(!CheckClientID(pResult->m_ClientID)) return;
CServer* pServ = (CServer*) pSelf->Server();
int Victim = pResult->GetVictim();
int Seconds = 0;
char aBuf[128];
if (pResult->NumArguments() > 0 && pResult->m_ClientID < 0)
Seconds = clamp(pResult->GetInteger(0), 0, 15);
//else if(pResult->NumArguments() > 0 && CheckClientID(pResult->m_ClientID))
//Seconds = clamp(pResult->GetInteger(1), 0, 360);
CPlayer *pPlayer = pSelf->m_apPlayers[Victim];
if (!pPlayer || (!Seconds && pResult->m_ClientID >= 0))
return;
CCharacter* pChr = pPlayer->GetCharacter();
if (!pPlayer->GetTeam() && pChr && !pPlayer->m_InfoSaved
&& pResult->m_ClientID < 0)
{
pPlayer->SaveCharacter();
pPlayer->m_InfoSaved = true;
pPlayer->SetTeam(TEAM_SPECTATORS);
pPlayer->m_ForcePauseTime = Seconds * pServ->TickSpeed();
}
else
{
pPlayer->m_ForcePauseTime = Seconds * pServ->TickSpeed();
}
if (pResult->m_ClientID < 0)
str_format(aBuf, sizeof(aBuf),
"'%s' has been force-paused for %d seconds",
pServ->ClientName(Victim), Seconds);
else
str_format(aBuf, sizeof(aBuf),
"Force-pause of '%s' have been removed by '%s'",
pServ->ClientName(Victim),
pServ->ClientName(pResult->m_ClientID));
pSelf->SendChat(-1, CHAT_ALL, aBuf);
}
示例12: ConShuffleTeams
void CGameContext::ConShuffleTeams(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;
if(!pSelf->m_pController->IsTeamplay())
return;
int CounterRed = 0;
int CounterBlue = 0;
int PlayerTeam = 0;
for(int i = 0; i < MAX_CLIENTS; ++i)
if(pSelf->m_apPlayers[i] && pSelf->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS)
++PlayerTeam;
PlayerTeam = (PlayerTeam+1)/2;
pSelf->SendChat(-1, CGameContext::CHAT_ALL, "Teams were shuffled");
for(int i = 0; i < MAX_CLIENTS; ++i)
{
if(pSelf->m_apPlayers[i] && pSelf->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS)
{
if(CounterRed == PlayerTeam)
pSelf->m_apPlayers[i]->SetTeam(TEAM_BLUE, false);
else if(CounterBlue == PlayerTeam)
pSelf->m_apPlayers[i]->SetTeam(TEAM_RED, false);
else
{
if(rand() % 2)
{
pSelf->m_apPlayers[i]->SetTeam(TEAM_BLUE, false);
++CounterBlue;
}
else
{
pSelf->m_apPlayers[i]->SetTeam(TEAM_RED, false);
++CounterRed;
}
}
}
}
(void)pSelf->m_pController->CheckTeamBalance();
}
示例13: ConSay
void CGameContext::ConSay(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;
pSelf->SendChat(-1, CGameContext::CHAT_ALL, pResult->GetString(0));
}
示例14: ConJoinTeam
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);
}
}
//.........这里部分代码省略.........
示例15: ConJoinTeam
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(
//.........这里部分代码省略.........