AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   [L4D2]Glow Menu Modification / Help Requests (https://forums.alliedmods.net/showthread.php?t=318589)

Darkwob 09-08-2019 15:36

[L4D2]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

foxhound27 02-22-2020 10:07

Re: [L4D2]Glow Menu Modification / Help Requests
 
maybe with this enough o.o

PHP Code:

public void SetupGlow(int entityint client)
{
    
char netclass[128];
    
GetEntityNetClass(entitynetclasssizeof netclass);
    
int offset FindSendPropInfo(netclass"m_iGlowType");
    
    if (
offset 1)
    {
        
LogError("Unable to find property offset: \"m_iGlowType\"!");
        return;
    }


    
SetEntProp(entityProp_Send"m_iGlowType"g_CVAR_GlowColor_Style.IntValue);
    
SetEntProp(entityProp_Send"m_nGlowRange"100);
    
SetEntProp(entityProp_Send"m_nGlowRangeMin"100);

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

    
SetEntProp(entityProp_Send"m_glowColorOverride"colors[0] + (colors[1] * 256) + (colors[2] * 65536));



g_CVAR_GlowColor_Style = CreateConVar("sm_glowmenu_style", "3", "Type of Style that you want to the glow (3 gives WALLHACKS to everyone)", _, true, 0.0, true, 3.0);

this has changed now

0 = None
1 = Use
2 = Look At
3 = Constant

foxhound27 02-22-2020 10:08

Re: [L4D2]Glow Menu Modification / Help Requests
 
and i think this is wrong

PHP Code:

        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); 

must be

PHP Code:

Format(buffersizeof(buffer), "INSERT INTO glow(SteamID, color) VALUES ('%s', -1)"SteamID); 


Silvers 07-21-2020 00:01

Re: [L4D2]Glow Menu Modification / Help Requests
 
Install Accelerator extension and post crash log.

AK978 07-21-2020 07:04

Re: [L4D2]Glow Menu Modification / Help Requests
 
1 Attachment(s)
My random color changing plugin, not sure if it is worth your reference.

Darkwob 08-13-2020 21:21

Re: [L4D2]Glow Menu Modification / Help Requests
 
Quote:

Originally Posted by AK978 (Post 2710997)
My random color changing plugin, not sure if it is worth your reference.

download file gives error and error due to misspelled code in editor

foxhound27 02-01-2021 16:56

Re: [L4D2]Glow Menu Modification / Help Requests
 
1 Attachment(s)
here

Tank Rush 03-17-2021 20:02

Re: [L4D2]Glow Menu Modification / Help Requests
 
Quote:

Originally Posted by foxhound27 (Post 2735349)
here

Code:

L 03/17/2021 - 20:58:48: SourceMod error session started
L 03/17/2021 - 20:58:48: Info (map "c2m1_highway") (file "D:\Program Files\Steam\steamapps\common\Left 4 Dead 2\left4dead2\addons\sourcemod\logs\errors_20210317.log")
L 03/17/2021 - 20:58:48: [SM] Exception reported: Invalid convar handle 0 (error 4)
L 03/17/2021 - 20:58:48: [SM] Blaming: glow_menu.smx
L 03/17/2021 - 20:58:48: [SM] Call stack trace:
L 03/17/2021 - 20:58:48: [SM]  [0] ConVar.IntValue.get
L 03/17/2021 - 20:58:48: [SM]  [1] Line 80, E:\FOX SERVER\glow_menu.sp::OnConfigsExecuted
L 03/17/2021 - 20:58:48: [glow_menu.smx] [GLOW COLOR] Error: Could not find database config "glow_menu"
L 03/17/2021 - 20:58:48: [SM] Exception reported: Databases dont work
L 03/17/2021 - 20:58:48: [SM] Blaming: glow_menu.smx
L 03/17/2021 - 20:58:48: [SM] Call stack trace:
L 03/17/2021 - 20:58:48: [SM]  [0] SetFailState
L 03/17/2021 - 20:58:48: [SM]  [1] Line 134, E:\FOX SERVER\glow_menu.sp::OnSQLConnect
L 03/17/2021 - 20:59:57: Error log file session closed.



All times are GMT -4. The time now is 07:02.

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