Raised This Month: $14 Target: $400
 3% 

Solved [REQ]TF2 Overlay on client connect


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Walgrim
Member
Join Date: Dec 2015
Location: France
Old 10-29-2016 , 19:44   [REQ]TF2 Overlay on client connect
Reply With Quote #1

Hello !

I need help in a plugin that I'm interested in, I was looking for a plugin displaying an overlay when a client is in the game (all the time).
Then I've found this thread : https://forums.alliedmods.net/showthread.php?p=2335800

And I tried the code of Arkarr to do what I want.
This code :
PHP Code:
#include <sourcemod>
#include <sdktools>

#define PLUGIN_AUTHOR "Arkarr (with ReFlexPoison functions)"
#define PLUGIN_VERSION "0.00"

Handle CVAR_Overlay;
char gPath[75];

public 
Plugin myinfo 
{
    
name "[TF2 / CS:S / MORE?] Persistant screen overlay",
    
author PLUGIN_AUTHOR,
    
description "Display a persistant screen overlay !",
    
version PLUGIN_VERSION,
    
url "http://www.sourcemod.net"
};

public 
void OnPluginStart()
{
    
CVAR_Overlay CreateConVar("sm_pso_overlay_path""path/relative/to/materials/folder.vtf""The path to the material file for the overlay.");
}

public 
void OnConfigsExecuted()
{
    
GetConVarString(CVAR_OverlaygPathsizeof(gPath));
    
PrecacheDecal(gPathtrue);    
}

public 
void OnClientConnected(client)
{
    
DisplayScreenOverlay(clientgPath);    
}

stock void DisplayScreenOverlay(int client, const char[] sFile)
{
    
int iFlags GetCommandFlags("r_screenoverlay");
    
SetCommandFlags("r_screenoverlay"iFlags &~ FCVAR_CHEAT);

    if(
IsClientInGame(client))
        
ClientCommand(client"r_screenoverlay \"%s\""sFile);

    
SetCommandFlags("r_screenoverlay"iFlags);
}

stock void ClearScreenOverlay(int client)
{
    
int iFlags GetCommandFlags("r_screenoverlay");
    
SetCommandFlags("r_screenoverlay"iFlags &~ FCVAR_CHEAT);

    if(
IsClientInGame(client))
        
ClientCommand(client"r_screenoverlay \"\"");

    
SetCommandFlags("r_screenoverlay"iFlags);

It doesn't worked, I've written the cvar in sourcemod.cfg like this :
PHP Code:
sm_pso_overlay_path "materials/overlays/custom/megusta.vtf" 
or like that :
PHP Code:
sm_pso_overlay_path "overlays/custom/megusta.vtf" 
Whatever I tried it doesn't worked
PS : megusta.vtf is downloaded by the clients (with a downloader) and is exactly where it is, I've tried with the plugin "Screen Overlays" and it worked perfectly

Anyone can help? >_<
__________________

Last edited by Walgrim; 10-30-2016 at 17:01.
Walgrim is online now
Walgrim
Member
Join Date: Dec 2015
Location: France
Old 10-30-2016 , 14:10   Re: [REQ]TF2 Overlay on client connect
Reply With Quote #2

Nobody ? >_<'
__________________
Walgrim is online now
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 10-30-2016 , 14:23   Re: [REQ]TF2 Overlay on client connect
Reply With Quote #3

Uh ? It worked for me, at least, that's what I remember.

EDIT: Oh... I never tested it haha.
__________________

Last edited by Arkarr; 10-30-2016 at 14:55.
Arkarr is offline
Walgrim
Member
Join Date: Dec 2015
Location: France
Old 10-30-2016 , 14:50   Re: [REQ]TF2 Overlay on client connect
Reply With Quote #4

Well I don't know, can you help me because it didn't work for me ><'
How you do the path of this one? (I tried like everything)
__________________
Walgrim is online now
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 10-30-2016 , 15:07   Re: [REQ]TF2 Overlay on client connect
Reply With Quote #5

Tested and worked !

Exemple of CVAR :
sm_pso_overlay_path "overlays\custom\megusta.vtf"

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

#define PLUGIN_AUTHOR     "Arkarr (with ReFlexPoison functions)"
#define PLUGIN_VERSION     "1.00"

Handle CVAR_Overlay;
char gPath[75];

public 
Plugin myinfo 
{
    
name "[TF2 / CS:S / MORE?] Persistant screen overlay",
    
author PLUGIN_AUTHOR,
    
description "Display a persistant screen overlay !",
    
version PLUGIN_VERSION,
    
url "http://www.sourcemod.net"
};

public 
void OnPluginStart()
{
    
CVAR_Overlay CreateConVar("sm_pso_overlay_path""path/relative/to/materials/folder.vtf""The path to the material file for the overlay.");
    
HookConVarChange(CVAR_OverlayOverlayChange);
    
    
HookEvent("player_spawn"Event_PlayerSpawn);
}

public 
void OnMapStart()
{
    
PrecacheOverlay();
}

public 
void OverlayChange(Handle convar, const char[] oldValue, const char[] newValue)
{
    
PrecacheOverlay();
}

public 
void PrecacheOverlay()
{
    
GetConVarString(CVAR_OverlaygPathsizeof(gPath));
    if(
FileExists(gPath))
    {
         
AddFileToDownloadsTable(gPath);
         
PrecacheDecal(gPathtrue);   
    }
}

public 
void Event_PlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int userID GetEventInt(event"userid");
    
CreateTimer(1.0TMR_ScreenOverlayuserID);
}

