View Single Post
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 02-09-2020 , 05:20   Re: [CS:GO] Server crashes if I "spam" a command
Reply With Quote #2

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

public Plugin myinfo 
{
    
name "Hitmarker menu",
    
author "roby & zauni",
    
description "",
    
version "",
    
url ""
};

#define TAG "\x01[\x10ERA\x01]"

int g_HitMarker[MAXPLAYERS 1];
Handle hitmarkerCookie;

public 
OnPluginStart()
{
    
RegConsoleCmd("sm_hitmarker"MenuHM);
    
RegConsoleCmd("sm_hitmarkers"MenuHM);
    
RegConsoleCmd("sm_hitmark"MenuHM);
    
HookEvent("player_death"EnDamage);
    
hitmarkerCookie RegClientCookie("hitmarker""Hitmarker Choice"CookieAccess_Protected);
}

public 
void OnClientCookiesCached(int client
{
    if (
IsFakeClient(client))
    {
        return;
    }
    
    if (
IsClientConnected(client))
    {
        
char buffer[32];
        
GetClientCookie(clienthitmarkerCookiebuffersizeof(buffer));
        
g_HitMarker[client] = StringToInt(buffer);
    }
}

public 
Action MenuHM(int clientint args)
{
    
Menu menu = new Menu(MenuHM_CB);
    
menu.SetTitle("Choose your hitmarker!");
    
menu.AddItem("1""Era wings");
    
menu.AddItem("2""Evil");
    
menu.AddItem("3""Cod");
    
menu.AddItem("4""Cod 2");
    
menu.AddItem("5""Karma 1");
    
menu.AddItem("6""Karma 2");
    
menu.Display(clientMENU_TIME_FOREVER);
    return 
Plugin_Handled;
}

public 
int MenuHM_CB(Menu menuMenuAction actionint param1int param2)
{
    switch (
action
    {
        case 
MenuAction_End:
        {
            
g_HitMarker[param1] = 1;
            
delete menu;
        }
        
        case 
MenuAction_Cancel:
        {
            
g_HitMarker[param1] = 1;
        } 
        
        case 
MenuAction_Select:
        {
            
char item[32], hm_name[16];
            
menu.GetItem(param2itemsizeof(item), _hm_namesizeof(hm_name));
            
            
int option StringToInt(item);
            
g_HitMarker[param1] = option;
            
            
PrintToChat(param1"%s \x04You chose \x0F%s\x04 hitmarker."TAGhm_name);
        }
    }
}

public 
void OnClientDisconnect(int client)
{
    
char option[64];
    
Format(optionsizeof(option), "%d"g_HitMarker[client]);
    
SetClientCookie(clienthitmarkerCookieoption);
}

public 
OnConfigsExecuted()
{
    
// 1, def
    
PrecacheDecal("overlays/wingsmarkerv2.vtf"true);
    
PrecacheDecal("overlays/wingsmarkerv2.vmt"true);

    
// 2 evil
    
PrecacheDecal("overlays/crosshair_evil_v2.vtf"true);
    
PrecacheDecal("overlays/crosshair_evil_v2.vmt"true);
    
    
// cod 3 4
    
PrecacheDecal("iex/hit01.vtf"true);
    
PrecacheDecal("iex/hit01.vmt"true);
    
PrecacheDecal("iex/hit02.vtf"true);
    
PrecacheDecal("iex/hit02.vmt"true);
    
    
// 5 6 karma
    
PrecacheDecal("backwards/hitmarker.vtf"true);
    
PrecacheDecal("backwards/hitmarker.vmt"true);
    
PrecacheDecal("backwards/hitmarker_2.vtf"true);
    
PrecacheDecal("backwards/hitmarker_2.vmt"true);
}

ShowOverlayToClient(client, const char[] overlaypath)
{
    
ClientCommand(client"r_screenoverlay \"%s\""overlaypath);
}

public 
void EnDamage(Event event, const char[] namebool dontBroadcast)
{
    
int attackerId event.GetInt("attacker");
    
int attacker GetClientOfUserId(attackerId);
    if (!
attacker)
        return;
    
    switch (
g_HitMarker[attacker])
    {
        case 
0: {
            
ShowOverlayToClient(attacker"overlays/wingsmarkerv2");
        }
        case 
1: {
            
ShowOverlayToClient(attacker"overlays/wingsmarkerv2");
        }
        case 
2: {    
            
ShowOverlayToClient(attacker"overlays/crosshair_evil_v2");
        }
        case 
3: {    
            
ShowOverlayToClient(attacker"iex/hit01");
        }
        case 
4: {    
            
ShowOverlayToClient(attacker"iex/hit02");
        }
        case 
5: {
            
ShowOverlayToClient(attacker"backwards/hitmarker");
        }
        case 
6: {    
            
ShowOverlayToClient(attacker"backwards/hitmarker_2");
        }
    }
    
    
CreateTimer(1.0NoOverlayattackerId);
}

public 
Action NoOverlay(Handle timerany data)
{
    
int client GetClientOfUserId(data);
    if (
client)
    {
        
ShowOverlayToClient(client"");
    }

__________________
Ilusion9 is offline