Raised This Month: $ Target: $400
 0% 

[CS:S] Auto Skin v2.0.3 (Updated: 4/14/13)


Post New Thread Reply   
 
Thread Tools Display Modes
Paparazziv2
Senior Member
Join Date: Feb 2011
Location: Chile, La Serena
Old 10-14-2011 , 21:10   Re: [CS:S] Auto Skin
Reply With Quote #101

Support please!.

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

#define PLUGIN_VERSION "2.0.2"
#define PLUGIN_PREFIX "\x04Skins: \x03"

#define NUM_TIERS 6
#define NUM_PATHS 8

#define ACCESS_NO_ACCESS -1
#define ACCESS_TIER_ONE 0
#define ACCESS_TIER_TWO 1
#define ACCESS_TIER_THREE 2
#define ACCESS_TIER_FOUR 3
#define ACCESS_TIER_FIVE 4
#define ACCESS_TIER_NONE 5

#define TEAM_NONE 0
#define TEAM_SPEC 1
#define TEAM_RED 2
#define TEAM_BLUE 3

new Handle:g_hEnabled = INVALID_HANDLE;
new Handle:g_hDefault = INVALID_HANDLE;
new Handle:g_hBots = INVALID_HANDLE;
new Handle:g_hDelay = INVALID_HANDLE;
new Handle:g_hCommands = INVALID_HANDLE;
new Handle:g_hAllowed = INVALID_HANDLE;
new Handle:g_hFlag[NUM_TIERS] = { INVALID_HANDLE, ... };
new Handle:g_hPathT[NUM_TIERS] = { INVALID_HANDLE, ... };
new Handle:g_hPathCT[NUM_TIERS] = { INVALID_HANDLE, ... };
new Handle:g_hForced[NUM_TIERS] = { INVALID_HANDLE, ... };
new Handle:g_hCookie = INVALID_HANDLE;
new Handle:g_hTrie = INVALID_HANDLE;
new Handle:g_hTimer = INVALID_HANDLE;

new g_iTeam[MAXPLAYERS + 1];
new g_iTier[MAXPLAYERS + 1];
new bool:g_bAppear[MAXPLAYERS + 1];
new bool:g_bAlive[MAXPLAYERS + 1];
new bool:g_bLoaded[MAXPLAYERS + 1];

new bool:g_bLateLoad = true, bool:g_bEnabled = true, bool:g_bModel, bool:g_bDefault, bool:g_bForced[NUM_TIERS], bool:g_bRedAvailable[NUM_TIERS], bool:g_bBlueAvailable[NUM_TIERS], bool:g_bChangable = true;
new g_iBots, g_iAccess[NUM_TIERS], g_iRedTotal[NUM_TIERS], g_iBlueTotal[NUM_TIERS];
new Float:g_fDelay, Float:g_fAllowed;
new String:g_sRedPaths[NUM_TIERS][NUM_PATHS][256], String:g_sBluePaths[NUM_TIERS][NUM_PATHS][256], String:g_sCommands[8][32];

static const String:g_sBlueModels[4][] = 
{
    "models/player/ct_urban.mdl",
    "models/player/ct_gsg9.mdl",
    "models/player/ct_sas.mdl",
    "models/player/ct_gign.mdl"
};

static const String:g_sRedModels[4][] = 
{
    "models/player/t_phoenix.mdl",
    "models/player/t_leet.mdl",
    "models/player/t_arctic.mdl",
    "models/player/t_guerilla.mdl"
};

public Plugin:myinfo =
{
    name = "Auto Skin", 
    author = "Twisted|Panda", 
    description = "Provides simple functionality for applying skins to players automatically.", 
    version = PLUGIN_VERSION, 
    url = "http://ominousgaming.com"
}

public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
{
    g_bLateLoad = late;
    return APLRes_Success;
}

