Raised This Month: $51 Target: $400
 12% 

[Help] Screen Overlay


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Skippy
Senior Member
Join Date: Nov 2011
Old 01-02-2013 , 20:21   [Help] Screen Overlay
Reply With Quote #1

So what I'm trying to do is get the command to show the image on the screen of the client.

Here is the sp

Code:
#pragma semicolon 1
#include <sdktools>
#include <sourcemod>

public Plugin:myinfo =
{
	name = "Rules Image",
	author = "Skipper",
	description = "Rules Agreement Image",
};

#define RulesVTF	"custom/rules.vtf"
#define RulesVMT	"custom/rules.vmt"

public OnPluginStart()
{
	RegAdminCmd("sm_rule", Command_Rule, ADMFLAG_BAN, "sm_rule <name>");
}

public OnMapStart()
{
	PrecacheGeneric(RulesVTF, true);
	AddFileToDownloadsTable("materials/custom/rules.vtf");
	
	PrecacheGeneric(RulesVMT, true);
	AddFileToDownloadsTable("materials/custom/rules.vmt");
}	

public Action:Command_Rule(client, args)
{
	if ( args < 1 )
	{
		ReplyToCommand(client, "[SM] Usage: sm_rule <client>");
		return Plugin_Handled;
	}

	decl String:player[64];
	GetCmdArg(1, player, sizeof(player));

	new String:target_name[MAX_TARGET_LENGTH];
	new target_list[MAXPLAYERS], target_count;
	new bool:tn_is_ml;
 
	if ( (target_count = ProcessTargetString(
			player,
			client,
			target_list,
			MAXPLAYERS,
			COMMAND_FILTER_CONNECTED|COMMAND_FILTER_NO_BOTS,
			target_name,
			sizeof(target_name),
			tn_is_ml)) <= 0 )
	{
		ReplyToCommand(client, "[SM] No matching client");
		return Plugin_Handled;
	}

	for ( new i=0; i<target_count; i++ )
	{
		Rules(client, target_list[i]);
	}

	return Plugin_Handled;
}

stock Rules(client, target)
{
	new Handle:cvarCheats;
	cvarCheats = FindConVar("sv_cheats");

	if ( target > 0 && target <= MaxClients )
	{
		if ( IsClientConnected(target) && IsClientInGame(target) )
		{
			SendConVarValue(target, cvarCheats, "1");
			ClientCommand(target, "r_screenoverlay custom/rules");
			SendConVarValue(target, cvarCheats, "0");

			CreateTimer(5.0, Timer_Rules, target, TIMER_FLAG_NO_MAPCHANGE);
		}
	}
}

public Action:Timer_Rules(Handle:timer, any:client)
{
	new Handle:cvarCheats;
	cvarCheats = FindConVar("sv_cheats");

	if ( IsClientConnected(client) && IsClientInGame(client) )
	{
		SendConVarValue(client, cvarCheats, "1");
		ClientCommand(client, "r_screenoverlay off");
		SendConVarValue(client, cvarCheats, "0");
	}
}

This is the vmt code. (The VTF is 2048 x 2048 )
Code:
"LightmappedGeneric"
{
	"$basetexture" "custom/rules"
}

So the problem is that the image isn't coming up on the screen. It downloads fine and there aren't any errors within console or error log. I was wondering if anyone knew how to fix this?

Last edited by Skippy; 01-02-2013 at 20:24.
Skippy is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 01-02-2013 , 21:02   Re: [Help] Screen Overlay
Reply With Quote #2

did you look at the code of this plugin to compare how it's done vs how you're doing it?
__________________
View my Plugins | Donate
TnTSCS is offline
Skippy
Senior Member
Join Date: Nov 2011
Old 01-02-2013 , 21:10   Re: [Help] Screen Overlay
Reply With Quote #3

