Exemplo n.º 1
0
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);
	}
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
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);
	}
}
Exemplo n.º 4
0
void CGameContext::ConLockTeam(IConsole::IResult *pResult, void *pUserData)
{
	CGameContext *pSelf = (CGameContext *) pUserData;
	if (!CheckClientID(pResult->m_ClientID))
		return;

	int Team = ((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.m_Core.Team(pResult->m_ClientID);

	bool Lock = ((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.TeamLocked(Team);

	if (pResult->NumArguments() > 0)
		Lock = !pResult->GetInteger(0);

	if(Team > TEAM_FLOCK && Team < TEAM_SUPER)
	{
		char aBuf[512];
		if(Lock)
		{
			((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.SetTeamLock(Team, false);

			str_format(aBuf, sizeof(aBuf), "'%s' unlocked your team.", pSelf->Server()->ClientName(pResult->m_ClientID));

			for (int i = 0; i < MAX_CLIENTS; i++)
				if (((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.m_Core.Team(i) == Team)
					pSelf->SendChatTarget(i, aBuf);
		}
		else if(!g_Config.m_SvTeamLock)
		{
			pSelf->Console()->Print(
					IConsole::OUTPUT_LEVEL_STANDARD,
					"print",
					"Team locking is disabled on this server");
		}
		else
		{
			((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.SetTeamLock(Team, true);

			str_format(aBuf, sizeof(aBuf), "'%s' locked your team. After the race started killing will kill everyone in your team.", pSelf->Server()->ClientName(pResult->m_ClientID));

			for (int i = 0; i < MAX_CLIENTS; i++)
				if (((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.m_Core.Team(i) == Team)
					pSelf->SendChatTarget(i, aBuf);
		}
	}
	else
		pSelf->Console()->Print(
				IConsole::OUTPUT_LEVEL_STANDARD,
				"print",
				"This team can't be locked");
}
Exemplo n.º 5
0
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
}
Exemplo n.º 6
0
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);
}
Exemplo n.º 7
0
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);
}
Exemplo n.º 8
0
void CGameContext::ConTest(IConsole::IResult *pResult, void *pUserData)
{
	if(!CheckClientID(pResult->m_ClientID)) return;
	int Victim = pResult->m_ClientID;
	CGameContext *pSelf = (CGameContext *)pUserData;
	const char *message = pResult->GetString(0);
	char aBuf[256];

	str_format(aBuf, sizeof(aBuf), "ClientID:%i|First arg:%s", pResult->m_ClientID, message);

	pSelf->SendChatTarget(Victim, aBuf);

//
//	CGameContext *pSelf = (CGameContext *)pUserData;
//	CCharacter* pChr = pSelf->m_apPlayers[pResult->ClientID]->GetCharacter();
//	if(!pChr)
//		return;

//	str_format(aBuf, sizeof(aBuf), "md5:%s" , md5(message));


	//pChr->m_is_bloody = 1;
	//~ pSelf->m_apPlayers[ClientID]->m_Score = (Score()->PlayerData(ClientID)->m_BestTime)?Score()->PlayerData(ClientID)->m_BestTime:0;
	//~ pSelf->m_apPlayers[ClientID]->m_Score = 123;
	//~ char aBuf[256];
	//~ str_format(aBuf, sizeof(aBuf), "%s: %s" ,pSelf->Server()->ClientName(ClientID),message);
	//~ str_format(aBuf, sizeof(aBuf), "Teeinfo:%i" , pSelf->m_apPlayers[ClientID]->m_TeeInfos.m_ColorBody);
	//~ pResult->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", aBuf);
	//~ pSelf->SendChatTarget(Victim, aBuf);

}
Exemplo n.º 9
0
void CGameContext::ConWhisper(IConsole::IResult *pResult, void *pUserData)
{
	if(!CheckRights(pResult->m_ClientID, pResult->GetVictim(), (CGameContext *)pUserData)) return;
	CGameContext *pSelf = (CGameContext *)pUserData;
	int Victim = pResult->GetVictim();
	CCharacter* pChr = pSelf->m_apPlayers[pResult->m_ClientID]->GetCharacter();
	const char *message = pResult->GetString(0);

	if(!pChr)
		return;

	char aBuf[256];
	str_format(aBuf, sizeof(aBuf), "%s: %s", pSelf->Server()->ClientName(pResult->m_ClientID), message);
	pSelf->SendChatTarget(Victim, aBuf);

	str_format(aBuf, sizeof(aBuf), "-->%s: %s", pSelf->Server()->ClientName(pResult->m_ClientID), message);
	pSelf->SendChatTarget(pResult->m_ClientID, aBuf);
}
Exemplo n.º 10
0
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
}
Exemplo n.º 11
0
void CGameContext::ConJumps(IConsole::IResult *pResult, void *pUserData)
{
	CGameContext *pSelf = (CGameContext *)pUserData;
	if(!CheckClientID(pResult->m_ClientID)) return;
	CCharacter *pChr = pSelf->m_apPlayers[pResult->m_ClientID]->GetCharacter();
	if (!pChr)
		return;

	char aBuf[64];
	str_format(aBuf, sizeof(aBuf), "You can jump %d times.", pChr->Core()->m_MaxJumps);
	pSelf->SendChatTarget(pResult->m_ClientID, aBuf);
}
Exemplo n.º 12
0
void CGameContext::ConVote(IConsole::IResult *pResult, void *pUserData)
{
	CGameContext *pSelf = (CGameContext *)pUserData;
	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), "admin forced vote %s", pResult->GetString(0));
	pSelf->SendChatTarget(-1, aBuf);
	str_format(aBuf, sizeof(aBuf), "forcing vote %s", pResult->GetString(0));
	pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
}
Exemplo n.º 13
0
void CGameContext::ConRainbow(IConsole::IResult *pResult, void *pUserData)
{
	if(!CheckRights(pResult->m_ClientID, pResult->GetVictim(), (CGameContext *)pUserData)) return;
	CGameContext *pSelf = (CGameContext *)pUserData;
	int Victim = pResult->GetVictim();
	int Rainbowtype = clamp(pResult->GetInteger(0), 0, 2);

	CPlayer *pPlayer = pSelf->m_apPlayers[Victim];
	if(!pPlayer)
		return;

	CCharacter* pChr = pSelf->m_apPlayers[Victim]->GetCharacter();
	if(!pChr)
		return;

	char aBuf[256];
	if ((pSelf->m_apPlayers[Victim]->m_Rainbow == RAINBOW_NONE || pSelf->m_apPlayers[Victim]->m_Rainbow == RAINBOW_BLACKWHITE) && Rainbowtype <= 1)
	{
		pSelf->m_apPlayers[Victim]->m_Rainbow = RAINBOW_COLOR;

		str_format(aBuf, sizeof(aBuf), "You got rainbow by %s.", pSelf->Server()->ClientName(pResult->m_ClientID));
		pSelf->SendChatTarget(Victim, aBuf);
	}
	else if ((pSelf->m_apPlayers[Victim]->m_Rainbow == RAINBOW_NONE || pSelf->m_apPlayers[Victim]->m_Rainbow == RAINBOW_COLOR) && Rainbowtype == 2)
	{
		pSelf->m_apPlayers[Victim]->m_Rainbow = RAINBOW_BLACKWHITE;

		str_format(aBuf, sizeof(aBuf), "You got black and white rainbow by %s.", pSelf->Server()->ClientName(pResult->m_ClientID));
		pSelf->SendChatTarget(Victim, aBuf);
	}
	else
	{
		pSelf->m_apPlayers[Victim]->m_Rainbow = RAINBOW_NONE;
		str_format(aBuf, sizeof(aBuf), "%s removed your rainbow.", pSelf->Server()->ClientName(pResult->m_ClientID));
		pSelf->SendChatTarget(Victim, aBuf);
	}
}
Exemplo n.º 14
0
void CGameContext::ConSolo(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)
	{
		pChr->m_Solo = !pChr->m_Solo;
		pSelf->SendChatTarget(pResult->m_ClientID, pChr->m_Solo ? "You are now in solo" : "You are now out of solo");
	}
}
Exemplo n.º 15
0
void CGameContext::ConLogin(IConsole::IResult *pResult, void *pUserData)
{
	if(!CheckClientID(pResult->GetInteger(0))) return;
	CGameContext *pSelf = (CGameContext *)pUserData;

	CPlayer *pPlayer = pSelf->m_apPlayers[pResult->GetInteger(0)];
	if(!pPlayer)
		return;

	if(pPlayer->m_LastLogin + 5 * pSelf->Server()->TickSpeed() - pSelf->Server()->Tick() > 0)
	{
		pSelf->SendChatTarget(pResult->m_ClientID, "You can login every 5 seconds only");
		return;
	}

	pPlayer->m_LastLogin = pSelf->Server()->Tick();
	pSelf->MemberList->Login(pResult->m_ClientID, pResult->GetString(0), pSelf);
}
Exemplo n.º 16
0
void CGameContext::ConRescue(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 (!g_Config.m_SvRescue) {
		pSelf->SendChatTarget(pPlayer->GetCID(), "Rescue is not enabled on this server");
		return;
	}

	pChr->Rescue();
}
Exemplo n.º 17
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;
	}
}
Exemplo n.º 18
0
void CGameContext::ConRescue(IConsole::IResult *pResult, void *pUserData)
{
	CGameContext *pSelf = (CGameContext *)pUserData;
	CCharacter* pChr = pSelf->m_apPlayers[pResult->m_ClientID]->GetCharacter();

	if(!g_Config.m_SvRescue)
	{
		pSelf->SendChatTarget(pResult->m_ClientID, "Rescue is not activated.");
		return;
	}

	if(!pChr)
	{
		pSelf->SendChatTarget(pResult->m_ClientID, "You are not alive!");
		return;
	}
	
	
	if(pChr->m_DeepFreeze)
	{
		pSelf->SendChatTarget(pResult->m_ClientID, "You are deepfreezed, undeepfreeze first!");
		return;
	}
	if(!pChr->IsAlive())
	{
		pSelf->SendChatTarget(pResult->m_ClientID, "You are not alive!");
		return;
	}
	// unfreeze if pressed second time
	if(pChr->m_RescueFlags & RESCUEFLAG_CAN_UNFREEZE)
	{
		pChr->m_RescueFlags &= ~RESCUEFLAG_CAN_UNFREEZE;
		if(pChr->m_FreezeTime && pChr->m_TileIndex != TILE_FREEZE && pChr->m_TileFIndex != TILE_FREEZE && pChr->Core()->m_Pos == pChr->m_RescuePos)
		{
			pChr->UnFreeze();
			return;
		}
	}
	if(pChr->m_FreezeTime == 0)
		return;
    
	if(pChr->m_LastRescue) // sv_rescue_delay
		return;

	if(pChr->m_RescueOverride)
	{
		pSelf->SendChatTarget(pResult->m_ClientID, "Rescue is disabled by the map.");
		return;
	}

	if(pChr->m_RescuePos == vec2(0,0))
	{
		pSelf->SendChatTarget(pResult->m_ClientID, "No position saved!");
		return;
	}


	// reset players' hook
	for(int i = 0; i < MAX_CLIENTS; i++)
	{
		if(pSelf->m_apPlayers[i])
		{
			CCharacter* pChr2 = pSelf->m_apPlayers[i]->GetCharacter();
			//who hooks me?
			if(pChr2 && pChr2->Core()->m_HookedPlayer == pResult->m_ClientID)
			{
				//Release hook
				pChr2->Core()->m_HookedPlayer = -1;
				pChr2->Core()->m_HookState = HOOK_RETRACTED;
				pChr2->Core()->m_HookPos = pChr2->Core()->m_Pos;
			}
		}
	}
	if(g_Config.m_SvRescueEffects)
	{
		//Blood effect
		pChr->GameServer()->CreateDeath(pChr->m_Pos, pResult->m_ClientID);
		//Spawn effect
		pChr->GameServer()->CreatePlayerSpawn(pChr->m_RescuePos);
	}
	//Teleport player
	pChr->Core()->m_Pos = pChr->m_PrevPos = pChr->m_Pos = pChr->m_RescuePos;
	pChr->Core()->m_Vel = vec2(0.f, 0.f); // reset momentum

	if(pChr->m_RescueFlags)
	{
		// disarm player
		if(pChr->m_RescueFlags & RESCUEFLAG_DISARM)
		{
			bool disarmed = false;
			for(int i = WEAPON_SHOTGUN; i < NUM_WEAPONS; i++)
			{
				if(pChr->GetWeaponGot(i) && i != WEAPON_NINJA)
				{
					pChr->SetWeaponGot(i, false);
					pChr->SetWeaponAmmo(i, 0);
					disarmed = true;
				}
			}
			if(disarmed)
				pChr->GameServer()->SendChatTarget(pResult->m_ClientID, "You have been disarmed");
		}
		// solo fix
		if(pChr->m_RescueFlags & RESCUEFLAG_SOLOOUT)
		{
			pChr->GameServer()->SendChatTarget(pResult->m_ClientID, "You are now in a solo part");
			pChr->m_Solo = true;
		}
		else if(pChr->m_RescueFlags & RESCUEFLAG_SOLOIN)
		{
			pChr->GameServer()->SendChatTarget(pResult->m_ClientID, "You are now out of the solo part");
			pChr->m_Solo = false;
		}
		// hit fix
		if(pChr->m_RescueFlags & RESCUEFLAG_NOHIT)
		{
			pChr->GameServer()->SendChatTarget(pResult->m_ClientID, "You can hit others");
			pChr->m_Hit = CCharacter::HIT_ALL;
		}
		else if(pChr->m_RescueFlags & RESCUEFLAG_HIT)
		{
			pChr->GameServer()->SendChatTarget(pResult->m_ClientID, "You can't hit others");
			pChr->m_Hit = CCharacter::DISABLE_HIT_GRENADE|CCharacter::DISABLE_HIT_HAMMER|
				CCharacter::DISABLE_HIT_RIFLE|CCharacter::DISABLE_HIT_SHOTGUN;
		}
		// endless hook fix
		if(pChr->m_RescueFlags & RESCUEFLAG_NOEHOOK && !pChr->m_EndlessHook)
		{
			pChr->GameServer()->SendChatTarget(pResult->m_ClientID, "Endless hook has been activated");
			pChr->m_EndlessHook = true;
		}
		else if(pChr->m_RescueFlags & RESCUEFLAG_EHOOK && pChr->m_EndlessHook)
		{
			pChr->GameServer()->SendChatTarget(pResult->m_ClientID, "Endless hook has been deactivated");
			pChr->m_EndlessHook = false;
		}
		pChr->m_RescueFlags = RESCUEFLAG_NONE;
	}
	//"save" last rescue time
	pChr->m_LastRescue = ((float)g_Config.m_SvRescueDelay / 1000) * pSelf->Server()->TickSpeed();
	pChr->m_RescueFlags |= RESCUEFLAG_CAN_UNFREEZE;
}
Exemplo n.º 19
0
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);
	}
}
Exemplo n.º 20
0
void CGameContext::ConHelper(IConsole::IResult *pResult, void *pUserData)
{
	int helper = 0;
	char aBuf[128];
	int Seconds;
	int HelperTime = 60;

	CGameContext *pSelf = (CGameContext *)pUserData;
	CCharacter* pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
	CServer* pServ = (CServer*)pSelf->Server();

	if (pResult->NumArguments() == 1 && pSelf->m_apPlayers[pResult->m_ClientID]->m_Authed >= pServ->AUTHED_MOD)
	{
		if(!CheckClientID(pResult->GetInteger(0))) return;
		CCharacter* pChr2 = pSelf->GetPlayerChar(pResult->GetInteger(0));
		if(pSelf->m_apPlayers[pResult->GetInteger(0)]
		   && pChr2 && pResult->m_ClientID != pResult->GetInteger(0)
		   && pSelf->m_apPlayers[pResult->GetInteger(0)]->m_Authed == pServ->AUTHED_NO)
			pServ->SetRconLevel(pResult->GetInteger(0), pServ->AUTHED_HELPER);

		return;
	}

	if(pChr && g_Config.m_SvHelper)
	{

		if (pSelf->m_apPlayers[pResult->m_ClientID]->m_Helped)
		{

			Seconds = pSelf->m_apPlayers[pResult->m_ClientID]->m_Helped / pSelf->Server()->TickSpeed();
			str_format(aBuf, sizeof(aBuf), "Please wait %d seconds to call a helper again.",  Seconds);
			pSelf->SendChatTarget(pResult->m_ClientID, aBuf);
			return;
		}
		for(int i = 0;i <=(int)MAX_CLIENTS-1 ; i++)
		{
			CCharacter* pChr3 = pSelf->GetPlayerChar(i);
			if(pChr3)
			{
				if (pSelf->m_apPlayers[i]->m_Authed >= pServ->AUTHED_HELPER)
				{
					str_format(aBuf, sizeof(aBuf), "%s needs help. ID:%i", pSelf->Server()->ClientName(pResult->m_ClientID), pResult->m_ClientID);
					pSelf->SendChatTarget(i, aBuf);
					pServ->SendRconLine(i, aBuf);
					helper++;

				}
			}
		}
		if (helper == 0 )
			str_format(aBuf, sizeof(aBuf), "Sorry, but there is no helper online.");
		else if (helper == 1)
		{
			str_format(aBuf, sizeof(aBuf), "You called one helper!");
			pSelf->m_apPlayers[pResult->m_ClientID]->m_Helped = HelperTime * pSelf->Server()->TickSpeed();
		}
		else
		{
			str_format(aBuf, sizeof(aBuf), "%i helpers called!", helper);
			pSelf->m_apPlayers[pResult->m_ClientID]->m_Helped = HelperTime * pSelf->Server()->TickSpeed();
		}
	}
	else
	{
		str_format(aBuf, sizeof(aBuf), "sv_helper not activated.");
	}
	pSelf->SendChatTarget(pResult->m_ClientID, aBuf);
}