Exemple #1
0
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");
}
Exemple #2
0
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);
}
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);
			
			}
		}
	}
}
Exemple #4
0
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;		
}
Exemple #5
0
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();
}
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);
	}
}
Exemple #7
0
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;
}
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);
	}
}
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);
	}
}
Exemple #10
0
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");
}
Exemple #11
0
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);
}
Exemple #12
0
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();
}
void CGameContext::ConSay(IConsole::IResult *pResult, void *pUserData)
{
	CGameContext *pSelf = (CGameContext *)pUserData;
	pSelf->SendChat(-1, CGameContext::CHAT_ALL, pResult->GetString(0));
}
Exemple #14
0
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);
		}
	}
}
Exemple #15
0
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);
		}
	}
}
Exemple #16
0
void CGameContext::ConSwap(IConsole::IResult *pResult, void *pUserData)
{
	CGameContext *pSelf = (CGameContext *) pUserData;
	const int ClientID = pResult->m_ClientID;

	if(!g_Config.m_SvSwap)
	{
		pSelf->SendChatTarget(ClientID, "Swap is not activated");
		return;
	}
	
	int ToSwap = pResult->GetVictim();
	if(!CheckClientID(ToSwap) || ClientID == ToSwap)
		ToSwap = -1;

	if(!CheckClientID(ClientID))
		return;
	
	pSelf->m_aSwapRequest[ClientID] = ToSwap;
	if(ToSwap == -1)
		return;
	
	if(pSelf->ProcessSpamProtection(ClientID)) // dont flood
		return;
	
	// check if ToSwap agrees
	char aBuf[128];
	if(pSelf->m_aSwapRequest[ToSwap] != ClientID)
	{
		// send  notification to ToSwap
		str_format(aBuf, sizeof(aBuf), "%s wants to swap places with you. Type \'/swap %d\' to accept.",
			   pSelf->Server()->ClientName(ClientID), ClientID);
		pSelf->SendChatTarget(ToSwap, aBuf);
		
		str_format(aBuf, sizeof(aBuf), "Requst sent to %s.",
			   pSelf->Server()->ClientName(ToSwap));
		pSelf->SendChatTarget(ClientID, aBuf);
	}
	else
	{
		// ToSwap agreed
		CCharacter * pChar1 = pSelf->GetPlayerChar(ClientID);
		CCharacter * pChar2 = pSelf->GetPlayerChar(ToSwap);
		if(!pChar1 || !pChar2 || pChar1->Team() != pChar2->Team())
		{
			// one is not alive or not in the same team
			const char * pStr = "Can\'t swap!";
			pSelf->SendChatTarget(ToSwap, pStr);
			pSelf->SendChatTarget(ClientID, pStr);
			return;
		}

		CPlayerRescueState state1 = GetPlayerState(pChar1),
			state2 = GetPlayerState(pChar2);
		
		// swap
		ApplyPlayerState(state2, pChar1);
		ApplyPlayerState(state1, pChar2);
		
		str_format(aBuf, sizeof(aBuf), "%s swapped with %s.",
			   pSelf->Server()->ClientName(ToSwap),
			   pSelf->Server()->ClientName(ClientID));
		pSelf->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
		// reset swap requests
		pSelf->m_aSwapRequest[ToSwap] = -1;
		pSelf->m_aSwapRequest[ClientID] = -1;
	}
}