Raised This Month: $68 Target: $400
 17% 

Overlapping hud


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
szogun
Senior Member
Join Date: Apr 2016
Old 08-16-2019 , 16:46   Overlapping hud
Reply With Quote #1

Hey, I have a small problem with the plugin after adding the number of credits, hud overlaps what you see on ss

https://zapodaj.net/images/63bd861dc12bf.jpg

PHP Code:
#pragma semicolon 1

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

public Plugin myinfo 
{
    
name "HUDv2",
    
author "xSLOW",
    
description "Server Hud",
    
version "1.4"
};

enum {
    
RED 0,
    
GREEN,
    
BLUE
}

ConVar g_cvarMessage1;
ConVar g_cvarMessage2;
ConVar g_cvarMessage3;
ConVar g_cvarSlots;
ConVar g_cvarHUDColors;

Handle hTimer[MAXPLAYERS 1] = INVALID_HANDLE;
Handle g_hHUDv2Cookie;
bool g_bIsHudEnabled[MAXPLAYERS 1];
int g_iHUDColors[3];


public 
void OnPluginStart()
{
    
g_hHUDv2Cookie RegClientCookie("HudCookie_V2""HudCookie_V2"CookieAccess_Protected);

    
g_cvarMessage1 CreateConVar("sm_hud_message1""Forum: AceGo.pl""Top-Left first message"FCVAR_NOTIFY);
    
g_cvarMessage2 CreateConVar("sm_hud_message2""TS3: OneFrag.pl""Top-Left second message"FCVAR_NOTIFY);
    
g_cvarMessage3 CreateConVar("sm_hud_message3""Wpisz /sklepsms aby kupic Vipa""Top-Mid third message"FCVAR_NOTIFY);
    
g_cvarSlots CreateConVar("sm_hud_slots""15""Number of server's slots"FCVAR_NOTIFY);
    
g_cvarHUDColors CreateConVar("sm_hud_rgb""230,57,0""RGB of the text. You can get more colors from https://www.hexcolortool.com/"FCVAR_NOTIFY);

    
AutoExecConfig(true"HUDv2");

    
UpdateHUDColor();
    
g_cvarHUDColors.AddChangeHook(cvarChanged_HUDColor);
    
RegConsoleCmd("hud"Command_hud);
}

public 
void OnClientPutInServer(int client)
{
    
g_bIsHudEnabled[client] = true;
    
char buffer[64];
    
GetClientCookie(clientg_hHUDv2Cookiebuffersizeof(buffer));
    if(
StrEqual(buffer,"0"))
        
g_bIsHudEnabled[client] = false;

    
hTimer[client] = CreateTimer(0.1CreditsTimerGetClientUserId(client), TIMER_REPEAT TIMER_FLAG_NO_MAPCHANGE);
}

public 
void cvarChanged_HUDColor(ConVar convar, const char[] oldValue, const char[] newValue) {
    
UpdateHUDColor();
}

public 
Action Command_hud(int clientint args
{
    if(
g_bIsHudEnabled[client])
    {
        
PrintToChat(client" ★ \x02HUD pomyslnie wylaczony");
        
g_bIsHudEnabled[client] = false;
        
SetClientCookie(clientg_hHUDv2Cookie"0");
    }
    else
    {
        
PrintToChat(client" ★ \x04HUD pomyslnie wlaczony");
        
g_bIsHudEnabled[client] = true;
        
SetClientCookie(clientg_hHUDv2Cookie"1");
    }
}

public 
Action CreditsTimer(Handle timerany userid)
{
    
int client GetClientOfUserId(userid);
    
int credits Store_GetClientCredits(client);
    
int clientCount 0iTimeleft;
    
char sTime[64], szTime[30], iMessage1[32], iMessage2[32], iMessage3[32], MapTimeLeft[128];

    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && !IsFakeClient(i))
            ++
clientCount;
    }

    
g_cvarMessage1.GetString(iMessage1sizeof(iMessage1));
    
g_cvarMessage2.GetString(iMessage2sizeof(iMessage2));
    
g_cvarMessage3.GetString(iMessage3sizeof(iMessage3));

    
GetMapTimeLeft(iTimeleft);
    
FormatTime(szTimesizeof(szTime), "%H:%M:%S"GetTime());
    
FormatTime(sTimesizeof(sTime), "%M:%S"iTimeleft);

    for(
int i 1<= MaxClientsi++)
    {
        if(
g_bIsHudEnabled[i] && IsValidClient(i))
        {
            
char iBuffer[1024];
            if(!(
iTimeleft 0))
                
Format(MapTimeLeft,sizeof(MapTimeLeft), "Last Round");
            else
                
Format(MapTimeLeft,sizeof(MapTimeLeft), "%s"sTime);

            
Format(iBuffersizeof(iBuffer),"%s\n%s\nGraczy: %d/%d\nPozostalo: %s\nGodzina: %s\nKredyty: %i",iMessage1iMessage2clientCountg_cvarSlots.IntValueMapTimeLeftszTimecredits);
            
//Format(iBuffer, sizeof(iBuffer),"%s\n%s\nGraczy: %d/%d\nGodzina: %s",iMessage1, iMessage2, clientCount, g_cvarSlots.IntValue, szTime);
            
SetHudTextParams(0.00.00.9g_iHUDColors[RED], g_iHUDColors[GREEN], g_iHUDColors[BLUE], 25500.00.00.0);  
            
ShowHudText(i, -1iBuffer);  

            
SetHudTextParams(-1.00.0750.9g_iHUDColors[RED], g_iHUDColors[GREEN], g_iHUDColors[BLUE], 25500.00.00.0);  
            
ShowHudText(i, -1iMessage3);  
        }
    }
}

stock bool IsValidClient(clientbool nobots true)

    if (
client <= || client MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client)))
    {
        return 
false
    }
    return 
IsClientInGame(client); 
}

void UpdateHUDColor() {
    
char buffer[16];
    
g_cvarHUDColors.GetString(buffersizeof(buffer));

    
char buffer2[3][4];
    
ExplodeString(buffer","buffer2sizeof(buffer2), sizeof(buffer2[]));
    
    for (
int i 03i++) {
        
g_iHUDColors[i] = StringToInt(buffer2[i]);
    }

szogun is offline
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 07:40.


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