View Single Post
sekac
Senior Member
Join Date: Nov 2016
Old 05-17-2018 , 08:02   Re: BOMB Effects Camera
Reply With Quote #6

Here is this test plugin, I know it works if you plant the bomb and die with no teammates left alive and there is at least 1 ct left alive. You must be in first person camera too. Hopefully it helps someone.
Edited this plugin: Link

PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>

new PLUGIN[] = "Spectator Camera";
new 
VERSION[] = "0.1 Beta";
new 
AUTHOR[] = "Multiply";

new 
MODEL[] = "models/player/vip/vip.mdl";

new 
bool:bombPlanted;
new 
giCameraEntity;
new 
bool:gbCameraActive[33];

new 
bool:specEnabledT;
new 
bool:specEnabledCT;

new const 
g_szBombModel[] = "models/w_c4.mdl"

new Float:g_fBombOrigin[3]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);

    
register_clcmd("camera",     "CameraToggle");
    
register_clcmd("+camera",     "CameraActivate");
    
register_clcmd("-camera",     "CameraDeactivate");
    
    
register_forward(FM_StartFrame"fwdServerFrame");
    
    
register_logevent("logevent_PlantedTheBomb"3"2=Planted_The_Bomb")
    
    
register_event("DeathMsg""EventDeath""a")
    
    
CameraInit();
}

public 
plugin_precache()
    
precache_model(MODEL);

public 
juhp_eventPlayerSpawn(iPlayerId) {
    
CameraDeactivate(iPlayerId);
}

public 
client_disconnect(iPlayerId) {
    
CameraDeactivate(iPlayerId);
    
countAlivePlayers(iPlayerId);
}
    
public 
CameraInit() {
    
giCameraEntity engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));     // Create Camera Entity
    
set_pev(giCameraEntity,     pev_classname,         "Multiply_Camera");                 // Give the Camera a name
    
set_pev(giCameraEntity,     pev_solid,         SOLID_NOT);                    // Make the Camera semiclip
    
engfunc(EngFunc_SetModel,     giCameraEntity,     MODEL);                     // Set Camera Model (Needed, for EngFunc_SetView to work properly)
    
set_pev(giCameraEntity,     pev_movetype,         MOVETYPE_FLY);                    // Stop the Camera from dropping on the ground
    
set_pev(giCameraEntity,     pev_health,        1.0);                        // Set Camera health to 1
    
set_pev(giCameraEntity,     pev_takedamage,        0.0);                        // Make Camera invincible
    
set_pev(giCameraEntity,     pev_rendermode,     5);                        // Fix rendermode
    
set_pev(giCameraEntity,     pev_renderamt,         0.0);                        // Make it less visable
    
set_pev(giCameraEntity,     pev_angles,         Float:{0.0180.00.0});            // Test using angles
    
CameraSetOrigin(Float:{0.00.00.0});                                    // Place Camera in the middle of the map
}


public 
CameraSetOrigin(Float:fOrigin[3]) {
    new 
Float:fMins[3], Float:fMaxs[3];
    
pev(giCameraEntitypev_minsfMins);
    
pev(giCameraEntitypev_maxsfMaxs);
    
engfunc(EngFunc_SetSizegiCameraEntityfMinsfMaxs);

    return 
engfunc(EngFunc_SetOrigingiCameraEntityfOrigin);
}

public 
CameraToggle(iPlayerId) {
    switch (
gbCameraActive[iPlayerId]) {
        case 
true:     CameraDeactivate(iPlayerId);
        case 
false:     CameraActivate(iPlayerId);
    }
    return 
PLUGIN_HANDLED;
}
public 
CameraActivate(iPlayerId) {
    if (!
is_user_alive(iPlayerId)) {
        
engfunc(EngFunc_SetViewiPlayerIdgiCameraEntity);
        
gbCameraActive[iPlayerId] = true;
    }
    
    return 
PLUGIN_HANDLED;
}

public 
CameraDeactivate(iPlayerId) {
    
engfunc(EngFunc_SetViewiPlayerIdiPlayerId);
    
gbCameraActive[iPlayerId] = false;
    return 
PLUGIN_HANDLED;
}

public 
logevent_PlantedTheBomb()
{
    new 
iC4 = -1
    
if((iC4 find_ent_by_model(iC4"grenade"g_szBombModel))) 
    {  
        
pev(iC4pev_origing_fBombOrigin)
        
CameraSetOrigin(g_fBombOrigin)
        
bombPlanted true
    
}
}

public 
countAlivePlayers(id) {
    if(!
bombPlanted) return
    new 
iPlayers[32], iTAliveiCTAlive
    
get_players(iPlayersiTAlive"ae""TERRORIST"); 
    
get_players(iPlayersiCTAlive"ae""CT"); 
    
    
specEnabledT = !clamp(iTAlive01)
    
specEnabledCT = !clamp(iCTAlive01)

    for(new 
032i++)
        if(
get_user_team(i) == && specEnabledT || get_user_team(i) == && specEnabledCT)
            
set_task(5.0"CameraActivate"i)

}

public 
EventDeath() {
    new 
id read_data(2)
    
countAlivePlayers(id)

sekac is offline