public OnPluginStart()
{
    LoadTranslations("common.phrases");
    LoadTranslations("sm_autoskin.phrases");

    CreateConVar("sm_autoskin_version", PLUGIN_VERSION, "Auto Skin Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
    g_hEnabled = CreateConVar("sm_autoskin_enable", "1.0", "Enables/disables all features of the plugin.", FCVAR_NONE, true, 0.0, true, 1.0);
    g_hBots = CreateConVar("sm_autoskin_bots", "5.0", "Default access level for bots. 1 = Tier One, 5 = Tier None, 0 = No Access", FCVAR_NONE, true, 0.0, true, 5.0);
    g_hDefault = CreateConVar("sm_autoskin_default", "1.0", "Controls how data is assigned for new players. (0 = Skins start disabled, 1 = Skins start enabled)", FCVAR_NONE, true, 0.0, true, 1.0);
    g_hDelay = CreateConVar("sm_autoskin_delay", "0.1", "Controls how long after a player spawns that their skin is applied.", FCVAR_NONE, true, 0.0);
    g_hCommands = CreateConVar("sm_autoskin_commands", "!skins, /skins, !skin, /skin", "The commands that can be used to access Auto Skin's menu, separated by \", \", up to 8 commands allowed.", FCVAR_NONE);
    g_hAllowed = CreateConVar("sm_autoskin_allowed", "30.0", "The number of seconds after the round starts that they're subject to skin changes (be it via sm_autoskin_commands or player_spawn being fired)", FCVAR_NONE, true, 0.0);

    g_hFlag[0] = CreateConVar("sm_autoskin_tier_one", "-1", "Letter flag(s) required to access the tier one model. (\"-1\" Disables)", FCVAR_NONE);
    g_hPathT[0] = CreateConVar("sm_autoskin_tier_one_t", "", "Path to player model, access level == sm_autoskin_tier_one. (\"\" Disables, separate multiple paths with \", \")", FCVAR_NONE);
    g_hPathCT[0] = CreateConVar("sm_autoskin_tier_one_ct", "", "Path to player model, access level == sm_autoskin_tier_one. (\"\" Disables, separate multiple paths with \", \")", FCVAR_NONE);
    g_hForced[0] = CreateConVar("sm_autoskin_tier_one_forced", "0", "Controls whether or not this tier's skin will be forced upon clients with appropriate access.", FCVAR_NONE, true, 0.0, true, 1.0);

    g_hFlag[1] = CreateConVar("sm_autoskin_tier_two", "-1", "Letter flag(s) required to access the tier two model. (\"-1\" Disables)", FCVAR_NONE);
    g_hPathT[1] = CreateConVar("sm_autoskin_tier_two_t", "", "Path to player model, access level == sm_autoskin_tier_two. (\"\" Disables, separate multiple paths with \", \")", FCVAR_NONE);
    g_hPathCT[1] = CreateConVar("sm_autoskin_tier_two_ct", "", "Path to player model, access level == sm_autoskin_tier_two. (\"\" Disables, separate multiple paths with \", \")", FCVAR_NONE);
    g_hForced[1] = CreateConVar("sm_autoskin_tier_two_forced", "0", "Controls whether or not this tier's skin will be forced upon clients with appropriate access.", FCVAR_NONE, true, 0.0, true, 1.0);

    g_hFlag[2] = CreateConVar("sm_autoskin_tier_three", "-1", "Letter flag(s) required to access the tier three model. (\"-1\" Disables)", FCVAR_NONE);
    g_hPathT[2] = CreateConVar("sm_autoskin_tier_three_t", "", "Path to player model, access level == sm_autoskin_tier_three. (\"\" Disables, separate multiple paths with \", \")", FCVAR_NONE);
    g_hPathCT[2] = CreateConVar("sm_autoskin_tier_three_ct", "", "Path to player model, access level == sm_autoskin_tier_three. (\"\" Disables, separate multiple paths with \", \")", FCVAR_NONE);
    g_hForced[2] = CreateConVar("sm_autoskin_tier_three_forced", "0", "Controls whether or not this tier's skin will be forced upon clients with appropriate access.", FCVAR_NONE, true, 0.0, true, 1.0);

    g_hFlag[3] = CreateConVar("sm_autoskin_tier_four", "-1", "Letter flag(s) required to access the tier four model. (\"-1\" Disables)", FCVAR_NONE);
    g_hPathT[3] = CreateConVar("sm_autoskin_tier_four_t", "", "Path to player model, access level == sm_autoskin_tier_four. (\"\" Disables, separate multiple paths with \", \")", FCVAR_NONE);
    g_hPathCT[3] = CreateConVar("sm_autoskin_tier_four_ct", "", "Path to player model, access level == sm_autoskin_tier_four. (\"\" Disables, separate multiple paths with \", \")", FCVAR_NONE);
    g_hForced[3] = CreateConVar("sm_autoskin_tier_four_forced", "0", "Controls whether or not this tier's skin will be forced upon clients with appropriate access.", FCVAR_NONE, true, 0.0, true, 1.0);

    g_hFlag[4] = CreateConVar("sm_autoskin_tier_five", "-1", "Letter flag(s) required to access the tier five model. (\"-1\" Disables)", FCVAR_NONE);
    g_hPathT[4] = CreateConVar("sm_autoskin_tier_five_t", "", "Path to player model, access level == sm_autoskin_tier_five. (\"\" Disables, separate multiple paths with \", \")", FCVAR_NONE);
    g_hPathCT[4] = CreateConVar("sm_autoskin_tier_five_ct", "", "Path to player model, access level == sm_autoskin_tier_five. (\"\" Disables, separate multiple paths with \", \")", FCVAR_NONE);
    g_hForced[4] = CreateConVar("sm_autoskin_tier_five_forced", "0", "Controls whether or not this tier's skin will be forced upon clients with appropriate access.", FCVAR_NONE, true, 0.0, true, 1.0);

    g_hFlag[5] = CreateConVar("sm_autoskin_tier_none", "0", "If enabled, players without access to any other tier will be assigned tier none models.", FCVAR_NONE, true, 0.0, true, 1.0);
    g_hPathT[5] = CreateConVar("sm_autoskin_tier_none_t", "", "Path to player model, access level == none. (\"\" Disables, separate multiple paths with \", \")", FCVAR_NONE);
    g_hPathCT[5] = CreateConVar("sm_autoskin_tier_none_ct", "", "Path to player model, access level == none. (\"\" Disables, separate multiple paths with \", \")", FCVAR_NONE);
    g_hForced[5] = CreateConVar("sm_autoskin_tier_none_forced", "0", "Controls whether or not this tier's skin will be forced upon clients with appropriate access.", FCVAR_NONE, true, 0.0, true, 1.0);
    AutoExecConfig(true, "sm_autoskin");

    HookConVarChange(g_hEnabled, Action_OnSettingsChange);
    HookConVarChange(g_hDelay, Action_OnSettingsChange);
    HookConVarChange(g_hBots, Action_OnSettingsChange);
    HookConVarChange(g_hDefault, Action_OnSettingsChange);
    HookConVarChange(g_hCommands, Action_OnSettingsChange);
    HookConVarChange(g_hAllowed, Action_OnSettingsChange);
    
    g_hTrie = CreateTrie();
    AddCommandListener(Command_Say, "say");
    AddCommandListener(Command_Say, "say_team");

    SetCookieMenuItem(Menu_Cookies, 0, "Skin Settings");
    g_hCookie = RegClientCookie("AutoSkin_Status", "Auto Skin: The client's skin status.", CookieAccess_Protected);
    HookEvent("player_spawn", Event_OnPlayerSpawn);
    HookEvent("player_death", Event_OnPlayerDeath);
    HookEvent("player_team", Event_OnPlayerTeam, EventHookMode_Pre);
    HookEvent("round_end", Event_OnRoundEnd);
    HookEvent("round_start", Event_OnRoundStart);
}

public OnPluginEnd()
{
    if(g_bEnabled)
    {
        ClearTrie(g_hTrie);
    }
}

public OnMapStart()
{
    Void_SetDefaults();

    if(g_bEnabled)
    {
        Void_ReadDownloads();

        for(new i = 0; i <= 3; i++)
        {
            PrecacheModel(g_sRedModels[i]);
            PrecacheModel(g_sBlueModels[i]);
        }
    }
}

public OnMapEnd()
{
    if(g_hTimer != INVALID_HANDLE && CloseHandle(g_hTimer))
    {
        g_hTimer = INVALID_HANDLE;
        g_bChangable = true;
    }
}

public OnConfigsExecuted()
{
    if(g_bEnabled)
    {
        Void_ReadModels();

        if(g_bLateLoad)
        {
            for(new i = 1; i <= MaxClients; i++)
            {
                if(IsClientInGame(i))
                {
                    g_iTeam[i] = GetClientTeam(i);
                    g_bAlive[i] = IsPlayerAlive(i) ? true : false;

                    if(!IsFakeClient(i))
                    {
                        g_iTier[i] = ACCESS_NO_ACCESS;
                        new _iFlags = GetUserFlagBits(i);
                        if(_iFlags > 0)
                        {
                            for(new j = ACCESS_TIER_ONE; j <= ACCESS_TIER_FIVE; j++)
                            {
                                if(g_iAccess[j] != ACCESS_NO_ACCESS && (_iFlags & g_iAccess[j]))
                                {
                                    g_iTier[i] = j;
                                    break;
                                }
                            }
                        }

                        if(g_iTier[i] == ACCESS_NO_ACCESS && g_iAccess[ACCESS_TIER_NONE])
                            g_iTier[i] = ACCESS_TIER_NONE;
                        
                        if(g_iTier[i] != ACCESS_NO_ACCESS && AreClientCookiesCached(i))
                        {
                            Void_LoadCookies(i);
                            if(g_bAppear[i] || g_bForced[g_iTier[i]])
                                CreateTimer(0.0, Timer_Apply, GetClientUserId(i), TIMER_FLAG_NO_MAPCHANGE);
                        }
                    }
                    else
                    {
                        g_iTier[i] = g_iBots;
                        g_bAppear[i] = true;
                        g_bLoaded[i] = true;
                        
                        if(g_iBots != ACCESS_NO_ACCESS)
                            CreateTimer(0.0, Timer_Apply, GetClientUserId(i), TIMER_FLAG_NO_MAPCHANGE);
                    }
                }
                else
                {
                    g_iTier[i] = ACCESS_NO_ACCESS;

                    g_iTeam[i] = 0;
                    g_bAlive[i] = false;
                }
            }
            
            g_bLateLoad = false;
        }
    }
}

public OnClientPostAdminCheck(client)
{
    if(g_bEnabled)
    {
        if(!IsFakeClient(client))
        {
            g_iTier[client] = ACCESS_NO_ACCESS;
            new _iFlags = GetUserFlagBits(client);
            if(_iFlags > 0)
            {
                for(new i = ACCESS_TIER_ONE; i <= ACCESS_TIER_FIVE; i++)
                {
                    if(g_iAccess[i] != ACCESS_NO_ACCESS && (_iFlags & g_iAccess[i]))
                    {
                        g_iTier[client] = i;
                        break;
                    }
                }
            }

            if(g_iTier[client] == ACCESS_NO_ACCESS && g_iAccess[ACCESS_TIER_NONE])
                g_iTier[client] = ACCESS_TIER_NONE;
            
            if(g_iTier[client] != ACCESS_NO_ACCESS && !g_bLoaded[client] && AreClientCookiesCached(client))
            {
                Void_LoadCookies(client);
                if(g_bAppear[client] || g_bForced[g_iTier[client]])
                    CreateTimer(0.0, Timer_Apply, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
            }
        }
        else
        {
            g_iTier[client] = g_iBots;
            g_bAppear[client] = true;
            g_bLoaded[client] = true;
        }
    }
}

public OnClientDisconnect(client)
{
    if(g_bEnabled)
    {
        g_iTeam[client] = 0;
        g_bAlive[client] = false;

        g_iTier[client] = ACCESS_NO_ACCESS;
        g_bAppear[client] = false;
        g_bLoaded[client] = false;
    }
}

public OnClientCookiesCached(client)
{
    if(!g_bLoaded[client] && g_iTier[client] != ACCESS_NO_ACCESS)
    {
        Void_LoadCookies(client);
        CreateTimer(0.0, Timer_Apply, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
    }
}

public Action:Command_Say(client, const String:command[], argc)
{
    if(g_bEnabled)
    {
        if(!client || !IsClientInGame(client) || g_iTier[client] == ACCESS_NO_ACCESS || g_bForced[g_iTier[client]])
            return Plugin_Continue;

        decl _iIndex, String:_sText[192];
        GetCmdArgString(_sText, sizeof(_sText));
        StripQuotes(_sText);

        if(GetTrieValue(g_hTrie, _sText, _iIndex))
        {
            Menu_Skins(client);
            return Plugin_Stop;
        }
    }

    return Plugin_Continue;
}

public Action:Event_OnPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(g_bEnabled)
    {
        new client = GetClientOfUserId(GetEventInt(event, "userid"));
        if(!client || !IsClientInGame(client) || g_iTeam[client] <= TEAM_SPEC)
            return Plugin_Continue;

        g_bAlive[client] = true;
        if(g_iTier[client] != ACCESS_NO_ACCESS && (g_bAppear[client] || g_bForced[g_iTier[client]]))
            CreateTimer(g_fDelay, Timer_Apply, GetClientUserId(client));
    }

    return Plugin_Continue;
}

public Action:Event_OnPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(g_bEnabled)
    {
        new client = GetClientOfUserId(GetEventInt(event, "userid"));
        if(!client || !IsClientInGame(client))
            return Plugin_Continue;

        g_bAlive[client] = false;
    }

    return Plugin_Continue;
}

public Action:Event_OnPlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(g_bEnabled)
    {
        new client = GetClientOfUserId(GetEventInt(event, "userid"));
        if(!client || !IsClientInGame(client))
            return Plugin_Continue;

        g_iTeam[client] = GetEventInt(event, "team");
        if(g_iTeam[client] == TEAM_SPEC)
            g_bAlive[client] = false;
        else if(g_iTier[client] != ACCESS_NO_ACCESS && (g_bAppear[client] || g_bForced[g_iTier[client]]))
            CreateTimer(g_fDelay, Timer_Apply, GetClientUserId(client));
    }
    
    return Plugin_Continue;
}