Quote:
Originally Posted by TnTSCS View Post
did you look at the code of this plugin to compare how it's done vs how you're doing it?
Only difference from that and mine is that they used PrecacheDecal and I tried using PrecacheDecal and it just either came up as an error in console or it crashed my tf2.
Skippy is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 01-02-2013 , 22:29   Re: [Help] Screen Overlay
Reply With Quote #4

that and you're changing sv_cheats? Also, maybe validate !IsFakeClient(target)

I've never messed with overlays, so I don't know if what I'm helping you with will work or not
__________________
View my Plugins | Donate
TnTSCS is offline
Skippy
Senior Member
Join Date: Nov 2011
Old 01-02-2013 , 23:11   Re: [Help] Screen Overlay
Reply With Quote #5

I changed the coding to take out the cheats thing and the same thing happened. Nothing showed up.

Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "1.0"

public Plugin:myinfo =
{
	name = "Rules Image",
	author = "Skipper",
	description = "Rules Agreement Image",
	version = PLUGIN_VERSION,
};

#define RulesVTF	"custom/rules.vtf"
#define RulesVMT	"custom/rules.vmt"

public OnPluginStart()
{
	RegAdminCmd("sm_rule", Command_Rule, ADMFLAG_SLAY, "sm_rule <#userid|name>");
}

public OnMapStart()
{
	PrecacheGeneric(RulesVTF, true);
	AddFileToDownloadsTable("materials/custom/rules.vtf");
	
	PrecacheGeneric(RulesVMT, true);
	AddFileToDownloadsTable("materials/custom/rules.vmt");
}	

public Action:Command_Rule(client, args)
{
	if ( args < 1 )
	{
		ReplyToCommand(client, "[SM] Usage: sm_rule <client>");
		return Plugin_Handled;
	}

	decl String:player[64];
	GetCmdArg(1, player, sizeof(player));

	new String:target_name[MAX_TARGET_LENGTH];
	new target_list[MAXPLAYERS], target_count;
	new bool:tn_is_ml;
 
	if ( (target_count = ProcessTargetString(
			player,
			client,
			target_list,
			MAXPLAYERS,
			COMMAND_FILTER_CONNECTED|COMMAND_FILTER_NO_BOTS,
			target_name,
			sizeof(target_name),
			tn_is_ml)) <= 0 )
	{
		ReplyToCommand(client, "[SM] No matching client");
		return Plugin_Handled;
	}

	for ( new i=0; i<target_count; i++ )
	{
		Rules(client, target_list[i]);
	}

	return Plugin_Handled;
}

stock Rules(client, target)
{
	if ( target > 0 && target <= MaxClients )
	{
		if ( IsClientConnected(target) && IsClientInGame(target) && !IsFakeClient(client) )
		{
			ClientCommand(target, "r_screenoverlay decals/rules");

			CreateTimer(5.0, Timer_Rules, target, TIMER_FLAG_NO_MAPCHANGE);
		}
	}
}

public Action:Timer_Rules(Handle:timer, any:client)
{
	if ( IsClientConnected(client) && IsClientInGame(client) && !IsFakeClient(client) )
	{
		ClientCommand(client, "r_screenoverlay off");
	}
}
Skippy is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 01-03-2013 , 12:03   Re: [Help] Screen Overlay
Reply With Quote #6

and if you type
r_screenoverlay decals/rules
into your game console, you see the overlay?
__________________
View my Plugins | Donate
TnTSCS is offline
andi67
Veteran Member
Join Date: Mar 2007
Location: Somewhere near you!!!
Old 01-03-2013 , 23:42   Re: [Help] Screen Overlay
Reply With Quote #7

Quote:
#define RulesVTF "custom/rules.vtf"
#define RulesVMT "custom/rules.vmt"
try:

