void CGameClient::Disconnect( const char *fmt, ... ) { va_list argptr; char reason[1024]; if ( m_nSignonState == SIGNONSTATE_NONE ) return; // no recursion va_start (argptr,fmt); Q_vsnprintf (reason, sizeof( reason ), fmt,argptr); va_end (argptr); // notify other clients of player leaving the game // send the username and network id so we don't depend on the CBasePlayer pointer IGameEvent *event = g_GameEventManager.CreateEvent( "player_disconnect" ); if ( event ) { event->SetInt("userid", GetUserID() ); event->SetString("reason", reason ); event->SetString("name", GetClientName() ); event->SetString("networkid", GetNetworkIDString() ); g_GameEventManager.FireEvent( event ); } m_Server->RemoveClientFromGame( this ); CBaseClient::Disconnect( "%s", reason ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTeamControlPoint::SendCapString( int iCapTeam, int iNumCappers, int *pCappingPlayers ) { if ( strlen( STRING(m_iszPrintName) ) <= 0 ) return; IGameEvent *event = gameeventmanager->CreateEvent( "teamplay_point_captured" ); if ( event ) { event->SetInt( "cp", m_iPointIndex ); event->SetString( "cpname", STRING(m_iszPrintName) ); event->SetInt( "team", iCapTeam ); char cappers[9]; // pCappingPlayers is max length 8 int i; for( i=0;i<iNumCappers;i++ ) { cappers[i] = (char)pCappingPlayers[i]; } cappers[i] = '\0'; // pCappingPlayers is a null terminated list of player indices event->SetString( "cappers", cappers ); event->SetInt( "priority", 9 ); gameeventmanager->FireEvent( event ); } }
void CGameRules::ClientSettingsChanged( CBasePlayer *pPlayer ) { const char *pszName = engine->GetClientConVarValue( pPlayer->entindex(), "name" ); const char *pszOldName = pPlayer->GetPlayerName(); // msg everyone if someone changes their name, and it isn't the first time (changing no name to current name) // Note, not using FStrEq so that this is case sensitive if ( pszOldName[0] != 0 && Q_strcmp( pszOldName, pszName ) ) { char text[256]; Q_snprintf( text,sizeof(text), "%s changed name to %s\n", pszOldName, pszName ); UTIL_ClientPrintAll( HUD_PRINTTALK, text ); IGameEvent * event = gameeventmanager->CreateEvent( "player_changename" ); if ( event ) { event->SetInt( "userid", pPlayer->GetUserID() ); event->SetString( "oldname", pszOldName ); event->SetString( "newname", pszName ); gameeventmanager->FireEvent( event ); } pPlayer->SetPlayerName( pszName ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTeamControlPoint::CaptureStart( int iCapTeam, int iNumCappingPlayers, int *pCappingPlayers ) { int iNumCappers = iNumCappingPlayers; IGameEvent *event = gameeventmanager->CreateEvent( "teamplay_point_startcapture" ); if ( event ) { event->SetInt( "cp", m_iPointIndex ); event->SetString( "cpname", STRING( m_iszPrintName ) ); event->SetInt( "team", m_iTeam ); event->SetInt( "capteam", iCapTeam ); // safety check if ( iNumCappers > 8 ) { iNumCappers = 8; } char cappers[9]; // pCappingPlayers should be max length 8 int i; for( i = 0 ; i < iNumCappers ; i++ ) { cappers[i] = (char)pCappingPlayers[i]; } cappers[i] = '\0'; // pCappingPlayers is a null terminated list of player indices event->SetString( "cappers", cappers ); event->SetInt( "priority", 7 ); gameeventmanager->FireEvent( event ); } }
// Ability to alter the objective: // DOBJ_ACTION_OPEN: Opens the objective door and starts spawning creeps (if round has started) // DOBJ_ACTION_CLOSE: Closes the objective door and stops spawning creeps (if this is the last door, the round will end) int DotaObjective::TakeAction( int dobjAction ) { // Issue #24: AMP - 2013-10-04 - Lane manipulation if (dobjAction & DOBJ_ACTION_CLOSE) { PropSetAnim( "Close" ); // Issue #35: JMS - 2013-10-27 - fire event to clients IGameEvent *pEvent = gameeventmanager->CreateEvent( "objectivegate_close" ); if ( pEvent ) { pEvent->SetString( "lane", GetLane() ); pEvent->SetInt( "team", this->GetTeamNumber() ); gameeventmanager->FireEvent( pEvent ); } m_bMet = true; //turn off the maker CreepMaker * maker = (CreepMaker*)gEntList.FindEntityByName( NULL, m_creepMakerName ); if( maker ) maker->m_enabled = false; //see if I'm the last one, if so, game over bool foundOne = false; for ( CBaseEntity *pEntity = gEntList.FirstEnt(); pEntity != NULL; pEntity = gEntList.NextEnt(pEntity) ) { DotaObjective * obj = dynamic_cast<DotaObjective*>( pEntity ); if ( obj && obj->GetTeamNumber() == this->GetTeamNumber() && !obj->m_bMet ) foundOne = true; } if ( !foundOne ) { CHL2MPRules *rules = (CHL2MPRules*)g_pGameRules; if ( rules && !rules->IsIntermission() ) { rules->EndMultiplayerGame(); } } return true; } else if (dobjAction & DOBJ_ACTION_OPEN) { // Issue #35: JMS - 2013-10-27 - fire event to clients IGameEvent *pEvent = gameeventmanager->CreateEvent( "objectivegate_open" ); if ( pEvent ) { pEvent->SetString( "lane", GetLane() ); pEvent->SetInt( "team", this->GetTeamNumber() ); gameeventmanager->FireEvent( pEvent ); } m_timesHit = 0; m_bMet = false; CreepMaker * maker = (CreepMaker*)gEntList.FindEntityByName( NULL, m_creepMakerName ); maker->m_enabled = true; PropSetAnim( "Open" ); return true; } return false; }
/** * @brief Called when a client is authorized. * * @param client Index of the client. * @param authstring His SteamID. */ void Left4Downtown::OnClientAuthorized(int client, const char *authstring) { /* Credits to Scott "DS" Ehlert from the SourceMod Dev Team for providing me with this super-easy method of selective event broadcasting. If it wasn't for him, I'd be stuck with a bunch of nasty code -- i.e. my initial idea of a NET_SendPacket vcall(bitbuffers, serializing events, casting IPs to netadr_t etc.) /blog */ if (!g_AddonsEclipse.GetBool()) { L4D_DEBUG_LOG("l4d2_addons_eclipse set to 0, skipping function"); return; } IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client); if (pPlayer->IsFakeClient()) { L4D_DEBUG_LOG("Fake client %d connected, ignoring...", client); return; } cell_t result = Pl_Continue; if (g_pFwdOnAddonsEclipseUpdate) { g_pFwdOnAddonsEclipseUpdate->PushCell(client); g_pFwdOnAddonsEclipseUpdate->Execute(&result); if(result == Pl_Handled) { L4D_DEBUG_LOG("L4D2_OnAddonsEclipseUpdate(%d) will be skipped", client); return; } L4D_DEBUG_LOG("L4D2_OnAddonsEclipseUpdate(%d) has been sent out...", client); } // Getting the client event listener INetChannel *pNetChan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(client)); IClient *pClient = static_cast<IClient *>(pNetChan->GetMsgHandler()); unsigned char *pBaseClient = reinterpret_cast<unsigned char *>(pClient) - 4; IGameEventListener2 *pClientListener = reinterpret_cast<IGameEventListener2 *>(pBaseClient); // Firing our event; it will tell the client to unload his addons IGameEvent *pEvent = gameeventmanager->CreateEvent("server_spawn"); if (pEvent) { pEvent->SetString("address", "159.253.143.194:0"); pEvent->SetString("mapname", STRING(gpGlobals->mapname)); pClientListener->FireGameEvent(pEvent); L4D_DEBUG_LOG("Fired event for client %d", client); } // When done with event, must destroy it manually gameeventmanager->FreeEvent(pEvent); }
//========================================================= // ClientUserInfoChanged //========================================================= void CTeamplayRules::ClientSettingsChanged( CBasePlayer *pPlayer ) { /* TODO: handle skin, model & team changes char text[1024]; // skin/color/model changes int iTeam = Q_atoi( engine->GetClientConVarValue( pPlayer->entindex(), "cl_team" ) ); int iClass = Q_atoi( engine->GetClientConVarValue( pPlayer->entindex(), "cl_class" ) ); if ( defaultteam.GetBool() ) { // int clientIndex = pPlayer->entindex(); // engine->SetClientKeyValue( clientIndex, "model", pPlayer->TeamName() ); // engine->SetClientKeyValue( clientIndex, "team", pPlayer->TeamName() ); UTIL_SayText( "Not allowed to change teams in this game!\n", pPlayer ); return; } if ( defaultteam.GetFloat() || !IsValidTeam( mdls ) ) { // int clientIndex = pPlayer->entindex(); // engine->SetClientKeyValue( clientIndex, "model", pPlayer->TeamName() ); Q_snprintf( text,sizeof(text), "Can't change team to \'%s\'\n", mdls ); UTIL_SayText( text, pPlayer ); Q_snprintf( text,sizeof(text), "Server limits teams to \'%s\'\n", m_szTeamList ); UTIL_SayText( text, pPlayer ); return; } ChangePlayerTeam( pPlayer, mdls, true, true ); // recound stuff RecountTeams(); */ const char *pszName = engine->GetClientConVarValue( pPlayer->entindex(), "name" ); const char *pszOldName = pPlayer->GetPlayerName(); // msg everyone if someone changes their name, and it isn't the first time (changing no name to current name) // Note, not using FStrEq so that this is case sensitive if ( pszOldName[0] != 0 && Q_strcmp( pszOldName, pszName ) ) { IGameEvent * event = gameeventmanager->CreateEvent( "player_changename" ); if ( event ) { event->SetInt( "userid", pPlayer->GetUserID() ); event->SetString( "oldname", pszOldName ); event->SetString( "newname", pszName ); gameeventmanager->FireEvent( event ); } pPlayer->SetPlayerName( pszName ); } }
static void NotifyConVar(ConVar *pConVar) { IGameEvent *pEvent = g_Interfaces.GameEventManagerInstance->CreateEvent("server_cvar"); pEvent->SetString("cvarname", pConVar->GetName()); if (IsFlagSet(pConVar, FCVAR_PROTECTED)) { pEvent->SetString("cvarvalue", "***PROTECTED***"); } else { pEvent->SetString("cvarvalue", pConVar->GetString()); } g_Interfaces.GameEventManagerInstance->FireEvent(pEvent); }
//----------------------------------------------------------------------------- // Purpose: Displays a hint message to the player // Input : *pMessage - //----------------------------------------------------------------------------- void CHintSystem::HintMessage( const char *pMessage ) { Assert( m_pPlayer ); #ifdef GAME_DLL // On the server, we send it down to the queue who sends it to the client if ( !m_pPlayer->IsNetClient() || !m_pHintMessageQueue ) return; if ( !m_bShowHints ) return; m_pHintMessageQueue->AddMessage( pMessage ); #else // On the client, we just send it straight to the hint hud element if ( cl_showhelp.GetBool() ) { IGameEvent *event = gameeventmanager->CreateEvent( "player_hintmessage" ); if ( event ) { event->SetString( "hintmessage", pMessage ); gameeventmanager->FireEventClientSide( event ); } } #endif }
void CGameFortsInfoZone::HandleOtherTeam(CBasePlayer *pPlayer) { if(pPlayer == NULL) return; // Si on a les infos, passer dans le trigger ne fait rien if(IsPlayerCarryingInfos(pPlayer)) return; // Les places sont prises § if(AreInfosSlotsFilled(pPlayer->GetTeamNumber())) return; // Bah, on peut prendre maintenant non ? AddPlayerToInfosList(pPlayer); pPlayer->IncrementFragCount(2); pPlayer->EmitSound("Gameplay.Forts.StoleData"); if(pPlayer->GetTeamNumber() == TEAM_PINK) pPlayer->m_nSkin = PLAYER_BONUS_NROSE; else pPlayer->m_nSkin = PLAYER_BONUS_NVERT; IGameEvent *event = gameeventmanager->CreateEvent( "player_death" ); if( event ) { event->SetInt("userid", 0 ); event->SetInt("attacker", pPlayer->GetUserID() ); event->SetString("weapon", "fortssteal" ); gameeventmanager->FireEvent( event ); } }
//----------------------------------------------------------------------------- // Purpose: // Input : *pVictim - // *pKiller - // *pInflictor - //----------------------------------------------------------------------------- void CSDKGameRules::DeathNotice( CBasePlayer *pVictim, const CTakeDamageInfo &info ) { int killer_ID = 0; // Find the killer & the scorer CSDKPlayer *pSDKPlayerVictim = ToSDKPlayer( pVictim ); CBaseEntity *pInflictor = info.GetInflictor(); CBaseEntity *pKiller = info.GetAttacker(); CBasePlayer *pScorer = GetDeathScorer( pKiller, pInflictor, pVictim ); // CSDKPlayer *pAssister = ToSDKPlayer( GetAssister( pVictim, pScorer, pInflictor ) ); // Work out what killed the player, and send a message to all clients about it int iWeaponID; const char *killer_weapon_name = GetKillingWeaponName( info, pSDKPlayerVictim, &iWeaponID ); if ( pScorer ) // Is the killer a client? { killer_ID = pScorer->GetUserID(); } IGameEvent * event = gameeventmanager->CreateEvent( "player_death" ); if ( event ) { event->SetInt( "userid", pVictim->GetUserID() ); event->SetInt( "attacker", killer_ID ); // event->SetInt( "assister", pAssister ? pAssister->GetUserID() : -1 ); event->SetString( "weapon", killer_weapon_name ); event->SetInt( "weaponid", iWeaponID ); event->SetInt( "damagebits", info.GetDamageType() ); event->SetInt( "customkill", info.GetDamageCustom() ); event->SetInt( "priority", 7 ); // HLTV event priority, not transmitted gameeventmanager->FireEvent( event ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTeamControlPoint::CaptureStart( int iCapTeam, int iNumCappingPlayers, int *pCappingPlayers ) { int iNumCappers = iNumCappingPlayers; float flLastOwnershipChangeTime = -1.f; CBaseEntity *pEnt = gEntList.FindEntityByClassname( NULL, GetControlPointMasterName() ); while( pEnt ) { CTeamControlPointMaster *pMaster = dynamic_cast<CTeamControlPointMaster *>( pEnt ); if ( pMaster && pMaster->IsActive() ) { flLastOwnershipChangeTime = pMaster->GetLastOwnershipChangeTime(); } pEnt = gEntList.FindEntityByClassname( pEnt, GetControlPointMasterName() ); } IGameEvent *event = gameeventmanager->CreateEvent( "teamplay_point_startcapture" ); if ( event ) { event->SetInt( "cp", m_iPointIndex ); event->SetString( "cpname", STRING( m_iszPrintName ) ); event->SetInt( "team", m_iTeam ); event->SetInt( "capteam", iCapTeam ); event->SetFloat( "captime", gpGlobals->curtime - flLastOwnershipChangeTime ); // safety check if ( iNumCappers > 8 ) { iNumCappers = 8; } char cappers[9]; // pCappingPlayers should be max length 8 int i; for( i = 0 ; i < iNumCappers ; i++ ) { cappers[i] = (char)pCappingPlayers[i]; } cappers[i] = '\0'; // pCappingPlayers is a null terminated list of player indices event->SetString( "cappers", cappers ); event->SetInt( "priority", 7 ); gameeventmanager->FireEvent( event ); } }
//--------------------------------------------------------------------------------- // Purpose: Player has said something we only want to ignore it x times //--------------------------------------------------------------------------------- bool ManiChatTriggers::ProcessIgnoreX ( player_t *player_ptr, chat_trigger_t *chat_trigger_ptr, const char *chat_string, bool teamonly, bool from_event ) { // This came from an event so just return true if (from_event) return true; // Check if we should let this one through or not based on this trigger count if (chat_trigger_ptr->ignore_count > 0) { if (chat_trigger_ptr->current_count == chat_trigger_ptr->ignore_count) { chat_trigger_ptr->current_count = 0; return true; } } chat_trigger_ptr->current_count ++; // Get CTeam pointer so we can use the proper team name in the log message // This will probably blow up on some mod when the CTeam header is changed :/ // Yup this blows up on hl2mp so I've switched to using the gametypes.txt file // instead. if (!gpManiGameType->IsValidActiveTeam(player_ptr->team)) return false; char *team_name = gpManiGameType->GetTeamLogName(player_ptr->team); // Just log the chat in format HLstatsX can recognise if ( teamonly ) { UTILLogPrintf( "\"%s<%i><%s><%s>\" say_team \"%s\"\n", player_ptr->name, player_ptr->user_id, player_ptr->steam_id, team_name , chat_string ); } else { UTILLogPrintf( "\"%s<%i><%s><%s>\" say \"%s\"\n", player_ptr->name, player_ptr->user_id, player_ptr->steam_id, team_name, chat_string ); } // Fire the event so other plugins can see it IGameEvent * event = gameeventmanager->CreateEvent( "player_say" ); if ( event ) // will be null if there are no listeners! { event->SetInt("userid", player_ptr->user_id ); event->SetString("text", chat_string ); event->SetInt("priority", 1 ); // HLTV event priority, not transmitted gameeventmanager->FireEvent( event ); } return false; }
void CGameRules::ClientSettingsChanged( CBasePlayer *pPlayer ) { const char *pszName = engine->GetClientConVarValue( pPlayer->entindex(), "name" ); const char *pszOldName = pPlayer->GetPlayerName(); // msg everyone if someone changes their name, and it isn't the first time (changing no name to current name) // Note, not using FStrEq so that this is case sensitive if ( pszOldName[0] != 0 && Q_strcmp( pszOldName, pszName ) ) { char text[256]; Q_snprintf( text,sizeof(text), "%s changed name to %s\n", pszOldName, pszName ); UTIL_ClientPrintAll( HUD_PRINTTALK, text ); IGameEvent * event = gameeventmanager->CreateEvent( "player_changename" ); if ( event ) { event->SetInt( "userid", pPlayer->GetUserID() ); event->SetString( "oldname", pszOldName ); event->SetString( "newname", pszName ); gameeventmanager->FireEvent( event ); } pPlayer->SetPlayerName( pszName ); } const char *pszFov = engine->GetClientConVarValue( pPlayer->entindex(), "fov_desired" ); if ( pszFov ) { int iFov = atoi(pszFov); iFov = clamp( iFov, 75, 90 ); pPlayer->SetDefaultFOV( iFov ); } // NVNT see if this user is still or has began using a haptic device const char *pszHH = engine->GetClientConVarValue( pPlayer->entindex(), "hap_HasDevice" ); if( pszHH ) { int iHH = atoi( pszHH ); pPlayer->SetHaptics( iHH != 0 ); } }
//--------------------------------------------------------- // Callback for the visibility monitor. //--------------------------------------------------------- bool CASW_Ammo::VismonCallback( CBaseEntity *pPickup, CBasePlayer *pViewingPlayer ) { CASW_Ammo *pPickupPtr = dynamic_cast < CASW_Ammo* >( pPickup ); if ( !pPickupPtr ) return true; IGameEvent * event = gameeventmanager->CreateEvent( "entity_visible" ); if ( event ) { event->SetInt( "userid", pViewingPlayer->GetUserID() ); event->SetInt( "subject", pPickupPtr->entindex() ); event->SetString( "classname", pPickupPtr->GetClassname() ); event->SetString( "entityname", STRING( pPickupPtr->GetEntityName() ) ); gameeventmanager->FireEvent( event ); } return false; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTeamControlPoint::InternalSetLocked( bool bLocked ) { if ( !bLocked && m_bLocked ) { // unlocked this point IGameEvent *event = gameeventmanager->CreateEvent( "teamplay_point_unlocked" ); if ( event ) { event->SetInt( "cp", m_iPointIndex ); event->SetString( "cpname", STRING( m_iszPrintName ) ); event->SetInt( "team", m_iTeam ); gameeventmanager->FireEvent( event ); } } else if ( bLocked && !m_bLocked ) { // locked this point IGameEvent *event = gameeventmanager->CreateEvent( "teamplay_point_locked" ); if ( event ) { event->SetInt( "cp", m_iPointIndex ); event->SetString( "cpname", STRING( m_iszPrintName ) ); event->SetInt( "team", m_iTeam ); gameeventmanager->FireEvent( event ); } } m_bLocked = bLocked; if ( ObjectiveResource() && GetPointIndex() < ObjectiveResource()->GetNumControlPoints() ) { ObjectiveResource()->SetCPLocked( GetPointIndex(), m_bLocked ); ObjectiveResource()->SetCPUnlockTime( GetPointIndex(), 0.0f ); } if ( !m_bLocked ) { m_flUnlockTime = -1; m_OnUnlocked.FireOutput( this, this ); SetContextThink( NULL, 0, CONTROL_POINT_UNLOCK_THINK ); } }
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void CEnvInstructorHint::InputEndHint( inputdata_t &inputdata ) { static int s_InstructorServerHintEventStop = 0; IGameEvent * event = gameeventmanager->CreateEvent( "instructor_server_hint_stop", false, &s_InstructorServerHintEventStop ); if ( event ) { event->SetString( "hint_name", GetEntityName().ToCStr() ); gameeventmanager->FireEvent( event ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTeamControlPoint::CaptureStart( void ) { IGameEvent *event = gameeventmanager->CreateEvent( "teamplay_point_startcapture" ); if ( event ) { event->SetInt( "cp", m_iPointIndex ); event->SetString( "cpname", STRING(m_iszPrintName) ); event->SetInt( "team", m_iTeam ); // pCappingPlayers is a null terminated list of player indices char capper[8]; Q_snprintf( capper, sizeof( capper ), "%d", entindex() ); event->SetString( "cappers", capper ); event->SetInt( "priority", 7 ); gameeventmanager->FireEvent( event ); } }
int DotaObjective::OnTakeDamage( const CTakeDamageInfo &inputInfo ) { if ( m_bMet ) return 0; if ( !(inputInfo.GetDamageType() & DMG_BULLET) ) { CHL2MP_Player * playerAttacker = ToHL2MPPlayer( inputInfo.GetAttacker() ); CreepMaker * maker = (CreepMaker*)gEntList.FindEntityByName( NULL, m_creepMakerName ); if ( !maker ) AssertMsg( false, "Objective can't find its creepmaker!\n" ); CAI_BaseNPC * guardian = (CAI_BaseNPC*)gEntList.FindEntityByName( NULL, m_guardianName ); if( guardian && guardian->IsAlive() ) { if( playerAttacker ) ClientPrint( playerAttacker, HUD_PRINTTALK, UTIL_VarArgs("The guradian is alive in this lane, you can't hurt the gate.\n") ); } else { m_timesHit++; m_timesHit = min(m_timesHit, OBJECTIVE_HEALTHI); // make sure times hit never goes above the maximum times an objective can be hit! CRecipientFilter user; user.AddRecipientsByTeam( this->GetTeam() ); user.MakeReliable(); char szText[200]; Q_snprintf( szText, sizeof(szText), "Your ally gate is under attack from an enemy!" ); UTIL_ClientPrintFilter( user, HUD_PRINTCENTER, szText ); if( playerAttacker ) ClientPrint( playerAttacker, HUD_PRINTTALK, UTIL_VarArgs("Gate has %i health left.\n", OBJECTIVE_HEALTHI - m_timesHit) ); if (m_timesHit >= OBJECTIVE_HEALTHI) { TakeAction(DOBJ_ACTION_CLOSE); } else { IGameEvent *pEvent = gameeventmanager->CreateEvent( "objectivegate_attacked" ); if ( pEvent ) { pEvent->SetString( "lane", GetLane() ); pEvent->SetInt( "team", this->GetTeamNumber() ); pEvent->SetFloat( "health", (OBJECTIVE_HEALTHF - m_timesHit)/OBJECTIVE_HEALTHF ); gameeventmanager->FireEvent( pEvent ); } } } } return 0; }
void CGameClient::Connect(const char * szName, int nUserID, INetChannel *pNetChannel, bool bFakePlayer) { CBaseClient::Connect( szName, nUserID, pNetChannel, bFakePlayer ); edict = EDICT_NUM( m_nEntityIndex ); // init PackInfo m_PackInfo.m_pClientEnt = edict; m_PackInfo.m_nPVSSize = sizeof( m_PackInfo.m_PVS ); // fire global game event IGameEvent *event = g_GameEventManager.CreateEvent( "player_connect" ); { event->SetInt( "userid", m_UserID ); event->SetInt( "index", m_nClientSlot ); event->SetString( "name", m_Name ); event->SetString("networkid", GetNetworkIDString() ); event->SetString( "address", m_NetChannel?m_NetChannel->GetAddress():"none" ); event->SetInt( "bot", m_bFakePlayer?1:0 ); g_GameEventManager.FireEvent( event ); } }
void CHL2MP_Player::UpdateAchievement(char *name, int amount) { if(sv_cheats->GetInt() != 0) return; IGameEvent* pEvent = gameeventmanager->CreateEvent("player_update_achiev", true); if(pEvent) { pEvent->SetInt("userid", this->GetUserID()); pEvent->SetString("name", name); pEvent->SetInt("amount", amount); gameeventmanager->FireEvent(pEvent); } }
void CASW_Jukebox::InputMusicStart( inputdata_t &inputdata ) { // Send each client the music start event IGameEvent * event = gameeventmanager->CreateEvent( "jukebox_play_random" ); if ( event ) { event->SetFloat( "fadeintime", m_fFadeInTime ); event->SetString( "defaulttrack", m_szDefaultMusic ); gameeventmanager->FireEvent( event ); // Stop stim music if it's playing ASWGameRules()->m_fPreventStimMusicTime = 5.0f; } }
void CGameDomCaptureZone::CaptureZoneTouch(CBaseEntity *pEntity) { CBasePlayer *pPlayer = ToBasePlayer(pEntity); if(!pPlayer) return; if(pPlayer->m_lifeState != LIFE_ALIVE) return; if(m_iZoneID == -1) return; if(HL2MPRules()->m_iDomZones[m_iZoneID] == pPlayer->GetTeamNumber()) return; // Déjà capturé par cette équipe if(gpGlobals->curtime < m_flLastCapture + 2.0f) return; m_flLastCapture = gpGlobals->curtime; HL2MPRules()->ResetDomTimer(); EmitSound("Gameplay.Domambient"); // Petite boucle moche pour reset toutes les zones CBaseEntity *pEntity2 = gEntList.FirstEnt(); while( pEntity2 ) { if(FClassnameIs(pEntity2, "game_dom_capturezone")) { CGameDomCaptureZone *pZone = dynamic_cast<CGameDomCaptureZone*>(pEntity2); pZone->ResetScoreTimer(); } pEntity2 = gEntList.NextEnt( pEntity2 ); } HL2MPRules()->m_iDomZones[m_iZoneID] = pPlayer->GetTeamNumber(); if(pPlayer->GetTeamNumber() == TEAM_PINK) m_OnPinkCapture.FireOutput(pPlayer, this); else m_OnGreenCapture.FireOutput(pPlayer, this); DevMsg("Zone %d captured by team %d\n", m_iZoneID, pPlayer->GetTeamNumber()); IGameEvent *event = gameeventmanager->CreateEvent( "player_death" ); if( event ) { event->SetInt("userid", 0 ); event->SetInt("attacker", pPlayer->GetUserID() ); event->SetString("weapon", "domcapture" ); gameeventmanager->FireEvent( event ); } }
void C_ASW_Campaign_Save::OnDataChanged( DataUpdateType_t updateType ) { BaseClass::OnDataChanged( updateType ); if ( Q_strcmp( m_szPreviousCampaignName, m_CampaignName ) ) { Q_strncpy( m_szPreviousCampaignName, m_CampaignName, sizeof( m_szPreviousCampaignName ) ); IGameEvent * event = gameeventmanager->CreateEvent( "campaign_changed" ); if ( event ) { event->SetString( "campaign", m_CampaignName ); gameeventmanager->FireEventClientSide( event ); } } }
//----------------------------------------------------------------------------- // Purpose: displays achievement progress notification in the HUD //----------------------------------------------------------------------------- void CBaseAchievement::ShowProgressNotification() { if ( !ShouldShowProgressNotification() ) return; IGameEvent *event = gameeventmanager->CreateEvent( "achievement_event" ); if ( event ) { event->SetString( "achievement_name", GetName() ); event->SetInt( "cur_val", m_iCount ); event->SetInt( "max_val", m_iGoal ); #ifdef GAME_DLL gameeventmanager->FireEvent( event ); #else gameeventmanager->FireEventClientSide( event ); #endif } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTeamControlPoint::CaptureBlocked( CBaseMultiplayerPlayer *pPlayer ) { if( strlen( STRING(m_iszPrintName) ) <= 0 ) return; IGameEvent *event = gameeventmanager->CreateEvent( "teamplay_capture_blocked" ); if ( event ) { event->SetInt( "cp", m_iPointIndex ); event->SetString( "cpname", STRING(m_iszPrintName) ); event->SetInt( "blocker", pPlayer->entindex() ); event->SetInt( "priority", 9 ); gameeventmanager->FireEvent( event ); } PlayerBlocked( pPlayer ); }
void CHLTVDirector::StartDelayMessage() { if ( m_nNextShotTick > gpGlobals->tickcount ) return; // check the next 8 seconds for interrupts/important events m_nNextShotTick = gpGlobals->tickcount + TIME_TO_TICKS( DEF_SHOT_LENGTH ); // game hasn't started yet, we are still in the broadcast delay hole IGameEvent *msg = gameeventmanager->CreateEvent( "hltv_message", true ); if ( msg ) { msg->SetString("text", "Please wait for broadcast to start ..." ); // send spectators the HLTV director command as a game event m_pHLTVServer->BroadcastEvent( msg ); gameeventmanager->FreeEvent( msg ); } StartBestFixedCameraShot( true ); }
void CGameFortsInfoZone::HandleSameTeam(CBasePlayer *pPlayer) { if(pPlayer == NULL) return; if(IsPlayerCarryingInfos(pPlayer)) { g_Teams[pPlayer->GetTeamNumber()]->AddScore(1); pPlayer->IncrementFragCount(3); IGameEvent *event = gameeventmanager->CreateEvent( "player_death" ); if( event ) { event->SetInt("userid", 0 ); event->SetInt("attacker", pPlayer->GetUserID() ); event->SetString("weapon", "fortsscore" ); gameeventmanager->FireEvent( event ); } ResetAllInfos(true); if(pPlayer->GetTeamNumber() == TEAM_PINK) m_OnPinkScore.FireOutput(pPlayer, this); else m_OnGreenScore.FireOutput(pPlayer, this); CRecipientFilter allyFilter, ennemyFilter; allyFilter.AddRecipientsByTeam(pPlayer->GetTeam()); ennemyFilter.AddRecipientsByTeam(g_Teams[pPlayer->GetTeamNumber()==TEAM_PINK?TEAM_GREEN:TEAM_PINK]); allyFilter.MakeReliable(); ennemyFilter.MakeReliable(); CBaseEntity::EmitSound(allyFilter, NULL, "Gameplay.Score.Friend"); CBaseEntity::EmitSound(ennemyFilter, NULL, "Gameplay.Score.Ennemy"); } }
//========================================================= // Deathnotice. //========================================================= void CHL2MPRules::DeathNotice( CBasePlayer *pVictim, const CTakeDamageInfo &info ) { #ifndef CLIENT_DLL // Work out what killed the player, and send a message to all clients about it const char *killer_weapon_name = "world"; // by default, the player is killed by the world int killer_ID = 0; // Find the killer & the scorer CBaseEntity *pInflictor = info.GetInflictor(); CBaseEntity *pKiller = info.GetAttacker(); CBasePlayer *pScorer = GetDeathScorer( pKiller, pInflictor ); // Custom kill type? if ( info.GetDamageCustom() ) { killer_weapon_name = GetDamageCustomString( info ); if ( pScorer ) { killer_ID = pScorer->GetUserID(); } } else { // Is the killer a client? if ( pScorer ) { killer_ID = pScorer->GetUserID(); if ( pInflictor ) { if ( pInflictor == pScorer ) { // If the inflictor is the killer, then it must be their current weapon doing the damage if ( pScorer->GetActiveWeapon() ) { killer_weapon_name = pScorer->GetActiveWeapon()->GetClassname(); } } else { killer_weapon_name = pInflictor->GetClassname(); // it's just that easy } } } else { killer_weapon_name = pInflictor->GetClassname(); } // strip the NPC_* or weapon_* from the inflictor's classname if ( strncmp( killer_weapon_name, "weapon_", 7 ) == 0 ) { killer_weapon_name += 7; } else if ( strncmp( killer_weapon_name, "npc_", 4 ) == 0 ) { killer_weapon_name += 4; } else if ( strncmp( killer_weapon_name, "func_", 5 ) == 0 ) { killer_weapon_name += 5; } else if ( strstr( killer_weapon_name, "physics" ) ) { killer_weapon_name = "physics"; } if ( strcmp( killer_weapon_name, "prop_combine_ball" ) == 0 ) { killer_weapon_name = "combine_ball"; } else if ( strcmp( killer_weapon_name, "grenade_ar2" ) == 0 ) { killer_weapon_name = "smg1_grenade"; } else if ( strcmp( killer_weapon_name, "satchel" ) == 0 || strcmp( killer_weapon_name, "tripmine" ) == 0) { killer_weapon_name = "slam"; } } IGameEvent *event = gameeventmanager->CreateEvent( "player_death" ); if( event ) { event->SetInt("userid", pVictim->GetUserID() ); event->SetInt("attacker", killer_ID ); event->SetString("weapon", killer_weapon_name ); event->SetInt( "priority", 7 ); gameeventmanager->FireEvent( event ); } #endif }
void CHL2MPRules::RestartGame() { // bounds check if ( mp_timelimit.GetInt() < 0 ) { mp_timelimit.SetValue( 0 ); } m_flGameStartTime = gpGlobals->curtime; if ( !IsFinite( m_flGameStartTime.Get() ) ) { Warning( "Trying to set a NaN game start time\n" ); m_flGameStartTime.GetForModify() = 0.0f; } CleanUpMap(); // now respawn all players for (int i = 1; i <= gpGlobals->maxClients; i++ ) { CHL2MP_Player *pPlayer = (CHL2MP_Player*) UTIL_PlayerByIndex( i ); if ( !pPlayer ) continue; if ( pPlayer->GetActiveWeapon() ) { pPlayer->GetActiveWeapon()->Holster(); } pPlayer->RemoveAllItems( true ); respawn( pPlayer, false ); pPlayer->Reset(); } // Respawn entities (glass, doors, etc..) CTeam *pRebels = GetGlobalTeam( TEAM_REBELS ); CTeam *pCombine = GetGlobalTeam( TEAM_COMBINE ); if ( pRebels ) { pRebels->SetScore( 0 ); } if ( pCombine ) { pCombine->SetScore( 0 ); } m_flIntermissionEndTime = 0; m_flRestartGameTime = 0.0; m_bCompleteReset = false; IGameEvent * event = gameeventmanager->CreateEvent( "round_start" ); if ( event ) { event->SetInt("fraglimit", 0 ); event->SetInt( "priority", 6 ); // HLTV event priority, not transmitted event->SetString("objective","DEATHMATCH"); gameeventmanager->FireEvent( event ); } }