public Action:Event_OnRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(g_bEnabled)
    {
        g_bChangable = true;
        if(g_fAllowed > 0.0)
            g_hTimer = CreateTimer(g_fAllowed, Timer_Changable, _, TIMER_FLAG_NO_MAPCHANGE);
            
        for(new i = 1; i <= MaxClients; i++)
            if(IsClientInGame(i) && g_bAlive[i] && g_iTier[i] != ACCESS_NO_ACCESS && (g_bAppear[i] || g_bForced[g_iTier[i]]))
                CreateTimer(g_fDelay, Timer_Apply, GetClientUserId(i));
    }

    return Plugin_Continue;
}

public Action:Event_OnRoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(g_bEnabled)
    {
        g_bChangable = true;
        if(g_hTimer != INVALID_HANDLE && CloseHandle(g_hTimer))
            g_hTimer = INVALID_HANDLE;
    }

    return Plugin_Continue;
}

public Action:Timer_Apply(Handle:timer, any:userid)
{
    new client = GetClientOfUserId(userid);
    if(client && IsClientInGame(client) && g_bAlive[client])
    {
        switch(g_iTeam[client])
        {
            case TEAM_RED:
            {
                if(g_iRedTotal[g_iTier[client]] && g_bRedAvailable[g_iTier[client]])
                    SetEntityModel(client, g_sRedPaths[g_iTier[client]][GetRandomInt(0, (g_iRedTotal[g_iTier[client]] - 1))]);
            }
            case TEAM_BLUE:
            {
                if(g_iBlueTotal[g_iTier[client]] && g_bBlueAvailable[g_iTier[client]])
                    SetEntityModel(client, g_sBluePaths[g_iTier[client]][GetRandomInt(0, (g_iBlueTotal[g_iTier[client]] - 1))]);
            }
        }
    }

    return Plugin_Continue;
}

