View Single Post
rogeraabbccdd
Veteran Member
Join Date: Jun 2015
Location: de_dust2
Old 04-08-2018 , 22:45   Re: |CSGO| Custom RoundEndOverlay > Round Draw
Reply With Quote #2

PHP Code:
#include <sourcemod> 
#include <sdktools> 

#pragma newdecls required 

ConVar Cvar_OverlayCvar_Time;

char overlay_path[PLATFORM_MAX_PATH];
float overlay_time;

public 
Plugin myinfo =   

    
name "[CS:GO] Round Draw Overlay",  
    
author "Kento",  
    
description "Display overlay when round draw.",  
    
version "1.0",  
    
url "http://steamcommunity.com/id/kentomatoryoshika/" 
}; 

public 
void OnPluginStart() 

    
HookEvent("round_end"Event_RoundEnd); 
    
    
Cvar_Overlay CreateConVar("sm_overlay""""Overlay to display, no need to add materials folder and vmt, vtf here."); 
    
Cvar_Time CreateConVar("sm_overlay_time""5.0""How long should overlay display?"); 
    
    
AutoExecConfig();


public 
void OnConfigsExecuted()
{
    
Cvar_Overlay.GetString(overlay_pathsizeof(overlay_path));
    
overlay_time Cvar_Time.FloatValue;
}

public 
void OnMapStart() 

    if(!
StrEqual(overlay_path""))
    {
        
char dlpath1[1024], dlpath2[1024];
        
Format(dlpath1sizeof(dlpath1), "materials/%s.vtf"overlay_path);
        
Format(dlpath2sizeof(dlpath2), "materials/%s.vmt"overlay_path);
        
AddFileToDownloadsTable(dlpath1);
        
AddFileToDownloadsTable(dlpath2);
        
PrecacheDecal(dlpath1true); 
        
PrecacheDecal(dlpath2true); 
    }


public 
Action Event_RoundEnd(Handle event, const char[] namebool dontBroadcast

    
char message[256]; 
    
GetEventString(event"message"messagesizeof(message));
    if(
StrEqual(message"#SFUI_Notice_Round_Draw"false))
    {
        for (
int i 1<= MaxClientsi++) 
        {
            if (
IsValidClient(i) && !IsFakeClient(i)) 
            {
                
SetClientOverlay(ioverlay_path);
                
CreateTimer(overlay_timeDeleteOverlayi);
            }
        }
    }


stock bool IsValidClient(int client

    if (
client <= 0) return false
    if (
client MaxClients) return false
    if (!
IsClientConnected(client)) return false
    return 
IsClientInGame(client); 


// Code taken from csgoware  
// https://forums.alliedmods.net/showthread.php?p=2500764 
bool SetClientOverlay(int clientchar[] strOverlay

    if (
IsValidClient(client) && !IsFakeClient(client)) 
    { 
        
//int iFlags = GetCommandFlags("r_screenoverlay") & (~FCVAR_CHEAT); 
        //SetCommandFlags("r_screenoverlay", iFlags);  
        
ClientCommand(client"r_screenoverlay \"%s\""strOverlay); 
        return 
true
    } 
    return 
false


public 
Action DeleteOverlay(Handle tmrany client

    if (
IsValidClient(client) && !IsFakeClient(client)) 
    { 
        
SetClientOverlay(client""); 
    } 
    return 
Plugin_Handled

Also available on Github
Attached Files
File Type: sp Get Plugin or Get Source (round_end_overlay.sp - 649 views - 2.5 KB)
__________________

Please keep in mind, nobody have responsibility to help you, especially who don't try to Google first.
I only read messages in Chinese and English.

GitHub | Discord:Kento#2118

Last edited by rogeraabbccdd; 04-10-2018 at 20:15. Reason: Update
rogeraabbccdd is offline