public 
Action TMR_ScreenOverlay(Handle tmrany userID)
{
    
int client GetClientOfUserId(userID);
    
    if(
client != -1)
             
DisplayScreenOverlay(clientgPath);
}

stock void DisplayScreenOverlay(int client, const char[] sFile)
{
    
int iFlags GetCommandFlags("r_screenoverlay");
    
SetCommandFlags("r_screenoverlay"iFlags &~ FCVAR_CHEAT);

    if(
IsClientInGame(client))
        
ClientCommand(client"r_screenoverlay \"%s\""sFile);

    
SetCommandFlags("r_screenoverlay"iFlags);
}

stock void ClearScreenOverlay(int client)
{
    
int iFlags GetCommandFlags("r_screenoverlay");
    
SetCommandFlags("r_screenoverlay"iFlags &~ FCVAR_CHEAT);

    if(
IsClientInGame(client))
        
ClientCommand(client"r_screenoverlay \"\"");

    
SetCommandFlags("r_screenoverlay"iFlags);

__________________

Last edited by Arkarr; 10-31-2016 at 13:16.
Arkarr is offline
Walgrim
Member
Join Date: Dec 2015
Location: France
Old 10-30-2016 , 15:21   Re: [REQ]TF2 Overlay on client connect
Reply With Quote #6

Ok thanks a lot, your plugin support animated vtf too?
__________________
Walgrim is online now
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 10-30-2016 , 15:22   Re: [REQ]TF2 Overlay on client connect
Reply With Quote #7

Quote:
Originally Posted by Walgrim View Post
Ok thanks a lot, your plugin support animated vtf too?
Not tested, you tell me But I think it should, yes.
__________________
Arkarr is offline
Walgrim
Member
Join Date: Dec 2015
Location: France
Old 10-30-2016 , 15:31   Re: [REQ]TF2 Overlay on client connect
Reply With Quote #8

Ok thanks a lot, there's just one last thing, it's just spamming 5 times the path of the vtf on the server like this :
overlays\custom\megusta.vtf
overlays\custom\megusta.vtf
overlays\custom\megusta.vtf
overlays\custom\megusta.vtf
overlays\custom\megusta.vtf

Can you fix it? Or I need to leave something?
EDIT : More than 5 times
__________________

Last edited by Walgrim; 10-30-2016 at 15:32.
Walgrim is online now
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 10-30-2016 , 15:37   Re: [REQ]TF2 Overlay on client connect
Reply With Quote #9

Fixed my code, I forgot to remove a debug line haha.
__________________
Arkarr is offline
Walgrim
Member
Join Date: Dec 2015
Location: France
Old 10-30-2016 , 15:41   Re: [REQ]TF2 Overlay on client connect
Reply With Quote #10

Thanks a llooooottttt ! +1000 rep ;P
EDIT : Works for animated vtf too ;)
__________________

Last edited by Walgrim; 10-30-2016 at 20:11.
Walgrim is online now
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:32.


Powered by vBulletin®
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Theme made by Freecode