public Action:Timer_Changable(Handle:timer)
{
    g_hTimer = INVALID_HANDLE;
    g_bChangable = false;
}    

bool:Bool_Check(const String:_sTemp[])
{
    if(StrEqual(_sTemp, "") || !FileExists(_sTemp))
        return false;
        
    return true;
}

public Menu_Cookies(client, CookieMenuAction:action, any:info, String:buffer[], maxlen) 
{
    switch(action)
    {
        case CookieMenuAction_DisplayOption:
            Format(buffer, maxlen, "Skin Settings");
        case CookieMenuAction_SelectOption:
        {
            if(!g_bEnabled)
                PrintToChat(client, "%s%t", PLUGIN_PREFIX, "Phrase_Inactive");
            else if(g_iTier[client] == ACCESS_NO_ACCESS)
                PrintToChat(client, "%s%t", PLUGIN_PREFIX, "Phrase_Restricted");
            else if(client && IsClientInGame(client))
                Menu_Skins(client);
        }
    }
}

Menu_Skins(client)
{
    decl String:_sBuffer[128];
    new Handle:_hMenu = CreateMenu(MenuHandler_MenuSkins);
    Format(_sBuffer, sizeof(_sBuffer), "%T", "Menu_Title_Main", client);
    SetMenuTitle(_hMenu, _sBuffer);
    SetMenuPagination(_hMenu, MENU_NO_PAGINATION);
    SetMenuExitButton(_hMenu, true);

    if(g_bAppear[client])
        Format(_sBuffer, sizeof(_sBuffer), "%T", "Menu_Option_Disable", client);
    else
        Format(_sBuffer, sizeof(_sBuffer), "%T", "Menu_Option_Enable", client);
    AddMenuItem(_hMenu, "0", _sBuffer);
    
    DisplayMenu(_hMenu, client, MENU_TIME_FOREVER);
}

