AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [CS:GO] hLiveCredits (https://forums.alliedmods.net/showthread.php?t=311364)

alexr153 10-14-2018 21:36

[CS:GO] hLiveCredits
 
2 Attachment(s)
Description
This is a very basic plugin to show the number of credits you have live. This plugin is meant for Zephyrus store. If any errors or additional features I could add do a quick reply and I'll get on it ASAP.

Commands
sm_chud (Enables or disables the hud text)

Change Log
Code:

1.0.1 - Fixed when showing a client is VIP when spectating when they are not
1.0 - Plugin Released


Cruze 10-15-2018 02:32

Re: [CS:GO] hLiveCredits
 
Good Job!!

qNiGHT 06-26-2019 14:19

Re: [CS:GO] hLiveCredits
 
L 06/26/2019 - 20:51:41: [SM] [1] Line 115, plugin.sp::ShowLiveCredits
L 06/26/2019 - 20:51:42: [SM] Exception reported: Entity 13 (13) is invalid
L 06/26/2019 - 20:51:42: [SM] Blaming: hLiveCredits.smx
L 06/26/2019 - 20:51:42: [SM] Call stack trace:
L 06/26/2019 - 20:51:42: [SM] [0] GetEntProp
L 06/26/2019 - 20:51:42: [SM] [1] Line 115, plugin.sp::ShowLiveCredits
L 06/26/2019 - 20:51:42: [SM] Exception reported: Entity 14 (14) is invalid
L 06/26/2019 - 20:51:42: [SM] Blaming: hLiveCredits.smx
L 06/26/2019 - 20:51:42: [SM] Call stack trace:
L 06/26/2019 - 20:51:42: [SM] [0] GetEntProp
L 06/26/2019 - 20:51:42: [SM] [1] Line 115, plugin.sp::ShowLiveCredits
L 06/26/2019 - 20:51:42: [SM] Exception reported: Entity 12 (12) is invalid
L 06/26/2019 - 20:51:42: [SM] Blaming: hLiveCredits.smx
L 06/26/2019 - 20:51:42: [SM] Call stack trace:
L 06/26/2019 - 20:51:42: [SM] [0] GetEntProp
L 06/26/2019 - 20:51:42: [SM] [1] Line 115, plugin.sp::ShowLiveCredits
L 06/26/2019 - 20:51:42: [SM] Exception reported: Entity 11 (11) is invalid
L 06/26/2019 - 20:51:42: [SM] Blaming: hLiveCredits.smx
L 06/26/2019 - 20:51:42: [SM] Call stack trace:
L 06/26/2019 - 20:51:42: [SM] [0] GetEntProp
L 06/26/2019 - 20:51:42: [SM] [1] Line 115, plugin.sp::ShowLiveCredits


my console spam these errors

Cruze 06-26-2019 14:57

Re: [CS:GO] hLiveCredits
 
PHP Code:

#pragma semicolon 1

#define DEBUG

#define PLUGIN_AUTHOR "hAlexr"
#define PLUGIN_VERSION "1.0.1"
#define CHAT_TAGS "[\x04hLiveCredits\x01]"

#define SPECMODE_NONE            0 
#define SPECMODE_FIRSTPERSON    4 
#define SPECMODE_3RDPERSON        5 
#define SPECMODE_FREELOOK        6 

#include <sourcemod>
#include <sdktools>
#include <clientprefs>
#include <store>

ConVar sm_hud_x;
ConVar sm_hud_y;
ConVar sm_hud_holdTime;
ConVar sm_hud_r;
ConVar sm_hud_g;
ConVar sm_hud_b;
ConVar sm_hud_alpha;
ConVar sm_hud_effect;
ConVar sm_hud_fxTime;
ConVar sm_hud_fadein;
ConVar sm_hud_fadeOut;
ConVar sm_hud_VIPFlag;


Handle g_hClientCookie;
Handle g_hTimer[MAXPLAYERS 1];

int g_iClientCredits[MAXPLAYERS 1];
bool g_bHud[MAXPLAYERS 1];

#pragma newdecls required

public Plugin myinfo 
{
    
name "hLiveCredits"
    
author PLUGIN_AUTHOR
    
description "Shows credits updating in live time zephrus store"
    
version PLUGIN_VERSION
    
url "NUN"
};

public 
void OnPluginStart()
{
    
g_hClientCookie RegClientCookie("CHud""Saves the value for enabling or disabling the hud"CookieAccess_Private);
    
    
sm_hud_x CreateConVar("sm_hud_x""0.45""The value of the text in x cordinate plaine"_true0.0true1.0);
    
sm_hud_y CreateConVar("sm_hud_y""1.0""The value of the text in y cordinate plaine"_true0.0true1.0);
    
sm_hud_holdTime CreateConVar("sm_hud_holdTime""1.0""The amount of time the text should be there");
    
sm_hud_r CreateConVar("sm_hud_r""255""The value for color in RGB format. This ConVar sets the R value"_true0.0true255.0);
    
sm_hud_g CreateConVar("sm_hud_g""255""The value for color in RGB format. This ConVar sets the G value"_true0.0true255.0);
    
sm_hud_b CreateConVar("sm_hud_b""255""The value for color in RGB format. This ConVar sets the B value"_true0.0true255.0);
    
sm_hud_alpha CreateConVar("sm_hud_alpha""1.0""The value to set alpha"_true0.0true1.0);
    
sm_hud_effect CreateConVar("sm_hud_effect""0""The effect to use for the text. (0 and 1 fade in and out. 2 Flicker the text)"_true0.0true2.0);
    
sm_hud_fxTime CreateConVar("sm_hud_fxTime""0""The amount of time the FX should display"_true0.0true60.0);
    
sm_hud_fadein CreateConVar("sm_hud_fadein""0.0""The amount of time the text should fade in"_true0.0true60.0);
    
sm_hud_fadeOut CreateConVar("sm_hud_fadeOut""0.0""The amound of time the text should fade out"_true0.0true60.0);
    
sm_hud_VIPFlag CreateConVar("sm_hud_VIPFlag""t""The flag you have for VIP");
    
    
RegConsoleCmd("sm_chud"CMD_CHud"Enables or disables the hud text");
    
    
AutoExecConfig(true"plugin.hLiveCredits");
    
    
SetHudTextParams(sm_hud_x.FloatValuesm_hud_y.FloatValuesm_hud_holdTime.FloatValuesm_hud_r.IntValuesm_hud_g.IntValuesm_hud_b.IntValuesm_hud_alpha.IntValuesm_hud_effect.IntValuesm_hud_fxTime.FloatValuesm_hud_fadein.FloatValuesm_hud_fadeOut.FloatValue);
}

public 
void OnClientCookiesCached(int client)
{
    
char cookieValue[32];
    
GetClientCookie(clientg_hClientCookiecookieValue32);
    
int value StringToInt(cookieValue);
    
    if (
value == 1)g_bHud[client] = true;
    else 
g_bHud[client] = false;
}

public 
Action CMD_CHud(int clientint args)
{
    
char enabled[32];
    
    
g_bHud[client] = !g_bHud[client];
    
PrintToChat(clientCHAT_TAGS..." You have %s credits on the hud", (g_bHud[client]) ? "\x02disabled\x01":"\x04enabled\x01");
    
    if (
g_bHud[client])
        
Format(enabled32"1");
    else
        
Format(enabled32"0");
        
    
SetClientCookie(clientg_hClientCookieenabled);
    return 
Plugin_Handled;
}

public 
void OnClientPutInServer(int client)
{
    
g_hTimer[client] = CreateTimer(1.0ShowLiveCreditsclientTIMER_REPEAT TIMER_FLAG_NO_MAPCHANGE);
}

public 
Action ShowLiveCredits(Handle timerint client)
{
    if (
g_bHud[client] || !IsValidClient(client))
        return 
Plugin_Handled;
    
    
g_iClientCredits[client] = Store_GetClientCredits(client);
    
char flagString[32];
    
GetConVarString(sm_hud_VIPFlagflagString32);
    
int flag ReadFlagString(flagString);
    
    
int SpecMode GetEntProp(clientProp_Send"m_iObserverMode");
    if (
SpecMode == SPECMODE_FIRSTPERSON || SpecMode == SPECMODE_3RDPERSON)
    {
        
int Target GetEntPropEnt(clientProp_Send"m_hObserverTarget");
        if (
IsValidClient(Target))
        {
            if (
GetUserFlagBits(Target) & flagShowHudText(client5"Credits: [%i] - VIP"g_iClientCredits[Target]);
            else 
ShowHudText(client5"Credits: [%i]"g_iClientCredits[Target]);
            return 
Plugin_Handled;
        }
    }
    
    if (
GetUserFlagBits(client) & flagShowHudText(client5"Credits: [%i] - VIP"g_iClientCredits[client]);
    else 
ShowHudText(client5"Credits: [%i]"g_iClientCredits[client]);
    return 
Plugin_Continue;
}

stock bool IsValidClient(int client)
{
    if (
client || client MaxClients)
        return 
false;
    if (!
IsClientConnected(client))
        return 
false;
    if (!
IsClientInGame(client))
        return 
false;
    if (
IsFakeClient(client))
        return 
false;
    
    return 
true;



Koga73 02-09-2021 03:23

Re: [CS:GO] hLiveCredits
 
Quote:

Originally Posted by Cruze (Post 2656853)
PHP Code:

#pragma semicolon 1

#define DEBUG

#define PLUGIN_AUTHOR "hAlexr"
#define PLUGIN_VERSION "1.0.1"
#define CHAT_TAGS "[\x04hLiveCredits\x01]"

#define SPECMODE_NONE            0 
#define SPECMODE_FIRSTPERSON    4 
#define SPECMODE_3RDPERSON        5 
#define SPECMODE_FREELOOK        6 

#include <sourcemod>
#include <sdktools>
#include <clientprefs>
#include <store>

ConVar sm_hud_x;
ConVar sm_hud_y;
ConVar sm_hud_holdTime;
ConVar sm_hud_r;
ConVar sm_hud_g;
ConVar sm_hud_b;
ConVar sm_hud_alpha;
ConVar sm_hud_effect;
ConVar sm_hud_fxTime;
ConVar sm_hud_fadein;
ConVar sm_hud_fadeOut;
ConVar sm_hud_VIPFlag;


Handle g_hClientCookie;
Handle g_hTimer[MAXPLAYERS 1];

int g_iClientCredits[MAXPLAYERS 1];
bool g_bHud[MAXPLAYERS 1];

#pragma newdecls required

public Plugin myinfo 
{
    
name "hLiveCredits"
    
author PLUGIN_AUTHOR
    
description "Shows credits updating in live time zephrus store"
    
version PLUGIN_VERSION
    
url "NUN"
};

public 
void OnPluginStart()
{
    
g_hClientCookie RegClientCookie("CHud""Saves the value for enabling or disabling the hud"CookieAccess_Private);
    
    
sm_hud_x CreateConVar("sm_hud_x""0.45""The value of the text in x cordinate plaine"_true0.0true1.0);
    
sm_hud_y CreateConVar("sm_hud_y""1.0""The value of the text in y cordinate plaine"_true0.0true1.0);
    
sm_hud_holdTime CreateConVar("sm_hud_holdTime""1.0""The amount of time the text should be there");
    
sm_hud_r CreateConVar("sm_hud_r""255""The value for color in RGB format. This ConVar sets the R value"_true0.0true255.0);
    
sm_hud_g CreateConVar("sm_hud_g""255""The value for color in RGB format. This ConVar sets the G value"_true0.0true255.0);
    
sm_hud_b CreateConVar("sm_hud_b""255""The value for color in RGB format. This ConVar sets the B value"_true0.0true255.0);
    
sm_hud_alpha CreateConVar("sm_hud_alpha""1.0""The value to set alpha"_true0.0true1.0);
    
sm_hud_effect CreateConVar("sm_hud_effect""0""The effect to use for the text. (0 and 1 fade in and out. 2 Flicker the text)"_true0.0true2.0);
    
sm_hud_fxTime CreateConVar("sm_hud_fxTime""0""The amount of time the FX should display"_true0.0true60.0);
    
sm_hud_fadein CreateConVar("sm_hud_fadein""0.0""The amount of time the text should fade in"_true0.0true60.0);
    
sm_hud_fadeOut CreateConVar("sm_hud_fadeOut""0.0""The amound of time the text should fade out"_true0.0true60.0);
    
sm_hud_VIPFlag CreateConVar("sm_hud_VIPFlag""t""The flag you have for VIP");
    
    
RegConsoleCmd("sm_chud"CMD_CHud"Enables or disables the hud text");
    
    
AutoExecConfig(true"plugin.hLiveCredits");
    
    
SetHudTextParams(sm_hud_x.FloatValuesm_hud_y.FloatValuesm_hud_holdTime.FloatValuesm_hud_r.IntValuesm_hud_g.IntValuesm_hud_b.IntValuesm_hud_alpha.IntValuesm_hud_effect.IntValuesm_hud_fxTime.FloatValuesm_hud_fadein.FloatValuesm_hud_fadeOut.FloatValue);
}

public 
void OnClientCookiesCached(int client)
{
    
char cookieValue[32];
    
GetClientCookie(clientg_hClientCookiecookieValue32);
    
int value StringToInt(cookieValue);
    
    if (
value == 1)g_bHud[client] = true;
    else 
g_bHud[client] = false;
}

public 
Action CMD_CHud(int clientint args)
{
    
char enabled[32];
    
    
g_bHud[client] = !g_bHud[client];
    
PrintToChat(clientCHAT_TAGS..." You have %s credits on the hud", (g_bHud[client]) ? "\x02disabled\x01":"\x04enabled\x01");
    
    if (
g_bHud[client])
        
Format(enabled32"1");
    else
        
Format(enabled32"0");
        
    
SetClientCookie(clientg_hClientCookieenabled);
    return 
Plugin_Handled;
}

public 
void OnClientPutInServer(int client)
{
    
g_hTimer[client] = CreateTimer(1.0ShowLiveCreditsclientTIMER_REPEAT TIMER_FLAG_NO_MAPCHANGE);
}

public 
Action ShowLiveCredits(Handle timerint client)
{
    if (
g_bHud[client] || !IsValidClient(client))
        return 
Plugin_Handled;
    
    
g_iClientCredits[client] = Store_GetClientCredits(client);
    
char flagString[32];
    
GetConVarString(sm_hud_VIPFlagflagString32);
    
int flag ReadFlagString(flagString);
    
    
int SpecMode GetEntProp(clientProp_Send"m_iObserverMode");
    if (
SpecMode == SPECMODE_FIRSTPERSON || SpecMode == SPECMODE_3RDPERSON)
    {
        
int Target GetEntPropEnt(clientProp_Send"m_hObserverTarget");
        if (
IsValidClient(Target))
        {
            if (
GetUserFlagBits(Target) & flagShowHudText(client5"Credits: [%i] - VIP"g_iClientCredits[Target]);
            else 
ShowHudText(client5"Credits: [%i]"g_iClientCredits[Target]);
            return 
Plugin_Handled;
        }
    }
    
    if (
GetUserFlagBits(client) & flagShowHudText(client5"Credits: [%i] - VIP"g_iClientCredits[client]);
    else 
ShowHudText(client5"Credits: [%i]"g_iClientCredits[client]);
    return 
Plugin_Continue;
}

stock bool IsValidClient(int client)
{
    if (
client || client MaxClients)
        return 
false;
    if (!
IsClientConnected(client))
        return 
false;
    if (!
IsClientInGame(client))
        return 
false;
    if (
IsFakeClient(client))
        return 
false;
    
    return 
true;



Hey Cruze, I'm getting some compile errors. Got any solution?

Quote:

//// hLiveCredits.sp
// C:\Users\alezv\Desktop\FastDL\sourcemod-1.10.0-git6502-windows\addons\sourcemod\scripting\hLiveCredi ts.sp(19) : error 010: invalid function or declaration
// C:\Users\alezv\Desktop\FastDL\sourcemod-1.10.0-git6502-windows\addons\sourcemod\scripting\hLiveCredi ts.sp(33) : error 010: invalid function or declaration
// C:\Users\alezv\Desktop\FastDL\sourcemod-1.10.0-git6502-windows\addons\sourcemod\scripting\hLiveCredi ts.sp(36) : error 010: invalid function or declaration
// C:\Users\alezv\Desktop\FastDL\sourcemod-1.10.0-git6502-windows\addons\sourcemod\scripting\hLiveCredi ts.sp(39) : warning 207: unknown #pragma
// C:\Users\alezv\Desktop\FastDL\sourcemod-1.10.0-git6502-windows\addons\sourcemod\scripting\hLiveCredi ts.sp(39) : error 038: extra characters on line
// C:\Users\alezv\Desktop\FastDL\sourcemod-1.10.0-git6502-windows\addons\sourcemod\scripting\hLiveCredi ts.sp(41) : error 001: expected token: ";", but found "-identifier-"
// C:\Users\alezv\Desktop\FastDL\sourcemod-1.10.0-git6502-windows\addons\sourcemod\scripting\hLiveCredi ts.sp(48) : error 010: invalid function or declaration
// C:\Users\alezv\Desktop\FastDL\sourcemod-1.10.0-git6502-windows\addons\sourcemod\scripting\hLiveCredi ts.sp(50) : error 001: expected token: ";", but found "-identifier-"
// C:\Users\alezv\Desktop\FastDL\sourcemod-1.10.0-git6502-windows\addons\sourcemod\scripting\hLiveCredi ts.sp(74) : error 021: symbol already defined: "void"
// C:\Users\alezv\Desktop\FastDL\sourcemod-1.10.0-git6502-windows\addons\sourcemod\scripting\hLiveCredi ts.sp(74) : error 010: invalid function or declaration
// C:\Users\alezv\Desktop\FastDL\sourcemod-1.10.0-git6502-windows\addons\sourcemod\scripting\hLiveCredi ts.sp(74 -- 80) : error 010: invalid function or declaration
// C:\Users\alezv\Desktop\FastDL\sourcemod-1.10.0-git6502-windows\addons\sourcemod\scripting\hLiveCredi ts.sp(74 -- 80) : fatal error 127: too many error messages on one line
//
// Compilation aborted.
// 11 Errors.
//
// Compilation Time: 0,14 sec
// ----------------------------------------


All times are GMT -4. The time now is 00:28.

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