AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   Solved [REQ]TF2 Overlay on client connect (https://forums.alliedmods.net/showthread.php?t=289791)

Walgrim 10-29-2016 18:44

[REQ]TF2 Overlay on client connect
 
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? >_<

Walgrim 10-30-2016 13:10

Re: [REQ]TF2 Overlay on client connect
 
Nobody ? >_<'

Arkarr 10-30-2016 13:23

Re: [REQ]TF2 Overlay on client connect
 
Uh ? It worked for me, at least, that's what I remember.

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

Walgrim 10-30-2016 13:50

Re: [REQ]TF2 Overlay on client connect
 
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)

Arkarr 10-30-2016 14:07

Re: [REQ]TF2 Overlay on client connect
 
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);



Walgrim 10-30-2016 14:21

Re: [REQ]TF2 Overlay on client connect
 
Ok thanks a lot, your plugin support animated vtf too?

Arkarr 10-30-2016 14:22

Re: [REQ]TF2 Overlay on client connect
 
Quote:

Originally Posted by Walgrim (Post 2466393)
Ok thanks a lot, your plugin support animated vtf too?

Not tested, you tell me :) But I think it should, yes.

Walgrim 10-30-2016 14:31

Re: [REQ]TF2 Overlay on client connect
 
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

Arkarr 10-30-2016 14:37

Re: [REQ]TF2 Overlay on client connect
 
Fixed my code, I forgot to remove a debug line haha.

Walgrim 10-30-2016 14:41

Re: [REQ]TF2 Overlay on client connect
 
Thanks a llooooottttt ! +1000 rep ;P
EDIT : Works for animated vtf too ;)


All times are GMT -4. The time now is 12:54.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.