public MenuHandler_MenuSkins(Handle:menu, MenuAction:action, param1, param2)
{
    switch (action)
    {
        case MenuAction_End:
            CloseHandle(menu);
        case MenuAction_Select:
        {
            decl String:_sTemp[8];
            GetMenuItem(menu, param2, _sTemp, sizeof(_sTemp));

            switch(StringToInt(_sTemp))
            {
                case 0:
                {
                    if(!g_bAppear[param1])
                    {
                        g_bAppear[param1] = true;
                        PrintToChat(param1, "%s%t", PLUGIN_PREFIX, "Phrase_Enable");
                        SetClientCookie(param1, g_hCookie, "1");

                        if(g_bAlive[param1] && g_bChangable)
                            CreateTimer(0.0, Timer_Apply, GetClientUserId(param1), TIMER_FLAG_NO_MAPCHANGE);
                    }
                    else
                    {
                        g_bAppear[param1] = false;
                        PrintToChat(param1, "%s%t", PLUGIN_PREFIX, "Phrase_Disable");
                        SetClientCookie(param1, g_hCookie, "0");

                        if(g_bAlive[param1] && g_bChangable)
                        {
                            if(g_bForced[ACCESS_TIER_NONE] && g_iTier[param1] != ACCESS_TIER_NONE)
                            {
                                switch(g_iTeam[param1])
                                {
                                    case TEAM_RED:
                                        if(g_bRedAvailable[ACCESS_TIER_NONE])
                                            SetEntityModel(param1, g_sRedPaths[ACCESS_TIER_NONE][GetRandomInt(0, (g_iRedTotal[ACCESS_TIER_NONE] - 1))]);
                                    case TEAM_BLUE:
                                        if(g_bBlueAvailable[ACCESS_TIER_NONE])
                                            SetEntityModel(param1, g_sBluePaths[ACCESS_TIER_NONE][GetRandomInt(0, (g_iBlueTotal[ACCESS_TIER_NONE] - 1))]);
                                }
                            }
                            else
                            {
                                switch(g_iTeam[param1])
                                {
                                    case TEAM_RED:
                                        if(g_bRedAvailable[ACCESS_TIER_NONE])
                                            SetEntityModel(param1, g_sRedModels[GetRandomInt(0, 3)]);
                                    case TEAM_BLUE:
                                        if(g_bBlueAvailable[ACCESS_TIER_NONE])
                                            SetEntityModel(param1, g_sBlueModels[GetRandomInt(0, 3)]);
                                }
                            }
                        }
                    }

                    Menu_Skins(param1);
                }
            }
        }
    }
}