Quote:
#define RulesVTF "materials/custom/rules.vtf"
#define RulesVMT "materials/custom/rules.vmt"
__________________
Waiting for HL3,Day of Defeat3 ,but will it ever come? So I'm gonna play COD WW2.>>>>SM_SKINCHOOSER<<<<
>>You need Models for DODS/CSS/CSGO , than click here!!!<<

Last edited by andi67; 01-03-2013 at 23:43.
andi67 is offline
Skippy
Senior Member
Join Date: Nov 2011
Old 01-05-2013 , 01:13   Re: [Help] Screen Overlay
Reply With Quote #8

Quote:
Originally Posted by TnTSCS View Post
and if you type
r_screenoverlay decals/rules
into your game console, you see the overlay?
Okay I typed that into console and nothing came up.
Skippy is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 01-05-2013 , 17:56   Re: [Help] Screen Overlay
Reply With Quote #9

maybe the file isn't setup correctly for an overlay? I've never made an overlay, so I don't know... but there is an overlay over in the zombie:reloaded forums you could grab for trying out
__________________
View my Plugins | Donate
TnTSCS is offline
ajr1234
Senior Member
Join Date: Mar 2011
Location: Chicago, IL, U.S.A.
Old 01-06-2013 , 23:42   Re: [Help] Screen Overlay
Reply With Quote #10

I made these stocks a while back.

Just PrecacheImageOnServer() for all your screen images during OnMapStart, and use DisplayScreenImage() when you want to display it to a client.

Also, change the shader from LightmappedGeneric to MonitorScreen. Although the wiki says "you can use any shader you want," I found that the pixel shader would blend alphas with any shader other than MonitorScreen, so the wiki's statement appears to be false.

PHP Code:
/**
* PrecacheImageOnServer()
*   Prepares an image stored on the server to be transferred
*   to the client on connect, and also precache the image
*   for use in-game.
*
* Example use:
*   If an image called img.vtf existed in materials/foo/
*   folder, we would call the function like so:
*       PrecacheImageOnServer("foo/img");
*
*   Do not include the "materials/" or the extension in the
*   argument.
*
* Returns: true when successful, NULL or 0 when something failed.
**/
public bool:PrecacheImageOnServer(const String:imgfile[])
{
    new 
String:overlays_file[64];
    new 
String:overlays_dltable[64];

    
Format(overlays_filesizeof(overlays_file), "%s.vtf"imgfile);
    
PrecacheDecal(overlays_filetrue);
    
Format(overlays_dltablesizeof(overlays_dltable), "materials/%s.vtf"imgfile);
    
AddFileToDownloadsTable(overlays_dltable);

    
Format(overlays_filesizeof(overlays_file), "%s.vmt"imgfile);
    
PrecacheDecal(overlays_filetrue);
    
Format(overlays_dltablesizeof(overlays_dltable), "materials/%s.vmt"imgfile);
    
AddFileToDownloadsTable(overlays_dltable);

    return 
true;
}

/**
* ClearScreen() clears all images on the client's screen
**/
public ClearScreenImages(client)
{
    if(
client && IsValidEntity(client))
    
ClientCommand(client"r_screenoverlay \"\"");
}

/**
* DisplayScreenImage() displays an image to the screen
**/
public DisplayScreenImage(client, const String:imgfile[])
{
    if(
client && IsValidEntity(client))
    
ClientCommand(client"r_screenoverlay \"%s.vtf\""imgfile);
}

/**
* DisplayScreenImageAndRemove()
*    Displays an image to the screen for a period of time
**/
public DisplayScreenImageAndRemove(client, const String:imgfile[], Float:duration)
{
    if(
client && IsValidEntity(client))
    {
        
ClientCommand(client"r_screenoverlay \"%s.vtf\""imgfile);
        
CreateTimer(durationRemoveScreenImageclient);
    }
}

// timer remove image
public Action:RemoveScreenImage(Handle:timerany:client)
{
    
ClearScreenImages(client);
    return 
Plugin_Stop;

ajr1234 is offline
Reply



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 20:45.


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