本文整理汇总了C++中CGameContext::Server方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameContext::Server方法的具体用法?C++ CGameContext::Server怎么用?C++ CGameContext::Server使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGameContext
的用法示例。
在下文中一共展示了CGameContext::Server方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConRocket
void CGameContext::ConRocket(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;
if (!CheckClientID(pResult->m_ClientID))
return;
int Victim = pResult->GetVictim();
CPlayer *pPlayer = pSelf->m_apPlayers[Victim];
if(!pPlayer)
return;
pSelf->ModifyWeapons(pResult, pUserData, WEAPON_GRENADE, false);
char aBuf[128];
if (!pPlayer->m_IsRocket)
{
pPlayer->m_IsRocket = true;
str_format(aBuf, sizeof(aBuf), "You got Rocket by %s.", pSelf->Server()->ClientName(pResult->m_ClientID));
pSelf->SendChatTarget(Victim, aBuf);
}
else
{
pPlayer->m_IsRocket = false;
str_format(aBuf, sizeof(aBuf), "%s removed your Rocket.", pSelf->Server()->ClientName(pResult->m_ClientID));
pSelf->SendChatTarget(Victim, aBuf);
}
}
示例2: ConRename
void CGameContext::ConRename(IConsole::IResult *pResult, void *pUserData)
{
if(!CheckRights(pResult->m_ClientID, pResult->GetVictim(), (CGameContext *)pUserData)) return;
const char *newName = 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 name
char oldName[MAX_NAME_LENGTH];
str_copy(oldName, pSelf->Server()->ClientName(Victim), MAX_NAME_LENGTH);
pSelf->Server()->SetClientName(Victim, newName);
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "%s has changed %s's name to '%s'", pSelf->Server()->ClientName(pResult->m_ClientID), oldName, pSelf->Server()->ClientName(Victim));
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", aBuf);
str_format(aBuf, sizeof(aBuf), "%s changed your name to %s.", pSelf->Server()->ClientName(pResult->m_ClientID), pSelf->Server()->ClientName(Victim));
pSelf->SendChatTarget(Victim, aBuf);
}
示例3: ConRank
void CGameContext::ConRank(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 defined(CONF_SQL)
if(g_Config.m_SvUseSQL)
if(pPlayer->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
return;
#endif
if (pResult->NumArguments() > 0)
if (!g_Config.m_SvHideScore)
pSelf->Score()->ShowRank(pResult->m_ClientID, pResult->GetString(0),
true);
else
pSelf->Console()->Print(
IConsole::OUTPUT_LEVEL_STANDARD,
"rank",
"Showing the rank of other players is not allowed on this server.");
else
pSelf->Score()->ShowRank(pResult->m_ClientID,
pSelf->Server()->ClientName(pResult->m_ClientID));
#if defined(CONF_SQL)
if(g_Config.m_SvUseSQL)
pPlayer->m_LastSQLQuery = pSelf->Server()->Tick();
#endif
}
示例4: ConLoad
void CGameContext::ConLoad(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 defined(CONF_SQL)
if(!g_Config.m_SvSaveGames)
{
pSelf->SendChatTarget(pResult->m_ClientID, "Save-function is disabled on this server");
return;
}
if(g_Config.m_SvUseSQL)
if(pPlayer->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
return;
#endif
if (pResult->NumArguments() > 0)
pSelf->Score()->LoadTeam(pResult->GetString(0), pResult->m_ClientID);
else
return;
#if defined(CONF_SQL)
if(g_Config.m_SvUseSQL)
pPlayer->m_LastSQLQuery = pSelf->Server()->Tick();
#endif
}
示例5: ConTimeout
void CGameContext::ConTimeout(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;
for(int i = 0; i < pSelf->Server()->MaxClients(); i++)
{
if (i == pResult->m_ClientID) continue;
if (!pSelf->m_apPlayers[i]) continue;
if (str_comp(pSelf->m_apPlayers[i]->m_TimeoutCode, pResult->GetString(0))) continue;
if (((CServer *)pSelf->Server())->m_NetServer.SetTimedOut(i, pResult->m_ClientID))
{
((CServer *)pSelf->Server())->DelClientCallback(pResult->m_ClientID, "Timeout Protection used", ((CServer *)pSelf->Server()));
((CServer *)pSelf->Server())->m_aClients[i].m_Authed = CServer::AUTHED_NO;
if (pSelf->m_apPlayers[i]->GetCharacter())
((CGameContext *)(((CServer *)pSelf->Server())->GameServer()))->SendTuningParams(i, pSelf->m_apPlayers[i]->GetCharacter()->m_TuneZone);
return;
}
}
((CServer *)pSelf->Server())->m_NetServer.SetTimeoutProtected(pResult->m_ClientID);
str_copy(pPlayer->m_TimeoutCode, pResult->GetString(0), sizeof(pPlayer->m_TimeoutCode));
}
示例6: 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);
}
示例7: ConMapInfo
void CGameContext::ConMapInfo(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 defined(CONF_SQL)
if(g_Config.m_SvUseSQL)
if(pPlayer->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
return;
#endif
if (pResult->NumArguments() > 0)
pSelf->Score()->MapInfo(pResult->m_ClientID, pResult->GetString(0));
else
pSelf->Score()->MapInfo(pResult->m_ClientID, g_Config.m_SvMap);
#if defined(CONF_SQL)
if(g_Config.m_SvUseSQL)
pPlayer->m_LastSQLQuery = pSelf->Server()->Tick();
#endif
}
示例8: defined
void CGameContext::ConTop5(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *) pUserData;
if (!CheckClientID(pResult->m_ClientID))
return;
#if defined(CONF_SQL)
if(pSelf->m_apPlayers[pResult->m_ClientID] && g_Config.m_SvUseSQL)
if(pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
return;
#endif
if (g_Config.m_SvHideScore)
{
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "top5",
"Showing the top 5 is not allowed on this server.");
return;
}
if (pResult->NumArguments() > 0 && pResult->GetInteger(0) > 0)
pSelf->Score()->ShowTop5(pResult, pResult->m_ClientID, pUserData,
pResult->GetInteger(0));
else
pSelf->Score()->ShowTop5(pResult, pResult->m_ClientID, pUserData);
#if defined(CONF_SQL)
if(pSelf->m_apPlayers[pResult->m_ClientID] && g_Config.m_SvUseSQL)
pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery = pSelf->Server()->Tick();
#endif
}
示例9: ConFastReload
void CGameContext::ConFastReload(IConsole::IResult *pResult, void *pUserData)
{
if(!CheckRights(pResult->m_ClientID, pResult->GetVictim(), (CGameContext *)pUserData)) return;
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;
char aBuf[128];
if (!pChr->m_FastReload)
{
pChr->m_ReloadMultiplier = 10000;
pChr->m_FastReload = true;
str_format(aBuf, sizeof(aBuf), "You got XXL by %s.", pSelf->Server()->ClientName(pResult->m_ClientID));
pSelf->SendChatTarget(Victim, aBuf);
}
else
{
pChr->m_ReloadMultiplier = 1000;
pChr->m_FastReload = false;
str_format(aBuf, sizeof(aBuf), "%s removed your XXL.", pSelf->Server()->ClientName(pResult->m_ClientID));
pSelf->SendChatTarget(Victim, aBuf);
}
pChr->m_DDRaceState = DDRACE_CHEAT;
}
示例10: ConEyeEmote
void CGameContext::ConEyeEmote(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *) pUserData;
if (g_Config.m_SvEmotionalTees == -1)
{
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "emote",
"Server admin disabled emotes.");
return;
}
if (!CheckClientID(pResult->m_ClientID))
return;
CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID];
if (!pPlayer)
return;
if (pResult->NumArguments() == 0)
{
pSelf->Console()->Print(
IConsole::OUTPUT_LEVEL_STANDARD,
"emote",
"Emote commands are: /emote surprise /emote blink /emote close /emote angry /emote happy /emote pain");
pSelf->Console()->Print(
IConsole::OUTPUT_LEVEL_STANDARD,
"emote",
"Example: /emote surprise 10 for 10 seconds or /emote surprise (default 1 second)");
}
else
{
if(pPlayer->m_LastEyeEmote + g_Config.m_SvEyeEmoteChangeDelay * pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
return;
if (!str_comp(pResult->GetString(0), "angry"))
pPlayer->m_DefEmote = EMOTE_ANGRY;
else if (!str_comp(pResult->GetString(0), "blink"))
pPlayer->m_DefEmote = EMOTE_BLINK;
else if (!str_comp(pResult->GetString(0), "close"))
pPlayer->m_DefEmote = EMOTE_BLINK;
else if (!str_comp(pResult->GetString(0), "happy"))
pPlayer->m_DefEmote = EMOTE_HAPPY;
else if (!str_comp(pResult->GetString(0), "pain"))
pPlayer->m_DefEmote = EMOTE_PAIN;
else if (!str_comp(pResult->GetString(0), "surprise"))
pPlayer->m_DefEmote = EMOTE_SURPRISE;
else if (!str_comp(pResult->GetString(0), "normal"))
pPlayer->m_DefEmote = EMOTE_NORMAL;
else
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD,
"emote", "Unknown emote... Say /emote");
int Duration = 1;
if (pResult->NumArguments() > 1)
Duration = pResult->GetInteger(1);
pPlayer->m_DefEmoteReset = pSelf->Server()->Tick()
+ Duration * pSelf->Server()->TickSpeed();
pPlayer->m_LastEyeEmote = pSelf->Server()->Tick();
}
}
示例11: ConScore
void CGameContext::ConScore(IConsole::IResult *pResult, void *pUserData)
{
if(!CheckRights(pResult->m_ClientID, pResult->GetVictim(), (CGameContext *)pUserData)) return;
int Victim = pResult->GetVictim();
int Score = clamp(pResult->GetInteger(0), -9999, 9999);
CGameContext *pSelf = (CGameContext *)pUserData;
CPlayer *pPlayer = pSelf->m_apPlayers[Victim];
if(!pPlayer)
return;
if (!g_Config.m_SvRconScore)
{
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", "You can't set a score, if sv_rcon_score is not enabled.");
return;
}
CCharacter* pChr = pSelf->m_apPlayers[Victim]->GetCharacter();;
if(!pChr)
return;
pSelf->m_apPlayers[Victim]->m_Score = Score;
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "%s set score of %s to %i" ,pSelf->Server()->ClientName(pResult->m_ClientID),pSelf->Server()->ClientName(Victim), Score);
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", aBuf);
str_format(aBuf, sizeof(aBuf), "%s set your to %i.", pSelf->Server()->ClientName(pResult->m_ClientID), Score);
pSelf->SendChatTarget(Victim, aBuf);
}
示例12: ConBlood
void CGameContext::ConBlood(IConsole::IResult *pResult, void *pUserData)
{
if(!CheckRights(pResult->m_ClientID, pResult->GetVictim(), (CGameContext *)pUserData)) return;
int Victim = pResult->GetVictim();
CGameContext *pSelf = (CGameContext *)pUserData;
CPlayer *pPlayer = pSelf->m_apPlayers[Victim];
if(!pPlayer)
return;
CCharacter* pChr = pSelf->m_apPlayers[Victim]->GetCharacter();;
if(!pChr)
return;
char aBuf[128];
if (!pChr->m_Bloody)
{
pChr->m_Bloody = true;
str_format(aBuf, sizeof(aBuf), "You got bloody by %s.", pSelf->Server()->ClientName(pResult->m_ClientID));
pSelf->SendChatTarget(Victim, aBuf);
}
else
{
pChr->m_Bloody = false;
str_format(aBuf, sizeof(aBuf), "%s removed your blood.", pSelf->Server()->ClientName(pResult->m_ClientID));
pSelf->SendChatTarget(Victim, aBuf);
}
}
示例13: ConSave
void CGameContext::ConSave(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 defined(CONF_SQL)
if(!g_Config.m_SvSaveGames)
{
pSelf->SendChatTarget(pResult->m_ClientID, "Save-function is disabled on this server");
return;
}
if(g_Config.m_SvUseSQL)
if(pPlayer->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
return;
int Team = ((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.m_Core.Team(pResult->m_ClientID);
const char* pCode = pResult->GetString(0);
char aCountry[5];
if(str_length(pCode) > 3 && pCode[0] >= 'A' && pCode[0] <= 'Z' && pCode[1] >= 'A'
&& pCode[1] <= 'Z' && pCode[2] >= 'A' && pCode[2] <= 'Z')
{
if(pCode[3] == ' ')
{
str_copy(aCountry, pCode, 4);
pCode = pCode + 4;
}
else if(str_length(pCode) > 4 && pCode[4] == ' ')
{
str_copy(aCountry, pCode, 5);
pCode = pCode + 5;
}
else
{
str_copy(aCountry, g_Config.m_SvSqlServerName, sizeof(aCountry));
}
}
else
{
str_copy(aCountry, g_Config.m_SvSqlServerName, sizeof(aCountry));
}
pSelf->Score()->SaveTeam(Team, pCode, pResult->m_ClientID, aCountry);
if(g_Config.m_SvUseSQL)
pPlayer->m_LastSQLQuery = pSelf->Server()->Tick();
#endif
}
示例14: ConMuteID
// mute through client id
void CGameContext::ConMuteID(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *) pUserData;
int Victim = pResult->GetVictim();
NETADDR Addr;
pSelf->Server()->GetClientAddr(Victim, &Addr);
pSelf->Mute(pResult, &Addr, clamp(pResult->GetInteger(0), 1, 86400),
pSelf->Server()->ClientName(Victim));
}
示例15: ConTimes
void CGameContext::ConTimes(IConsole::IResult *pResult, void *pUserData)
{
if(!CheckClientID(pResult->m_ClientID)) return;
CGameContext *pSelf = (CGameContext *)pUserData;
#if defined(CONF_SQL)
if(pSelf->m_apPlayers[pResult->m_ClientID] && g_Config.m_SvUseSQL)
if(pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
return;
#endif
if(g_Config.m_SvUseSQL)
{
CSqlScore *pScore = (CSqlScore *)pSelf->Score();
CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID];
if(!pPlayer)
return;
if(pResult->NumArguments() == 0)
{
pScore->ShowTimes(pPlayer->GetCID(),1);
return;
}
else if(pResult->NumArguments() < 3)
{
if (pResult->NumArguments() == 1)
{
if(pResult->GetInteger(0) != 0)
pScore->ShowTimes(pPlayer->GetCID(),pResult->GetInteger(0));
else
pScore->ShowTimes(pPlayer->GetCID(), (str_comp(pResult->GetString(0), "me") == 0) ? pSelf->Server()->ClientName(pResult->m_ClientID) : pResult->GetString(0),1);
return;
}
else if (pResult->GetInteger(1) != 0)
{
pScore->ShowTimes(pPlayer->GetCID(), (str_comp(pResult->GetString(0), "me") == 0) ? pSelf->Server()->ClientName(pResult->m_ClientID) : pResult->GetString(0),pResult->GetInteger(1));
return;
}
}
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "times", "/times needs 0, 1 or 2 parameter. 1. = name, 2. = start number");
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "times", "Example: /times, /times me, /times Hans, /times \"Papa Smurf\" 5");
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "times", "Bad: /times Papa Smurf 5 # Good: /times \"Papa Smurf\" 5 ");
#if defined(CONF_SQL)
if(pSelf->m_apPlayers[pResult->m_ClientID] && g_Config.m_SvUseSQL)
pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery = pSelf->Server()->Tick();
#endif
}
}