Void_LoadCookies(client)
{
    if(g_bForced[g_iTier[client]])
        g_bAppear[client] = true;
    else
    {
        decl String:g_sCookie[3];
        GetClientCookie(client, g_hCookie, g_sCookie, sizeof(g_sCookie));

        if(StrEqual(g_sCookie, ""))
        {
            SetClientCookie(client, g_hCookie, g_bDefault ? "1" : "0");
            g_bAppear[client] = g_bDefault;
        }
        else
            g_bAppear[client] = StringToInt(g_sCookie) ? true : false;
    }
        
    g_bLoaded[client] = true;
}

Void_SetDefaults()
{
    g_bEnabled = GetConVarInt(g_hEnabled) ? true : false;
    g_iBots = GetConVarInt(g_hBots);
    g_bDefault = GetConVarInt(g_hDefault) ? true : false;
    g_fDelay = GetConVarFloat(g_hDelay);
    g_fAllowed = GetConVarFloat(g_hAllowed);

    decl String:_sTemp[256];
    GetConVarString(g_hCommands, _sTemp, sizeof(_sTemp));
    ClearTrie(g_hTrie);
    new _iCount = ExplodeString(_sTemp, ", ", g_sCommands, 8, 32);
    for(new i = 0; i < _iCount; i++)
        SetTrieValue(g_hTrie, g_sCommands[i], _iCount);
}

Void_ReadModels()
{
    decl String:_sBuffer[1024];
    for(new i = ACCESS_TIER_ONE; i <= ACCESS_TIER_NONE; i++)
    {
        if(i == ACCESS_TIER_NONE)
            g_iAccess[ACCESS_TIER_NONE] = GetConVarInt(g_hFlag[i]);
        else
        {
            GetConVarString(g_hFlag[i], _sBuffer, sizeof(_sBuffer));
            new _iBuffer = ReadFlagString(_sBuffer);
            g_iAccess[i] = (_iBuffer > 0) ? _iBuffer : ACCESS_NO_ACCESS;
        }

        if((i == ACCESS_TIER_NONE && g_iAccess[ACCESS_TIER_NONE]) || g_iAccess[i] != ACCESS_NO_ACCESS)
        {
            GetConVarString(g_hPathT[i], _sBuffer, sizeof(_sBuffer));
            g_iRedTotal[i] = ExplodeString(_sBuffer, ", ", g_sRedPaths[i], NUM_PATHS, 256);
            g_bRedAvailable[i] = Bool_Check(g_sRedPaths[i][0]);
            
            GetConVarString(g_hPathCT[i], _sBuffer, sizeof(_sBuffer));
            g_iBlueTotal[i] = ExplodeString(_sBuffer, ", ", g_sBluePaths[i], NUM_PATHS, 256);
            g_bBlueAvailable[i] = Bool_Check(g_sBluePaths[i][0]);
        }
        else
        {
            g_iRedTotal[i] = 0;
            g_iBlueTotal[i] = 0;
            g_bRedAvailable[i] = false;
            g_bBlueAvailable[i] = false;
        }
    }
}

public Action_OnSettingsChange(Handle:cvar, const String:oldvalue[], const String:newvalue[])
{
    if(cvar == g_hEnabled)
        g_bEnabled = StringToInt(newvalue) ? true : false;
    else if(cvar == g_hBots)
        g_iBots = StringToInt(newvalue);
    else if(cvar == g_hDefault)
        g_bDefault = StringToInt(newvalue) ? true : false;
    else if(cvar == g_hDelay)
        g_fDelay = StringToFloat(newvalue);
    else if(cvar == g_hAllowed)
        g_fAllowed = StringToFloat(newvalue);
    else if(cvar == g_hCommands)
    {
        ClearTrie(g_hTrie);

        new _iCount = ExplodeString(newvalue, ", ", g_sCommands, 8, 32);
        for(new i = 0; i < _iCount; i++)
            SetTrieValue(g_hTrie, g_sCommands[i], _iCount);
    }
}

Void_ReadDownloads()
{
    new String:_sBuffer[256];
    BuildPath(Path_SM, _sBuffer, sizeof(_sBuffer), "configs/sm_autoskin.ini");
    new Handle:_hTemp = OpenFile(_sBuffer, "r");

    if(_hTemp != INVALID_HANDLE) 
    {
        new _iLength;
        while (ReadFileLine(_hTemp, _sBuffer, sizeof(_sBuffer)))
        {    
            _iLength = strlen(_sBuffer);
            if (_sBuffer[(_iLength - 1)] == '\n')
                _sBuffer[--_iLength] = '\0';

            TrimString(_sBuffer);
            if (!StrEqual(_sBuffer, "", false))
                Void_ReadFileFolder(_sBuffer);

            if (IsEndOfFile(_hTemp))
                break;
        }

        CloseHandle(_hTemp);
    }
}

