AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Trash (https://forums.alliedmods.net/forumdisplay.php?f=22)
-   -   Glow Menu Modification / Help Requests (https://forums.alliedmods.net/showthread.php?t=326950)

Darkwob 08-25-2020 04:38

Glow Menu Modification / Help Requests
 
This plugin is normally written for Cs go, but how do I adapt it to Left 4 dead 2.


PHP Code:

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <colorvariables>

#pragma newdecls required
#pragma semicolon 1

Handle db;

ArrayList g_GlowColor;
ArrayList g_GlowColorName;

// Server ConVars;
ConVar sv_force_transmit_players;
ConVar g_CVAR_GlowColor_Style;
ConVar g_CVAR_GlowColor_Flag;
ConVar g_CVAR_GlowColor_Prefix;

int g_GlowColor_Style;
int g_GlowColor_Flag;

char g_GlowColor_Prefix[40];

int playerModels[MAXPLAYERS 1];
int playerModelsIndex[MAXPLAYERS 1];

int force_transmit;

int GlowIndex[MAXPLAYERS 1];

char g_GlowColorPath[PLATFORM_MAX_PATH];

// Values to the Glow Skin;
#define EF_BONEMERGE                (1 << 0)
#define EF_NOSHADOW                 (1 << 4)
#define EF_NORECEIVESHADOW          (1 << 6)

public Plugin myinfo =
{
    
name        "[CS:GO Glow Menu]",
    
author      "Hallucinogenic Troll (Glow code mostly by Mitch)",
    
description "Allow users to activate Glow to themselves",
    
version     "2.0",
    
url         "HTConfigs.me"
};

public 
void OnPluginStart()
{
    
g_GlowColor = new ArrayList(256);
    
g_GlowColorName = new ArrayList(256);
    
    
SQL_TConnect(OnSQLConnect"glow_menu");
    
    
sv_force_transmit_players     =     FindConVar("sv_force_transmit_players");
    
    
g_CVAR_GlowColor_Style CreateConVar("sm_glowmenu_style""1""Type of Style that you want to the glow (0 gives WALLHACKS to everyone)"_true0.0true3.0);
    
g_CVAR_GlowColor_Flag CreateConVar("sm_glowmenu_flag""""Only gives the glow to players with a certain flag");
    
g_CVAR_GlowColor_Prefix CreateConVar("sm_glowmenu_prefix""[Glow Menu]""Chat's Prefix");
    
    
    
BuildPath(Path_SMg_GlowColorPathsizeof(g_GlowColorPath), "configs/glow_menu.ini");
    
    
RegConsoleCmd("sm_glow"Command_GlowMenu"Glow Color Menu");
    
    
HookEvent("player_spawn",     Event_PlayerSpawn);
    
HookEvent("player_death",     Event_PlayerDeath);
    
    
AutoExecConfig(true"glow_menu");
    
LoadTranslations("glow_menu.phrases");
}

public 
void OnConfigsExecuted()
{
    
g_GlowColor.Clear();
    
g_GlowColorName.Clear();
    
force_transmit sv_force_transmit_players.IntValue;
    
    
g_GlowColor_Style g_CVAR_GlowColor_Style.IntValue;
    
    
g_CVAR_GlowColor_Prefix.GetString(g_GlowColor_Prefixsizeof(g_GlowColor_Prefix));
    
    
char buffer[40];
    
g_CVAR_GlowColor_Flag.GetString(buffersizeof(buffer));
    
    
g_GlowColor_Flag ReadFlagString(buffer);
    
    if(
force_transmit == 0)
    {
        
sv_force_transmit_players.SetInt(1true);
    }
    
    
KeyValues kv CreateKeyValues("glow_colors");
    
kv.ImportFromFile(g_GlowColorPath);

    if (!
kv.GotoFirstSubKey())
    {
        return;
    }
    
    
char colors[150];
    
char colors2[150][3];
    
int icolors[3];
    
char name[150];
    do
    {
        
kv.GetString("name"namesizeof(name));
        
kv.GetString("color"colorssizeof(colors));
        
        
ExplodeString(colors" "colors23sizeof(colors));
        
        for (
int i 03i++)
        {
            
icolors[0] = StringToInt(colors2[i]);
        }
        
        
g_GlowColor.PushArray(icolors);
        
g_GlowColorName.PushString(name);
        
    } while (
kv.GotoNextKey());
    
    
delete kv;
}

public 
int OnSQLConnect(Handle ownerHandle hndlchar [] errorany data)
{
    if(
hndl == INVALID_HANDLE)
    {
        
LogError("[GLOW COLOR] Error: %s"error);
        
        
SetFailState("Databases dont work");
    }
    else
    {
        
db hndl;
        
        
char buffer[3096];
        
SQL_GetDriverIdent(SQL_ReadDriver(db), buffersizeof(buffer));
        
        if(
StrEqual(buffer,"mysql"false))
        {
            
Format(buffersizeof(buffer), "CREATE TABLE IF NOT EXISTS glow(SteamID NVARCHAR(64) NOT NULL DEFAULT '', color INT NOT NULL DEFAULT 0);");
            
SQL_TQuery(dbOnSQLConnectCallbackbuffer);
        }
    }
}

public 
int OnSQLConnectCallback(Handle ownerHandle hndlchar [] errorany data)
{
    if(
hndl == INVALID_HANDLE)
    {
        
LogError("[GLOW COLOR] Error: %s"error);
        return;
    }

    
    for(
int client 1client <= MaxClientsclient++)
    {
        if(
IsClientInGame(client))
        {
            
OnClientPostAdminCheck(client);
        }
    }
}

public 
void OnClientPostAdminCheck(int client)
{
    
playerModelsIndex[client] = -1;
    
playerModels[client] = INVALID_ENT_REFERENCE;
    
    
GlowIndex[client] = -1;
    
    
char SteamID[64];
    
GetClientAuthId(clientAuthId_Steam3SteamIDsizeof(SteamID));
    
    if(
db != INVALID_HANDLE)
    {
        
char buffer[1024];
        
Format(buffersizeof(buffer), "SELECT * FROM glow WHERE SteamID = '%s';"SteamID);
        
SQL_TQuery(dbSQL_LoadPlayerCallbackbufferclient);
    }
}

public 
void SQL_LoadPlayerCallback(Handle DBHandle results, const char[] errorany client)
{
    if(!
IsClientInGame(client) || IsFakeClient(client))
    {
        return;
    }
    
    if(
results == INVALID_HANDLE)
    {
        
LogError("[GLOW COLOR] Error: %s"error);
        return;
    }

    if(
SQL_HasResultSet(results) && SQL_FetchRow(results))
    {
        
GlowIndex[client] = SQL_FetchInt(results1);
    }
    else
    {
        
char buffer[2056];
        
char SteamID[64];
        
GetClientAuthId(clientAuthId_Steam3SteamIDsizeof(SteamID));
        
Format(buffersizeof(buffer), "INSERT INTO glow(SteamID, color) VALUES ('%s', -1)"SteamID[client]);
        
SQL_TQuery(dbSQL_NothingCallbackbuffer);
    }
    
}

public 
void OnClientDisconnect(int client)
{
    if(!
IsValidClient(client))
    {
        return;
    }
    
    if(
db != INVALID_HANDLE)
    {
        
char buffer[1024];
        
char SteamID[64];
        
GetClientAuthId(clientAuthId_Steam3SteamIDsizeof(SteamID));
        
Format(buffersizeof(buffer), "UPDATE glow SET color = %d WHERE SteamID = '%s';"GlowIndex[client], SteamID);
        
SQL_TQuery(dbSQL_NothingCallbackbuffer);
    }
}

public 
int SQL_NothingCallback(Handle ownerHandle hndl, const char[] errorany client)
{
    if (
hndl == INVALID_HANDLE)
    {
        
LogError("[GLOW COLOR] Error: %s"error);
        return;
    }
}



public 
Action Command_GlowMenu(int clientint args)
{
    if (!
IsValidClient(client))
    {
        return;
    }
    
    if(!
CheckCommandAccess(client""g_GlowColor_Flagtrue))
    {
        
CPrintToChat(client"%s %t"g_GlowColor_Prefix"NoPermission");
        return;
    }
    
    
char buffer[256];
    
Menu menu = new Menu(Menu_Glow_Handler);
    
Format(buffersizeof(buffer), "%t""MenuTitle");
    
menu.SetTitle(buffer);
    
Format(buffersizeof(buffer), "%t""MenuNone");
    
menu.AddItem("-1"buffer);
    for (
int i 0g_GlowColorName.Lengthi++)
    {
        
g_GlowColorName.GetString(ibuffersizeof(buffer));
        
menu.AddItem(bufferbuffer);
    }
    
menu.ExitButton true;
    
menu.Display(client20);
}

public 
int Menu_Glow_Handler(Menu menuMenuAction actionint clientint choice)
{
    if(
action == MenuAction_Select)
    {
        
GlowIndex[client] = choice 1;
        if(
choice == 0)
        {
            
CPrintToChat(client"%s %t"g_GlowColor_Prefix"DisabledGlow");
        }
        else
        {    
            
char info[256];
            
menu.GetItem(choiceinfosizeof(info));
            
            
CPrintToChat(client"%s %t"g_GlowColor_Prefix"ChangedGlowColor"info);
        }
    }
    else if(
action == MenuAction_End)
    {
        
delete menu;
    }
}

public 
Action Event_PlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    
    if(!
IsValidClient(client) || GlowIndex[client] == -|| !CheckCommandAccess(client""g_GlowColor_Flagtrue))
    {
        return;
    }
    
    
RemoveSkin(client);
    
CreateGlow(client);
}

public 
Action Event_PlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    
    if(!
IsValidClient(client) || GlowIndex[client] == -|| !CheckCommandAccess(client""g_GlowColor_Flagtrue))
    {
        return;
    }
    
    
RemoveSkin(client);
}

public 
void CreateGlow(int client
{    
    
char model[PLATFORM_MAX_PATH];
    
int skin = -1;
    
GetClientModel(clientmodelsizeof(model));
    
skin CreatePlayerModelProp(clientmodel);
    if(
skin MaxClients)
    {
        if(
SDKHookEx(skinSDKHook_SetTransmitOnSetTransmit_All))
        {
                
SetupGlow(skinclient);
        }
    }
}

public 
Action OnSetTransmit_All(int entityint client)
{
    if(
playerModelsIndex[client] != entity)
    {
        return 
Plugin_Continue;
    }
    return 
Plugin_Handled;
}

public 
void SetupGlow(int entityint client)
{
    static 
int offset = -1;
    
    if ((
offset GetEntSendPropOffs(entity"m_clrGlow")) == -1)
    {
        
LogError("Unable to find property offset: \"m_clrGlow\"!");
        return;
    }


    
SetEntProp(entityProp_Send"m_bShouldGlow"truetrue);
    
SetEntProp(entityProp_Send"m_nGlowStyle"g_GlowColor_Style);
    
SetEntPropFloat(entityProp_Send"m_flGlowMaxDist"10000.0);

    
int colors[3];
    
g_GlowColor.GetArray(GlowIndex[client], colors);

    for(
int i=0;i<3;i++)
    {
        
SetEntData(entityoffset icolors[i], _true);
    }
}

//////////////////////////////////////////////////////////////////////////
///// THE CODE BELOW IS 100% MADE FROM Mitchell's Advanced Admin ESP /////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
public int CreatePlayerModelProp(int clientchar[] sModel)
{
    
RemoveSkin(client);
    
int skin CreateEntityByName("prop_dynamic_override");
    
DispatchKeyValue(skin"model"sModel);
    
DispatchKeyValue(skin"disablereceiveshadows""1");
    
DispatchKeyValue(skin"disableshadows""1");
    
DispatchKeyValue(skin"solid""0");
    
DispatchKeyValue(skin"spawnflags""256");
    
SetEntProp(skinProp_Send"m_CollisionGroup"0);
    
DispatchSpawn(skin);
    
SetEntityRenderMode(skinRENDER_TRANSALPHA);
    
SetEntityRenderColor(skin0000);
    
SetEntProp(skinProp_Send"m_fEffects"EF_BONEMERGE|EF_NOSHADOW|EF_NORECEIVESHADOW);
    
SetVariantString("!activator");
    
AcceptEntityInput(skin"SetParent"clientskin);
    
SetVariantString("primary");
    
AcceptEntityInput(skin"SetParentAttachment"skinskin0);
    
playerModels[client] = EntIndexToEntRef(skin);
    
playerModelsIndex[client] = skin;
    return 
skin;
}

public 
void RemoveSkin(int client)
{
    if(
IsValidEntity(playerModels[client]))
    {
        
AcceptEntityInput(playerModels[client], "Kill");
    }
    
playerModels[client] = INVALID_ENT_REFERENCE;
    
playerModelsIndex[client] = -1;
}

public 
bool IsValidClient(int client)
{
    return (
<= client && client <= MaxClients && IsClientInGame(client));


https://forums.alliedmods.net/image-...3234303534312f

https://www.makinggames.biz/wp-conte...nes-teaser.jpg

HarryPotter 08-25-2020 22:30

Re: Glow Menu Modification / Help Requests
 
Why you need to create new topic of old one ??
[L4D2]Glow Menu Modification / Help Requests

Darkwob 08-26-2020 00:22

Re: Glow Menu Modification / Help Requests
 
because I could not find the answers I was looking for in the first position, extra because there were no respondents later.


All times are GMT -4. The time now is 10:06.

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