Void_ReadFileFolder(String:_sPath[])
{
    new Handle:_hTemp = INVALID_HANDLE;
    new _iLength, FileType:_iFileType = FileType_Unknown;
    decl String:_sBuffer[256], String:_sLine[256];
    
    _iLength = strlen(_sPath);
    if (_sPath[_iLength-1] == '\n')
        _sPath[--_iLength] = '\0';

    TrimString(_sPath);
    if(DirExists(_sPath))
    {
        _hTemp = OpenDirectory(_sPath);
        while(ReadDirEntry(_hTemp, _sBuffer, sizeof(_sBuffer), _iFileType))
        {
            _iLength = strlen(_sBuffer);
            if (_sBuffer[_iLength-1] == '\n')
                _sBuffer[--_iLength] = '\0';
            TrimString(_sBuffer);

            if (!StrEqual(_sBuffer, "") && !StrEqual(_sBuffer, ".", false) && !StrEqual(_sBuffer,"..",false))
            {
                strcopy(_sLine, sizeof(_sLine), _sPath);
                StrCat(_sLine, sizeof(_sLine), "/");
                StrCat(_sLine, sizeof(_sLine), _sBuffer);

                if(_iFileType == FileType_File)
                    Void_ReadItem(_sLine);
                else
                    Void_ReadFileFolder(_sLine);
            }
        }
    }
    else
        Void_ReadItem(_sPath);

    if(_hTemp != INVALID_HANDLE)
        CloseHandle(_hTemp);
}

Void_ReadItem(String:_sBuffer[])
{
    decl String:_sTemp[3];
    new _iLength = strlen(_sBuffer);
    if (_sBuffer[_iLength-1] == '\n')
        _sBuffer[--_iLength] = '\0';
    TrimString(_sBuffer);

    strcopy(_sTemp, sizeof(_sTemp), _sBuffer);
    if(!StrEqual(_sBuffer, "", false) && StrContains(_sBuffer, "//", false) == -1)
    {
        g_bModel = (StrContains(_sBuffer, ".mdl", false) >= 0) ? true : false;
        if (FileExists(_sBuffer))
        {
            if(g_bModel)
                PrecacheModel(_sBuffer);

            AddFileToDownloadsTable(_sBuffer);
        }
        else
            LogError("Auto Skin: The file for %s doesn't exist!", _sBuffer);
    }
}
I compiled and now i test...
__________________
Sorry for the bad english please.


Last edited by Paparazziv2; 10-14-2011 at 21:25.
Paparazziv2 is offline
Send a message via MSN to Paparazziv2
Paparazziv2
Senior Member
Join Date: Feb 2011
Location: Chile, La Serena
Old 10-15-2011 , 10:25   Re: [CS:S] Auto Skin
Reply With Quote #102

The problem, continues :/
__________________
Sorry for the bad english please.

Paparazziv2 is offline
Send a message via MSN to Paparazziv2
weeb1e
SourceMod Donor
Join Date: Sep 2011
Old 10-28-2011 , 05:15   Re: [CS:S] Auto Skin
Reply With Quote #103

I experienced this same issue with random players getting errors sporadically requiring them to have to restart their game client to fix it. I had to remove the custom skin and use the same normal terrorist skin for everyone.

If anyone ever finds a solution to this issue, please give as much info as possible. Thanks
weeb1e is offline
Jizzy
Member
Join Date: Dec 2010
Old 11-05-2011 , 19:51   Re: [CS:S] Auto Skin
Reply With Quote #104

This is a great plugin!!!

However, when used with Zombie Reloaded, the model set for T always takes priority over the Zombie skins. I think its because Auto Skin fires the T skin when the player changes team to T when zombified.

Panda,

Could you allow Auto Skin to fire only once per round so when humans do get zombified and change team, zombie reloaded changes the player skin not Auto Skin.

I bet alot of ppl would appreciate this!
Jizzy is offline
Fearts
ferts of daeth
Join Date: Oct 2008
Old 01-17-2012 , 19:43   Re: [CS:S] Auto Skin
Reply With Quote #105

I would like to add two public skins that are chosen at random. Is this something you would be willing to add, I know your busy.
__________________
Fearts is offline
Lingus
Member
Join Date: Jan 2010
Location: UK
Old 02-27-2012 , 19:40   Re: [CS:S] Auto Skin
Reply With Quote #106

i have been trying for months and months to get this plugin configured so that human players have 1 skin, bots have another, but nothing seems to work. I have to settle for 2 plugins atm to do this.

So i've got my 'human' skin applied to tier none which works fine, humans get the appropriate skin. 'Bot' skin is applied to tier one, no matter what i try bots do not get the skin unless i set them to tier none which works everytime.

The problem being that i cannot specify a flag for every human player that joins so i need 'humans' set to tier none.

Please help me.

// This file was auto-generated by SourceMod (v1.4.1)
// ConVars for plugin "sm_autoskin.smx"


// The number of seconds after the round starts that they're subject to skin changes (be it via sm_autoskin_commands or player_spawn being fired)
// -
// Default: "30.0"
// Minimum: "0.000000"
sm_autoskin_allowed "0.0"

// Default access level for bots. 1 = Tier One, 5 = Tier None, 0 = No Access
// -
// Default: "5.0"
// Minimum: "0.000000"
// Maximum: "5.000000"
sm_autoskin_bots "1.0"

// The commands that can be used to access Auto Skin's menu, separated by ", ", up to 8 commands allowed.
// -
// Default: "!skins, /skins, !skin, /skin"
sm_autoskin_commands "!skins, /skins, !skin, /skin"

// Controls how data is assigned for new players. (0 = Skins start disabled, 1 = Skins start enabled)
// -
// Default: "1.0"
// Minimum: "0.000000"
// Maximum: "1.000000"
sm_autoskin_default "1.0"

// Controls how long after a player spawns that their skin is applied.
// -
// Default: "0.1"
// Minimum: "0.000000"
sm_autoskin_delay "0.0"

// Enables/disables all features of the plugin.
// -
// Default: "1.0"
// Minimum: "0.000000"
// Maximum: "1.000000"
sm_autoskin_enable "1.0"

sm_autoskin_tier_five "-1"
sm_autoskin_tier_five_ct ""
sm_autoskin_tier_five_forced "0"
sm_autoskin_tier_five_t ""

sm_autoskin_tier_four "-1"
sm_autoskin_tier_four_ct ""
sm_autoskin_tier_four_forced "0"
sm_autoskin_tier_four_t ""

sm_autoskin_tier_three "-1"
sm_autoskin_tier_three_ct ""
sm_autoskin_tier_three_forced "0"
sm_autoskin_tier_three_t ""

sm_autoskin_tier_two "-1"
sm_autoskin_tier_two_ct ""
sm_autoskin_tier_two_forced "1"
sm_autoskin_tier_two_t ""

sm_autoskin_tier_one "-1"
sm_autoskin_tier_one_ct "models/player/Dopeling/Zombie_Fast/zombie_fast.mdl"
sm_autoskin_tier_one_forced "1"
sm_autoskin_tier_one_t "models/player/Dopeling/Zombie_Fast/zombie_fast.mdl"

// If enabled, players without access to any other tier will be assigned tier none models.
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
sm_autoskin_tier_none "1"

// Path to player model, access level == none. ("" Disables, separate multiple paths with ", ")
// -
// Default: ""
sm_autoskin_tier_none_ct "models/player/Dopeling/CT_Admin/ct_admin.mdl"

// Controls whether or not this tier's skin will be forced upon clients with appropriate access.
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
sm_autoskin_tier_none_forced "1"

// Path to player model, access level == none. ("" Disables, separate multiple paths with ", ")
// -
// Default: ""
sm_autoskin_tier_none_t "models/player/Dopeling/T_Admin/t_admin.mdl"

Last edited by Lingus; 02-27-2012 at 19:41.
Lingus is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 02-27-2012 , 19:54   Re: [CS:S] Auto Skin
Reply With Quote #107

I'll look into the Bot issue, I don't recall ever testing that portion of the plugin as I didn't use it.
__________________
thetwistedpanda is offline
Lingus
Member
Join Date: Jan 2010
Location: UK
Old 03-03-2012 , 13:05   Re: [CS:S] Auto Skin
Reply With Quote #108

great stuff! I would love to use just this 1 plugin for skins because it seems very capable.

Thanks,
Ling
Lingus is offline
poppin-fresh
AlliedModders Donor
Join Date: Aug 2010
Old 03-30-2012 , 00:50   Re: [CS:S] Auto Skin
Reply With Quote #109

this plugin seems to crash my server, no errors
poppin-fresh is offline
.BadGurl AKA FallenAngel
Member
Join Date: Jun 2011
Location: UK
Old 04-09-2012 , 10:28   Re: [CS:S] Auto Skin
Reply With Quote #110

Quote:
Originally Posted by Jizzy View Post
This is a great plugin!!!

However, when used with Zombie Reloaded, the model set for T always takes priority over the Zombie skins. I think its because Auto Skin fires the T skin when the player changes team to T when zombified.

Panda,

Could you allow Auto Skin to fire only once per round so when humans do get zombified and change team, zombie reloaded changes the player skin not Auto Skin.

I bet alot of ppl would appreciate this!
My thoughts exactly, works perfect except for over riding the zombie skins, would be great if there was a fix for this.

Thank you for the great plugin
__________________
.BadGurl AKA FallenAngel is offline
Reply



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 18:08.


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