Raised This Month: $51 Target: $400
 12% 

Help, got a little compilation error.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KleirPlays
Member
Join Date: Jun 2013
Location: Portugal
Old 08-03-2014 , 18:05   Help, got a little compilation error.
Reply With Quote #1

I tryed to change to color chat but got some error:

Line 415


PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <chatcolor>

#define PLUG_NAME         "HATS"
#define PLUG_AUTH         "SgtBane"
#define PLUG_VERS         "1.8"
#define PLUG_TAG         "Wicked"
#define PLUG_ADMIN        ADMIN_RCON        //Access flags required to give/remove hats
#define PLUG_ADMINB     ADMIN_CHAT        //Access flags required to set personal hat if admin only is enabled

#define OFFSET_GLOWSET    100

#define HAT_ALL            0
#define HAT_ADMIN        1
#define HAT_TERROR        2
#define HAT_COUNTER        3

#define menusize         220
#define maxTry            15                //Number of tries to get someone a non-admin random hat before giving up.
#define modelpath        "models/hat"

stock fm_set_entity_visibility(indexvisible 1set_pev(indexpev_effectsvisible == pev(indexpev_effects) & ~EF_NODRAW pev(indexpev_effects) | EF_NODRAW)

new 
g_HatEnt[33]
new 
CurrentHat[33]
new 
CurrentMenu[33]

new 
HatFile[64]
new 
MenuPagesTotalHats

#define MAX_HATS 64
new HATMDL[MAX_HATS][26]
new 
HATNAME[MAX_HATS][26]
new 
HATREST[MAX_HATS]

new 
P_AdminOnly
new P_AdminHats
new P_RandomJoin
new P_BotRandom
new P_ForceHat
new P_Glow

public plugin_init() {
    
register_plugin(PLUG_NAMEPLUG_VERSPLUG_AUTH)
    
register_logevent("event_roundstart",     2,    "1=Round_Start")
    
register_event("TeamInfo",                 "event_team_info",     "a" )
    
    
register_concmd("amx_givehat",         "Give_Hat",     PLUG_ADMIN,     "<nick> <mdl #>")
    
register_concmd("amx_removehats",     "Remove_Hat",     PLUG_ADMIN,     " - Removes hats from everyone.")
    
    
register_menucmd(register_menuid("\yHat Menu: [Page"),    (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9),"MenuCommand")
    
register_clcmd("say /hats",            "ShowMenu", -1,     "Shows Knife menu")
    
    
P_AdminOnly        register_cvar("hat_adminonly",    "0")    //Only admins can use the menu
    
P_AdminHats     register_cvar("hat_adminhats",    "1")    //Allow hats for admins only (if 0, hats specifically for admins can be used by anyone)
    
P_RandomJoin    register_cvar("hat_random",        "1")    //Random hats for players as they join
    
P_BotRandom        register_cvar("hat_bots",            "1")    //Random hats for bots as they join
    
P_ForceHat        register_cvar("hat_force",        "0")    //Force a specific hat (if not 0)
    
P_Glow            register_cvar("hat_glow",            "1")    //0=None,1=GlowWithPlayer,2=TeamColor
}

public 
ShowMenu(id) {
    if ((
get_pcvar_num(P_AdminOnly) == && get_user_flags(id) & PLUG_ADMIN) || (get_pcvar_num(P_AdminOnly) == && get_pcvar_num(P_ForceHat) == 0)) {
        
CurrentMenu[id] = 1
        ShowHats
(id)
    } else {
        
ChatColor(id"%s Only admins may currently use this menu.",PLUG_TAG)
    }
    return 
PLUGIN_HANDLED
}

public 
ShowHats(id) {
    new 
keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9)
    
    new 
szMenuBody[menusize 1], WpnID
    
new nLen format(szMenuBodymenusize"\yHat Menu: [Page %i/%i]^n",CurrentMenu[id],MenuPages)
    
    new 
MnuClr[3]
    
// Get Hat Names And Add Them To The List
    
for (new hatid=0hatid 8hatid++) {
        
WpnID = ((CurrentMenu[id] * 8) + hatid 8)
        if (
WpnID TotalHats) {
            
menucolor(idWpnIDMnuClr)
            
nLen += format(szMenuBody[nLen], menusize-nLen"^n\w%i.%s %s"hatid 1MnuClrHATNAME[WpnID])
        }
    }
    
    
// Next Page And Previous/Close
    
if (CurrentMenu[id] == MenuPages) {
        
nLen += format(szMenuBody[nLen], menusize-nLen"^n^n\d9. Next Page")
    } else {
        
nLen += format(szMenuBody[nLen], menusize-nLen"^n^n\w9. Next Page")
    }
    
    if (
CurrentMenu[id] > 1) {
        
nLen += format(szMenuBody[nLen], menusize-nLen"^n\w0. Previous Page")
    } else {
        
nLen += format(szMenuBody[nLen], menusize-nLen"^n\w0. Close")
    }
    
show_menu(idkeysszMenuBody, -1)
    return 
PLUGIN_HANDLED
}

public 
MenuCommand(idkey) {
    switch(
key)
    {
        case 
8:        //9 - [Next Page]
        
{
            if (
CurrentMenu[id] < MenuPagesCurrentMenu[id]++
            
ShowHats(id)
            return 
PLUGIN_HANDLED
        
}
        case 
9:        //0 - [Close]
        
{
            
CurrentMenu[id]--
            if (
CurrentMenu[id] > 0ShowHats(id)
            return 
PLUGIN_HANDLED
        
}
        default:
        {
            new 
HatID = ((CurrentMenu[id] * 8) + key 8)
            if (
HatID TotalHats) {
                if ((
get_pcvar_num(P_AdminHats) == && HATREST[HatID] == HAT_ADMIN) || (get_pcvar_num(P_AdminHats) == && HATREST[HatID] == HAT_ADMIN && get_user_flags(id) & PLUG_ADMINB) || HATREST[HatID] == HAT_ALL || (HATREST[HatID] == get_user_team(id) + 1)) {
                    
Set_Hat(id,HatID,id)
                } else {
                    if (
HATREST[HatID] == HAT_TERROR && get_user_team(id) == 2) {
                        
client_print(id,print_chat,"[%s] This hat is currently set as a Terrorist Hat.",PLUG_TAG)
                    } else if (
HATREST[HatID] == HAT_COUNTER && get_user_team(id) == 1) {
                        
client_print(id,print_chat,"[%s] This hat is currently set as Counter Terrorist.",PLUG_TAG)
                    } else {
                        
client_print(id,print_chat,"[%s] This hat is currently set as Admin Only.",PLUG_TAG)
                    }
                }
            }
        }
    }
    return 
PLUGIN_HANDLED
}

public 
plugin_precache() {
    new 
cfgDir[32]
    
get_configsdir(cfgDir,31)
    
formatex(HatFile,63,"%s/HatList.ini",cfgDir)
    
command_load()
    new 
tmpfile [101]
    for (new 
1TotalHats; ++i) {
        
format(tmpfile100"%s/%s"modelpathHATMDL[i])
        if (
file_exists (tmpfile)) {
            
precache_model(tmpfile)
            
server_print("[%s] Precached %s"PLUG_TAGHATMDL[i])
        } else {
            
server_print("[%s] Failed to precache %s"PLUG_TAGtmpfile)
        }
    }
}

public 
client_putinserver(id) {
    if (
get_pcvar_num(P_ForceHat) == 1) {
        new 
forceID get_pcvar_num(P_ForceHat)
        if (
forceID <= TotalHats 1) {
            
forcehat(idforceID)
        } else {
            
set_pcvar_num(P_ForceHat0)
        }
    } else if (
get_pcvar_num(P_RandomJoin) == || (get_pcvar_num(P_BotRandom) == && is_user_bot(id))) {
        if (
get_pcvar_num(P_ForceHat) == 0Random_Hat(id)
    }
    return 
PLUGIN_CONTINUE
}

public 
event_team_info() {
    if (
get_pcvar_num(P_ForceHat) != 0) return
    new 
id read_data(1)
    if (
HATREST[CurrentHat[id]] == HAT_ALL) return
    if (
HATREST[CurrentHat[id]] == HAT_ADMIN && get_user_flags(id) & PLUG_ADMINB) return
    
    new 
team[3]
    
read_data(2team2)
    switch(
team[0]) {
        case 
'C': {
            if (
HATREST[CurrentHat[id]] != HAT_COUNTERRandom_Hat(id)
        }
        case 
'T': {
            if (
HATREST[CurrentHat[id]] != HAT_TERRORRandom_Hat(id)
        }
        case 
'S': {
            
Set_Hat(id00)
        }
    }
    return
}
public 
event_roundstart() {
    new 
forceID get_pcvar_num(P_ForceHat)
    for (new 
0get_maxplayers(); ++i) {
        if (
is_user_connected(i) && g_HatEnt[i] > 0) {
            if (
forceID != 0) {
                
forcehat(iforceID)
            }
            
glowhat(i)
        }
    }
    return 
PLUGIN_CONTINUE
}

public 
Give_Hat(idreq_flag)
{
    if( !(
get_user_flags(id) & req_flag) )
        return 
PLUGIN_HANDLED
    
    
new smodelnum[5], name[32]
    
read_argv(1,name,31)
    
read_argv(2,smodelnum,4)
    
    new 
player cmd_target(id,name,2)
    if (!
player) {
        
client_print(id,print_chat,"[%s] Player With That Name Does Not Exist.",PLUG_TAG)
        return 
PLUGIN_HANDLED
    
}
    
    new 
imodelnum = (str_to_num(smodelnum))
    if (
imodelnum MAX_HATS) return PLUGIN_HANDLED
    
    Set_Hat
(player,imodelnum,id)

    return 
PLUGIN_CONTINUE
}

public 
Remove_Hat(idreq_flag)
{
    if( !(
get_user_flags(id) & req_flag) )
        return 
PLUGIN_HANDLED

    
for (new 0get_maxplayers(); ++i) {
        if (
is_user_connected(i) && g_HatEnt[i] > 0) {
            
Set_Hat(id00)
        }
    }
    
client_print(id,print_chat,"[%s] Removed hats from everyone.",PLUG_TAG)
    return 
PLUGIN_CONTINUE
}

public 
Random_Hat(id) {
    new 
bool:foundrnd falsecntTry 0randID random_num (1TotalHats 1)
    while (
cntTry maxTry && foundrnd == false) {
        
randID random_num (1TotalHats 1)
        
cntTry += 1
        
if (HATREST[randID] == HAT_ALLfoundrnd true
        
if (HATREST[randID] == HAT_ADMIN && get_user_flags(id) & PLUG_ADMINBfoundrnd true
        
if ((get_user_team(id) != 0) && HATREST[CurrentHat[id]] == get_user_team(id) + 1foundrnd true
    
}
    if (
foundrnd == true) {    //If a valid random hat is found, apply it.
        
Set_Hat(idrandID 0)
    } else {                
//Otherwise, don't use any hat.
        
Set_Hat(id00)    
    }
    return 
PLUGIN_CONTINUE
}

public 
Set_Hat(playerimodelnumtargeter) {
    new 
name[32]
    new 
tmpfile[101]
    
format(tmpfile100"%s/%s"modelpathHATMDL[imodelnum])
    
get_user_name(playername31)
    if (
imodelnum == 0) {
        if(
g_HatEnt[player] > 0) {
            
fm_set_entity_visibility(g_HatEnt[player], 0)
        }
        if (
targeter != 0) {
            
client_print(targeterprint_chat"[%s] Removed hat from %s",PLUG_TAG,name)
        }
    } else if (
file_exists(tmpfile)) {
        if(
g_HatEnt[player] < 1) {
            
g_HatEnt[player] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))
            if(
g_HatEnt[player] > 0) {
                
set_pev(g_HatEnt[player], pev_movetypeMOVETYPE_FOLLOW)
                
set_pev(g_HatEnt[player], pev_aimentplayer)
                
set_pev(g_HatEnt[player], pev_rendermode,     kRenderNormal)
                
engfunc(EngFunc_SetModelg_HatEnt[player], tmpfile)
            }
        } else {
            
engfunc(EngFunc_SetModelg_HatEnt[player], tmpfile)
        }
        
glowhat(player)
        
CurrentHat[player] = imodelnum
        
if (targeter != 0) {
            
client_print(targeterprint_chat"[%s] Set %s on %s",PLUG_TAG,HATNAME[imodelnum],name)
        }
    }
}

public 
command_load() {
    if(
file_exists(HatFile)) {
        
HATMDL[0] = ""
        
HATNAME[0] = "None"
        
TotalHats 1
        
new TempCrapA[2]
        new 
sfLineData[128]
        new 
file fopen(HatFile,"rt")
        while(
file && !feof(file)) {
            
fgets(file,sfLineData,127)
            
            
// Skip Comment ; // and Empty Lines 
            
if (sfLineData[0] == ';' || strlen(sfLineData) < || (sfLineData[0] == '/' && sfLineData[1] == '/')) continue
            
            
// BREAK IT UP!
            
parse(sfLineDataHATMDL[TotalHats], 25HATNAME[TotalHats], 25TempCrapA1)
            
            if (
TempCrapA[0] == 'A' || TempCrapA[0] == '1') {
                
HATREST[TotalHats] = HAT_ADMIN
            
} else if (TempCrapA[0] == 'T' || TempCrapA[0] == '2') {
                
HATREST[TotalHats] = HAT_TERROR
            
} else if (TempCrapA[0] == 'C' || TempCrapA[0] == '3') {
                
HATREST[TotalHats] = HAT_COUNTER
            
} else {
                
HATREST[TotalHats] = HAT_ALL
            
}
            
TotalHats += 1
            
if(TotalHats >= MAX_HATS) {
                
server_print("[%s] Reached hat limit",PLUG_TAG)
                break
            }
        }
        if(
filefclose(file)
    }
    
MenuPages floatround((TotalHats 8.0), floatround_ceil)
    
server_print("[%s] Loaded %i hats, and Generated %i pages",PLUG_TAG,TotalHats,MenuPages)
}


menucolor(idItemIDMnuClr[3]) {
    
//If its the hat they currently have on
    
if (ItemID == CurrentHat[id]) {
        
MnuClr "\d"
        
return
    }
    if (
HATREST[ItemID] != HAT_ALL) {
        
//If its an AdminHat&They are NOT an admin
        
if (HATREST[ItemID] == HAT_ADMIN && get_pcvar_num(P_AdminHats) == 1) {
            if (
get_user_flags(id) & PLUG_ADMINB) {
                
MnuClr "\y"
            
} else {
                
MnuClr "\r"
            
}
        
//If this is a hat set for there team or not
        
} else if (HATREST[ItemID] != get_user_team(id) + 1) {
            
MnuClr "\r"
        
} else {
            
MnuClr "\y"
        
}
    } else {
        
MnuClr "\w"
    
}
    return
}

glowhat(id) {
    if (!
pev_valid(g_HatEnt[id])) return
    if (
get_pcvar_num(P_Glow) != 0) {    //If Glowing Hats Are Enabled
        
set_pev(g_HatEnt[id], pev_renderfx,    kRenderFxGlowShell)
        if (
get_pcvar_num(P_Glow) == 2) {    //If Not Team Specific, Use Player Glow On Hat
            
new Float:curcolors[3], Float:curamt
            pev
(idpev_rendercolorcurcolors)
            
pev(idpev_renderamtcuramt)
            
set_pev(g_HatEnt[id], pev_rendercolorcurcolors)
            
set_pev(g_HatEnt[id], pev_renderamtcuramt)
        } else {                                
//If Team Specific, Red=T, Blue=CT
            
if (get_user_team(id) == 1) {
                
set_pev(g_HatEnt[id], pev_rendercolor, {200.00.00.0})
            } else if (
get_user_team(id) == 2) {
                
set_pev(g_HatEnt[id], pev_rendercolor, {0.00.0200.0})
            }
            
set_pev(g_HatEnt[id], pev_renderamt,    50.0)
        }
    } else {
        
set_pev(g_HatEnt[id], pev_renderfx,    kRenderFxNone)
        
set_pev(g_HatEnt[id], pev_renderamt,    0.0)
    }
    
fm_set_entity_visibility(g_HatEnt[id], 1)
    return
}

forcehat(idforceID) {
    if (
forceID == 0forceID get_pcvar_num(P_ForceHat)
    if (
forceID != 0) {
        if (
forceID <= TotalHats 1) {
            if (
forceID != CurrentHat[id]) Set_Hat(idforceID0)
        } else {
            
set_pcvar_num(P_ForceHat0)
        }
    }
}

/*============================================================
                     Stocks!
============================================================*/
stock ChatColor(const id, const input[], any:...)
{
    new 
count 1players[32]
    static 
msg[191]
    
vformat(msg190input3)
    
    
replace_all(msg190"!g""^4"// Green Color
    
replace_all(msg190"!y""^1"// Default Color
    
replace_all(msg190"!team""^3"// Team Color

    
    
if (idplayers[0] = id; else get_players(playerscount"ch")
    {
        for (new 
0counti++)
        {
            if (
is_user_connected(players[i]))
            {
            
message_begin(MSG_ONE_UNRELIABLEg_iMsgSayText_players[i])  
            
write_byte(players[i]);
            
write_string(msg);
            
message_end();
            }
        }
    }

KleirPlays is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 08-03-2014 , 18:06   Re: Help, got a little compilation error.
Reply With Quote #2

PHP Code:
#include <amxmodx> 
#include <amxmisc> 
#include <fakemeta>  

#define PLUG_NAME         "HATS" 
#define PLUG_AUTH         "SgtBane" 
#define PLUG_VERS         "1.8" 
#define PLUG_TAG         "Wicked" 
#define PLUG_ADMIN        ADMIN_RCON        //Access flags required to give/remove hats 
#define PLUG_ADMINB     ADMIN_CHAT        //Access flags required to set personal hat if admin only is enabled 

#define OFFSET_GLOWSET    100 

#define HAT_ALL            0 
#define HAT_ADMIN        1 
#define HAT_TERROR        2 
#define HAT_COUNTER        3 

#define menusize         220 
#define maxTry            15                //Number of tries to get someone a non-admin random hat before giving up. 
#define modelpath        "models/hat" 

stock fm_set_entity_visibility(indexvisible 1set_pev(indexpev_effectsvisible == pev(indexpev_effects) & ~EF_NODRAW pev(indexpev_effects) | EF_NODRAW

new 
g_HatEnt[33
new 
CurrentHat[33
new 
CurrentMenu[33

new 
HatFile[64
new 
MenuPagesTotalHats 

#define MAX_HATS 64 
new HATMDL[MAX_HATS][26
new 
HATNAME[MAX_HATS][26
new 
HATREST[MAX_HATS

new 
P_AdminOnly 
new P_AdminHats 
new P_RandomJoin 
new P_BotRandom 
new P_ForceHat 
new P_Glow 

new g_iMsgSayText

public plugin_init() { 
    
register_plugin(PLUG_NAMEPLUG_VERSPLUG_AUTH
    
register_logevent("event_roundstart",     2,    "1=Round_Start"
    
register_event("TeamInfo",                 "event_team_info",     "a" 
     
    
register_concmd("amx_givehat",         "Give_Hat",     PLUG_ADMIN,     "<nick> <mdl #>"
    
register_concmd("amx_removehats",     "Remove_Hat",     PLUG_ADMIN,     " - Removes hats from everyone."
     
    
register_menucmd(register_menuid("\yHat Menu: [Page"),    (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9),"MenuCommand"
    
register_clcmd("say /hats",            "ShowMenu", -1,     "Shows Knife menu"
     
    
P_AdminOnly        register_cvar("hat_adminonly",    "0")    //Only admins can use the menu 
    
P_AdminHats     register_cvar("hat_adminhats",    "1")    //Allow hats for admins only (if 0, hats specifically for admins can be used by anyone) 
    
P_RandomJoin    register_cvar("hat_random",        "1")    //Random hats for players as they join 
    
P_BotRandom        register_cvar("hat_bots",            "1")    //Random hats for bots as they join 
    
P_ForceHat        register_cvar("hat_force",        "0")    //Force a specific hat (if not 0) 
    
P_Glow            register_cvar("hat_glow",            "1")    //0=None,1=GlowWithPlayer,2=TeamColor 
    
    
g_iMsgSayText get_user_msgid("SayText")


public 
ShowMenu(id) { 
    if ((
get_pcvar_num(P_AdminOnly) == && get_user_flags(id) & PLUG_ADMIN) || (get_pcvar_num(P_AdminOnly) == && get_pcvar_num(P_ForceHat) == 0)) { 
        
CurrentMenu[id] = 
        ShowHats
(id
    } else { 
        
ChatColor(id"%s Only admins may currently use this menu.",PLUG_TAG
    } 
    return 
PLUGIN_HANDLED 


public 
ShowHats(id) { 
    new 
keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9
     
    new 
szMenuBody[menusize 1], WpnID 
    
new nLen format(szMenuBodymenusize"\yHat Menu: [Page %i/%i]^n",CurrentMenu[id],MenuPages
     
    new 
MnuClr[3
    
// Get Hat Names And Add Them To The List 
    
for (new hatid=0hatid 8hatid++) { 
        
WpnID = ((CurrentMenu[id] * 8) + hatid 8
        if (
WpnID TotalHats) { 
            
menucolor(idWpnIDMnuClr
            
nLen += format(szMenuBody[nLen], menusize-nLen"^n\w%i.%s %s"hatid 1MnuClrHATNAME[WpnID]) 
        } 
    } 
     
    
// Next Page And Previous/Close 
    
if (CurrentMenu[id] == MenuPages) { 
        
nLen += format(szMenuBody[nLen], menusize-nLen"^n^n\d9. Next Page"
    } else { 
        
nLen += format(szMenuBody[nLen], menusize-nLen"^n^n\w9. Next Page"
    } 
     
    if (
CurrentMenu[id] > 1) { 
        
nLen += format(szMenuBody[nLen], menusize-nLen"^n\w0. Previous Page"
    } else { 
        
nLen += format(szMenuBody[nLen], menusize-nLen"^n\w0. Close"
    } 
    
show_menu(idkeysszMenuBody, -1
    return 
PLUGIN_HANDLED 


public 
MenuCommand(idkey) { 
    switch(
key
    { 
        case 
8:        //9 - [Next Page] 
        

            if (
CurrentMenu[id] < MenuPagesCurrentMenu[id]++ 
            
ShowHats(id
            return 
PLUGIN_HANDLED 
        

        case 
9:        //0 - [Close] 
        

            
CurrentMenu[id]-- 
            if (
CurrentMenu[id] > 0ShowHats(id
            return 
PLUGIN_HANDLED 
        

        default: 
        { 
            new 
HatID = ((CurrentMenu[id] * 8) + key 8
            if (
HatID TotalHats) { 
                if ((
get_pcvar_num(P_AdminHats) == && HATREST[HatID] == HAT_ADMIN) || (get_pcvar_num(P_AdminHats) == && HATREST[HatID] == HAT_ADMIN && get_user_flags(id) & PLUG_ADMINB) || HATREST[HatID] == HAT_ALL || (HATREST[HatID] == get_user_team(id) + 1)) { 
                    
Set_Hat(id,HatID,id
                } else { 
                    if (
HATREST[HatID] == HAT_TERROR && get_user_team(id) == 2) { 
                        
client_print(id,print_chat,"[%s] This hat is currently set as a Terrorist Hat.",PLUG_TAG
                    } else if (
HATREST[HatID] == HAT_COUNTER && get_user_team(id) == 1) { 
                        
client_print(id,print_chat,"[%s] This hat is currently set as Counter Terrorist.",PLUG_TAG
                    } else { 
                        
client_print(id,print_chat,"[%s] This hat is currently set as Admin Only.",PLUG_TAG
                    } 
                } 
            } 
        } 
    } 
    return 
PLUGIN_HANDLED 


public 
plugin_precache() { 
    new 
cfgDir[32
    
get_configsdir(cfgDir,31
    
formatex(HatFile,63,"%s/HatList.ini",cfgDir
    
command_load() 
    new 
tmpfile [101
    for (new 
1TotalHats; ++i) { 
        
format(tmpfile100"%s/%s"modelpathHATMDL[i]) 
        if (
file_exists (tmpfile)) { 
            
precache_model(tmpfile
            
server_print("[%s] Precached %s"PLUG_TAGHATMDL[i]) 
        } else { 
            
server_print("[%s] Failed to precache %s"PLUG_TAGtmpfile
        } 
    } 


public 
client_putinserver(id) { 
    if (
get_pcvar_num(P_ForceHat) == 1) { 
        new 
forceID get_pcvar_num(P_ForceHat
        if (
forceID <= TotalHats 1) { 
            
forcehat(idforceID
        } else { 
            
set_pcvar_num(P_ForceHat0
        } 
    } else if (
get_pcvar_num(P_RandomJoin) == || (get_pcvar_num(P_BotRandom) == && is_user_bot(id))) { 
        if (
get_pcvar_num(P_ForceHat) == 0Random_Hat(id
    } 
    return 
PLUGIN_CONTINUE 


public 
event_team_info() { 
    if (
get_pcvar_num(P_ForceHat) != 0) return 
    new 
id read_data(1
    if (
HATREST[CurrentHat[id]] == HAT_ALL) return 
    if (
HATREST[CurrentHat[id]] == HAT_ADMIN && get_user_flags(id) & PLUG_ADMINB) return 
     
    new 
team[3
    
read_data(2team2
    switch(
team[0]) { 
        case 
'C': { 
            if (
HATREST[CurrentHat[id]] != HAT_COUNTERRandom_Hat(id
        } 
        case 
'T': { 
            if (
HATREST[CurrentHat[id]] != HAT_TERRORRandom_Hat(id
        } 
        case 
'S': { 
            
Set_Hat(id00
        } 
    } 
    return 

public 
event_roundstart() { 
    new 
forceID get_pcvar_num(P_ForceHat
    for (new 
0get_maxplayers(); ++i) { 
        if (
is_user_connected(i) && g_HatEnt[i] > 0) { 
            if (
forceID != 0) { 
                
forcehat(iforceID
            } 
            
glowhat(i
        } 
    } 
    return 
PLUGIN_CONTINUE 


public 
Give_Hat(idreq_flag

    if( !(
get_user_flags(id) & req_flag) ) 
        return 
PLUGIN_HANDLED 
     
    
new smodelnum[5], name[32
    
read_argv(1,name,31
    
read_argv(2,smodelnum,4
     
    new 
player cmd_target(id,name,2
    if (!
player) { 
        
client_print(id,print_chat,"[%s] Player With That Name Does Not Exist.",PLUG_TAG
        return 
PLUGIN_HANDLED 
    

     
    new 
imodelnum = (str_to_num(smodelnum)) 
    if (
imodelnum MAX_HATS) return PLUGIN_HANDLED 
     
    Set_Hat
(player,imodelnum,id

    return 
PLUGIN_CONTINUE 


public 
Remove_Hat(idreq_flag

    if( !(
get_user_flags(id) & req_flag) ) 
        return 
PLUGIN_HANDLED 

    
for (new 0get_maxplayers(); ++i) { 
        if (
is_user_connected(i) && g_HatEnt[i] > 0) { 
            
Set_Hat(id00
        } 
    } 
    
client_print(id,print_chat,"[%s] Removed hats from everyone.",PLUG_TAG
    return 
PLUGIN_CONTINUE 


public 
Random_Hat(id) { 
    new 
bool:foundrnd falsecntTry 0randID random_num (1TotalHats 1
    while (
cntTry maxTry && foundrnd == false) { 
        
randID random_num (1TotalHats 1
        
cntTry += 
        
if (HATREST[randID] == HAT_ALLfoundrnd true 
        
if (HATREST[randID] == HAT_ADMIN && get_user_flags(id) & PLUG_ADMINBfoundrnd true 
        
if ((get_user_team(id) != 0) && HATREST[CurrentHat[id]] == get_user_team(id) + 1foundrnd true 
    

    if (
foundrnd == true) {    //If a valid random hat is found, apply it. 
        
Set_Hat(idrandID 0
    } else {                
//Otherwise, don't use any hat. 
        
Set_Hat(id00)     
    } 
    return 
PLUGIN_CONTINUE 


public 
Set_Hat(playerimodelnumtargeter) { 
    new 
name[32
    new 
tmpfile[101
    
format(tmpfile100"%s/%s"modelpathHATMDL[imodelnum]) 
    
get_user_name(playername31
    if (
imodelnum == 0) { 
        if(
g_HatEnt[player] > 0) { 
            
fm_set_entity_visibility(g_HatEnt[player], 0
        } 
        if (
targeter != 0) { 
            
client_print(targeterprint_chat"[%s] Removed hat from %s",PLUG_TAG,name
        } 
    } else if (
file_exists(tmpfile)) { 
        if(
g_HatEnt[player] < 1) { 
            
g_HatEnt[player] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target")) 
            if(
g_HatEnt[player] > 0) { 
                
set_pev(g_HatEnt[player], pev_movetypeMOVETYPE_FOLLOW
                
set_pev(g_HatEnt[player], pev_aimentplayer
                
set_pev(g_HatEnt[player], pev_rendermode,     kRenderNormal
                
engfunc(EngFunc_SetModelg_HatEnt[player], tmpfile
            } 
        } else { 
            
engfunc(EngFunc_SetModelg_HatEnt[player], tmpfile
        } 
        
glowhat(player
        
CurrentHat[player] = imodelnum 
        
if (targeter != 0) { 
            
client_print(targeterprint_chat"[%s] Set %s on %s",PLUG_TAG,HATNAME[imodelnum],name
        } 
    } 


public 
command_load() { 
    if(
file_exists(HatFile)) { 
        
HATMDL[0] = "" 
        
HATNAME[0] = "None" 
        
TotalHats 
        
new TempCrapA[2
        new 
sfLineData[128
        new 
file fopen(HatFile,"rt"
        while(
file && !feof(file)) { 
            
fgets(file,sfLineData,127
             
            
// Skip Comment ; // and Empty Lines  
            
if (sfLineData[0] == ';' || strlen(sfLineData) < || (sfLineData[0] == '/' && sfLineData[1] == '/')) continue 
             
            
// BREAK IT UP! 
            
parse(sfLineDataHATMDL[TotalHats], 25HATNAME[TotalHats], 25TempCrapA1
             
            if (
TempCrapA[0] == 'A' || TempCrapA[0] == '1') { 
                
HATREST[TotalHats] = HAT_ADMIN 
            
} else if (TempCrapA[0] == 'T' || TempCrapA[0] == '2') { 
                
HATREST[TotalHats] = HAT_TERROR 
            
} else if (TempCrapA[0] == 'C' || TempCrapA[0] == '3') { 
                
HATREST[TotalHats] = HAT_COUNTER 
            
} else { 
                
HATREST[TotalHats] = HAT_ALL 
            

            
TotalHats += 
            
if(TotalHats >= MAX_HATS) { 
                
server_print("[%s] Reached hat limit",PLUG_TAG
                break 
            } 
        } 
        if(
filefclose(file
    } 
    
MenuPages floatround((TotalHats 8.0), floatround_ceil
    
server_print("[%s] Loaded %i hats, and Generated %i pages",PLUG_TAG,TotalHats,MenuPages



menucolor(idItemIDMnuClr[3]) { 
    
//If its the hat they currently have on 
    
if (ItemID == CurrentHat[id]) { 
        
MnuClr "\d" 
        
return 
    } 
    if (
HATREST[ItemID] != HAT_ALL) { 
        
//If its an AdminHat&They are NOT an admin 
        
if (HATREST[ItemID] == HAT_ADMIN && get_pcvar_num(P_AdminHats) == 1) { 
            if (
get_user_flags(id) & PLUG_ADMINB) { 
                
MnuClr "\y" 
            
} else { 
                
MnuClr "\r" 
            

        
//If this is a hat set for there team or not 
        
} else if (HATREST[ItemID] != get_user_team(id) + 1) { 
            
MnuClr "\r" 
        
} else { 
            
MnuClr "\y" 
        

    } else { 
        
MnuClr "\w" 
    

    return 


glowhat(id) { 
    if (!
pev_valid(g_HatEnt[id])) return 
    if (
get_pcvar_num(P_Glow) != 0) {    //If Glowing Hats Are Enabled 
        
set_pev(g_HatEnt[id], pev_renderfx,    kRenderFxGlowShell
        if (
get_pcvar_num(P_Glow) == 2) {    //If Not Team Specific, Use Player Glow On Hat 
            
new Float:curcolors[3], Float:curamt 
            pev
(idpev_rendercolorcurcolors
            
pev(idpev_renderamtcuramt
            
set_pev(g_HatEnt[id], pev_rendercolorcurcolors
            
set_pev(g_HatEnt[id], pev_renderamtcuramt
        } else {                                
//If Team Specific, Red=T, Blue=CT 
            
if (get_user_team(id) == 1) { 
                
set_pev(g_HatEnt[id], pev_rendercolor, {200.00.00.0}) 
            } else if (
get_user_team(id) == 2) { 
                
set_pev(g_HatEnt[id], pev_rendercolor, {0.00.0200.0}) 
            } 
            
set_pev(g_HatEnt[id], pev_renderamt,    50.0
        } 
    } else { 
        
set_pev(g_HatEnt[id], pev_renderfx,    kRenderFxNone
        
set_pev(g_HatEnt[id], pev_renderamt,    0.0
    } 
    
fm_set_entity_visibility(g_HatEnt[id], 1
    return 


forcehat(idforceID) { 
    if (
forceID == 0forceID get_pcvar_num(P_ForceHat
    if (
forceID != 0) { 
        if (
forceID <= TotalHats 1) { 
            if (
forceID != CurrentHat[id]) Set_Hat(idforceID0
        } else { 
            
set_pcvar_num(P_ForceHat0
        } 
    } 


/*============================================================ 
                     Stocks! 
============================================================*/ 
stock ChatColor(const id, const input[], any:...) 

    new 
count 1players[32
    static 
msg[191
    
vformat(msg190input3
     
    
replace_all(msg190"!g""^4"// Green Color 
    
replace_all(msg190"!y""^1"// Default Color 
    
replace_all(msg190"!team""^3"// Team Color 

     
    
if (idplayers[0] = id; else get_players(playerscount"ch"
    { 
        for (new 
0counti++) 
        { 
            if (
is_user_connected(players[i])) 
            { 
            
message_begin(MSG_ONE_UNRELIABLEg_iMsgSayText_players[i])   
            
write_byte(players[i]); 
            
write_string(msg); 
            
message_end(); 
            } 
        } 
    } 

Remove the include, you didn't use it anywhere.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
KleirPlays
Member
Join Date: Jun 2013
Location: Portugal
Old 08-03-2014 , 18:18   Re: Help, got a little compilation error.
Reply With Quote #3

I want to change line 274, 291 to chatcolor aswell like I did in line 72.

PHP Code:
#include <amxmodx> 
#include <amxmisc> 
#include <fakemeta>  

#define PLUG_NAME         "HATS" 
#define PLUG_AUTH         "SgtBane" 
#define PLUG_VERS         "1.8" 
#define PLUG_TAG         "Wicked" 
#define PLUG_ADMIN        ADMIN_RCON        //Access flags required to give/remove hats 
#define PLUG_ADMINB     ADMIN_CHAT        //Access flags required to set personal hat if admin only is enabled 

#define OFFSET_GLOWSET    100 

#define HAT_ALL            0 
#define HAT_ADMIN        1 
#define HAT_TERROR        2 
#define HAT_COUNTER        3 

#define menusize         220 
#define maxTry            15                //Number of tries to get someone a non-admin random hat before giving up. 
#define modelpath        "models/hat" 

stock fm_set_entity_visibility(indexvisible 1set_pev(indexpev_effectsvisible == pev(indexpev_effects) & ~EF_NODRAW pev(indexpev_effects) | EF_NODRAW

new 
g_HatEnt[33
new 
CurrentHat[33
new 
CurrentMenu[33

new 
HatFile[64
new 
MenuPagesTotalHats 

#define MAX_HATS 64 
new HATMDL[MAX_HATS][26
new 
HATNAME[MAX_HATS][26
new 
HATREST[MAX_HATS

new 
P_AdminOnly 
new P_AdminHats 
new P_RandomJoin 
new P_BotRandom 
new P_ForceHat 
new P_Glow 

new g_iMsgSayText

public plugin_init() { 
    
register_plugin(PLUG_NAMEPLUG_VERSPLUG_AUTH
    
register_logevent("event_roundstart",     2,    "1=Round_Start"
    
register_event("TeamInfo",                 "event_team_info",     "a" 
     
    
register_concmd("amx_givehat",         "Give_Hat",     PLUG_ADMIN,     "<nick> <mdl #>"
    
register_concmd("amx_removehats",     "Remove_Hat",     PLUG_ADMIN,     " - Removes hats from everyone."
     
    
register_menucmd(register_menuid("\yHat Menu: [Page"),    (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9),"MenuCommand"
    
register_clcmd("say /hats",            "ShowMenu", -1,     "Shows Knife menu"
     
    
P_AdminOnly        register_cvar("hat_adminonly",    "0")    //Only admins can use the menu 
    
P_AdminHats     register_cvar("hat_adminhats",    "1")    //Allow hats for admins only (if 0, hats specifically for admins can be used by anyone) 
    
P_RandomJoin    register_cvar("hat_random",        "1")    //Random hats for players as they join 
    
P_BotRandom        register_cvar("hat_bots",            "1")    //Random hats for bots as they join 
    
P_ForceHat        register_cvar("hat_force",        "0")    //Force a specific hat (if not 0) 
    
P_Glow            register_cvar("hat_glow",            "1")    //0=None,1=GlowWithPlayer,2=TeamColor 
    
    
g_iMsgSayText get_user_msgid("SayText")


public 
ShowMenu(id) { 
    if ((
get_pcvar_num(P_AdminOnly) == && get_user_flags(id) & PLUG_ADMIN) || (get_pcvar_num(P_AdminOnly) == && get_pcvar_num(P_ForceHat) == 0)) { 
        
CurrentMenu[id] = 
        ShowHats
(id
    } else { 
        
ChatColor(id"!g%s !yOnly !tadmins!y may currently use this menu.",PLUG_TAG
    } 
    return 
PLUGIN_HANDLED 


public 
ShowHats(id) { 
    new 
keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9
     
    new 
szMenuBody[menusize 1], WpnID 
    
new nLen format(szMenuBodymenusize"\yHat Menu: [Page %i/%i]^n",CurrentMenu[id],MenuPages
     
    new 
MnuClr[3
    
// Get Hat Names And Add Them To The List 
    
for (new hatid=0hatid 8hatid++) { 
        
WpnID = ((CurrentMenu[id] * 8) + hatid 8
        if (
WpnID TotalHats) { 
            
menucolor(idWpnIDMnuClr
            
nLen += format(szMenuBody[nLen], menusize-nLen"^n\w%i.%s %s"hatid 1MnuClrHATNAME[WpnID]) 
        } 
    } 
     
    
// Next Page And Previous/Close 
    
if (CurrentMenu[id] == MenuPages) { 
        
nLen += format(szMenuBody[nLen], menusize-nLen"^n^n\d9. Next Page"
    } else { 
        
nLen += format(szMenuBody[nLen], menusize-nLen"^n^n\w9. Next Page"
    } 
     
    if (
CurrentMenu[id] > 1) { 
        
nLen += format(szMenuBody[nLen], menusize-nLen"^n\w0. Previous Page"
    } else { 
        
nLen += format(szMenuBody[nLen], menusize-nLen"^n\w0. Close"
    } 
    
show_menu(idkeysszMenuBody, -1
    return 
PLUGIN_HANDLED 


public 
MenuCommand(idkey) { 
    switch(
key
    { 
        case 
8:        //9 - [Next Page] 
        

            if (
CurrentMenu[id] < MenuPagesCurrentMenu[id]++ 
            
ShowHats(id
            return 
PLUGIN_HANDLED 
        

        case 
9:        //0 - [Close] 
        

            
CurrentMenu[id]-- 
            if (
CurrentMenu[id] > 0ShowHats(id
            return 
PLUGIN_HANDLED 
        

        default: 
        { 
            new 
HatID = ((CurrentMenu[id] * 8) + key 8
            if (
HatID TotalHats) { 
                if ((
get_pcvar_num(P_AdminHats) == && HATREST[HatID] == HAT_ADMIN) || (get_pcvar_num(P_AdminHats) == && HATREST[HatID] == HAT_ADMIN && get_user_flags(id) & PLUG_ADMINB) || HATREST[HatID] == HAT_ALL || (HATREST[HatID] == get_user_team(id) + 1)) { 
                    
Set_Hat(id,HatID,id
                } else { 
                    if (
HATREST[HatID] == HAT_TERROR && get_user_team(id) == 2) { 
                        
client_print(id,print_chat,"[%s] This hat is currently set as a Terrorist Hat.",PLUG_TAG
                    } else if (
HATREST[HatID] == HAT_COUNTER && get_user_team(id) == 1) { 
                        
client_print(id,print_chat,"[%s] This hat is currently set as Counter Terrorist.",PLUG_TAG
                    } else { 
                        
client_print(id,print_chat,"[%s] This hat is currently set as Admin Only.",PLUG_TAG
                    } 
                } 
            } 
        } 
    } 
    return 
PLUGIN_HANDLED 


public 
plugin_precache() { 
    new 
cfgDir[32
    
get_configsdir(cfgDir,31
    
formatex(HatFile,63,"%s/HatList.ini",cfgDir
    
command_load() 
    new 
tmpfile [101
    for (new 
1TotalHats; ++i) { 
        
format(tmpfile100"%s/%s"modelpathHATMDL[i]) 
        if (
file_exists (tmpfile)) { 
            
precache_model(tmpfile
            
server_print("[%s] Precached %s"PLUG_TAGHATMDL[i]) 
        } else { 
            
server_print("[%s] Failed to precache %s"PLUG_TAGtmpfile
        } 
    } 


public 
client_putinserver(id) { 
    if (
get_pcvar_num(P_ForceHat) == 1) { 
        new 
forceID get_pcvar_num(P_ForceHat
        if (
forceID <= TotalHats 1) { 
            
forcehat(idforceID
        } else { 
            
set_pcvar_num(P_ForceHat0
        } 
    } else if (
get_pcvar_num(P_RandomJoin) == || (get_pcvar_num(P_BotRandom) == && is_user_bot(id))) { 
        if (
get_pcvar_num(P_ForceHat) == 0Random_Hat(id
    } 
    return 
PLUGIN_CONTINUE 


public 
event_team_info() { 
    if (
get_pcvar_num(P_ForceHat) != 0) return 
    new 
id read_data(1
    if (
HATREST[CurrentHat[id]] == HAT_ALL) return 
    if (
HATREST[CurrentHat[id]] == HAT_ADMIN && get_user_flags(id) & PLUG_ADMINB) return 
     
    new 
team[3
    
read_data(2team2
    switch(
team[0]) { 
        case 
'C': { 
            if (
HATREST[CurrentHat[id]] != HAT_COUNTERRandom_Hat(id
        } 
        case 
'T': { 
            if (
HATREST[CurrentHat[id]] != HAT_TERRORRandom_Hat(id
        } 
        case 
'S': { 
            
Set_Hat(id00
        } 
    } 
    return 

public 
event_roundstart() { 
    new 
forceID get_pcvar_num(P_ForceHat
    for (new 
0get_maxplayers(); ++i) { 
        if (
is_user_connected(i) && g_HatEnt[i] > 0) { 
            if (
forceID != 0) { 
                
forcehat(iforceID
            } 
            
glowhat(i
        } 
    } 
    return 
PLUGIN_CONTINUE 


public 
Give_Hat(idreq_flag

    if( !(
get_user_flags(id) & req_flag) ) 
        return 
PLUGIN_HANDLED 
     
    
new smodelnum[5], name[32
    
read_argv(1,name,31
    
read_argv(2,smodelnum,4
     
    new 
player cmd_target(id,name,2
    if (!
player) { 
        
client_print(id,print_chat,"[%s] Player With That Name Does Not Exist.",PLUG_TAG
        return 
PLUGIN_HANDLED 
    

     
    new 
imodelnum = (str_to_num(smodelnum)) 
    if (
imodelnum MAX_HATS) return PLUGIN_HANDLED 
     
    Set_Hat
(player,imodelnum,id

    return 
PLUGIN_CONTINUE 


public 
Remove_Hat(idreq_flag

    if( !(
get_user_flags(id) & req_flag) ) 
        return 
PLUGIN_HANDLED 

    
for (new 0get_maxplayers(); ++i) { 
        if (
is_user_connected(i) && g_HatEnt[i] > 0) { 
            
Set_Hat(id00
        } 
    } 
    
client_print(id,print_chat,"[%s] Removed hats from everyone.",PLUG_TAG
    return 
PLUGIN_CONTINUE 


public 
Random_Hat(id) { 
    new 
bool:foundrnd falsecntTry 0randID random_num (1TotalHats 1
    while (
cntTry maxTry && foundrnd == false) { 
        
randID random_num (1TotalHats 1
        
cntTry += 
        
if (HATREST[randID] == HAT_ALLfoundrnd true 
        
if (HATREST[randID] == HAT_ADMIN && get_user_flags(id) & PLUG_ADMINBfoundrnd true 
        
if ((get_user_team(id) != 0) && HATREST[CurrentHat[id]] == get_user_team(id) + 1foundrnd true 
    

    if (
foundrnd == true) {    //If a valid random hat is found, apply it. 
        
Set_Hat(idrandID 0
    } else {                
//Otherwise, don't use any hat. 
        
Set_Hat(id00)     
    } 
    return 
PLUGIN_CONTINUE 


public 
Set_Hat(playerimodelnumtargeter) { 
    new 
name[32
    new 
tmpfile[101
    
format(tmpfile100"%s/%s"modelpathHATMDL[imodelnum]) 
    
get_user_name(playername31
    if (
imodelnum == 0) { 
        if(
g_HatEnt[player] > 0) { 
            
fm_set_entity_visibility(g_HatEnt[player], 0
        } 
        if (
targeter != 0) { 
            
client_print(targeterprint_chat"[%s] Removed hat from %s",PLUG_TAG,name
        } 
    } else if (
file_exists(tmpfile)) { 
        if(
g_HatEnt[player] < 1) { 
            
g_HatEnt[player] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target")) 
            if(
g_HatEnt[player] > 0) { 
                
set_pev(g_HatEnt[player], pev_movetypeMOVETYPE_FOLLOW
                
set_pev(g_HatEnt[player], pev_aimentplayer
                
set_pev(g_HatEnt[player], pev_rendermode,     kRenderNormal
                
engfunc(EngFunc_SetModelg_HatEnt[player], tmpfile
            } 
        } else { 
            
engfunc(EngFunc_SetModelg_HatEnt[player], tmpfile
        } 
        
glowhat(player
        
CurrentHat[player] = imodelnum 
        
if (targeter != 0) { 
            
client_print(targeterprint_chat"[%s] Set %s on %s",PLUG_TAG,HATNAME[imodelnum],name
        } 
    } 


public 
command_load() { 
    if(
file_exists(HatFile)) { 
        
HATMDL[0] = "" 
        
HATNAME[0] = "None" 
        
TotalHats 
        
new TempCrapA[2
        new 
sfLineData[128
        new 
file fopen(HatFile,"rt"
        while(
file && !feof(file)) { 
            
fgets(file,sfLineData,127
             
            
// Skip Comment ; // and Empty Lines  
            
if (sfLineData[0] == ';' || strlen(sfLineData) < || (sfLineData[0] == '/' && sfLineData[1] == '/')) continue 
             
            
// BREAK IT UP! 
            
parse(sfLineDataHATMDL[TotalHats], 25HATNAME[TotalHats], 25TempCrapA1
             
            if (
TempCrapA[0] == 'A' || TempCrapA[0] == '1') { 
                
HATREST[TotalHats] = HAT_ADMIN 
            
} else if (TempCrapA[0] == 'T' || TempCrapA[0] == '2') { 
                
HATREST[TotalHats] = HAT_TERROR 
            
} else if (TempCrapA[0] == 'C' || TempCrapA[0] == '3') { 
                
HATREST[TotalHats] = HAT_COUNTER 
            
} else { 
                
HATREST[TotalHats] = HAT_ALL 
            

            
TotalHats += 
            
if(TotalHats >= MAX_HATS) { 
                
server_print("[%s] Reached hat limit",PLUG_TAG
                break 
            } 
        } 
        if(
filefclose(file
    } 
    
MenuPages floatround((TotalHats 8.0), floatround_ceil
    
server_print("[%s] Loaded %i hats, and Generated %i pages",PLUG_TAG,TotalHats,MenuPages



menucolor(idItemIDMnuClr[3]) { 
    
//If its the hat they currently have on 
    
if (ItemID == CurrentHat[id]) { 
        
MnuClr "\d" 
        
return 
    } 
    if (
HATREST[ItemID] != HAT_ALL) { 
        
//If its an AdminHat&They are NOT an admin 
        
if (HATREST[ItemID] == HAT_ADMIN && get_pcvar_num(P_AdminHats) == 1) { 
            if (
get_user_flags(id) & PLUG_ADMINB) { 
                
MnuClr "\y" 
            
} else { 
                
MnuClr "\r" 
            

        
//If this is a hat set for there team or not 
        
} else if (HATREST[ItemID] != get_user_team(id) + 1) { 
            
MnuClr "\r" 
        
} else { 
            
MnuClr "\y" 
        

    } else { 
        
MnuClr "\w" 
    

    return 


glowhat(id) { 
    if (!
pev_valid(g_HatEnt[id])) return 
    if (
get_pcvar_num(P_Glow) != 0) {    //If Glowing Hats Are Enabled 
        
set_pev(g_HatEnt[id], pev_renderfx,    kRenderFxGlowShell
        if (
get_pcvar_num(P_Glow) == 2) {    //If Not Team Specific, Use Player Glow On Hat 
            
new Float:curcolors[3], Float:curamt 
            pev
(idpev_rendercolorcurcolors
            
pev(idpev_renderamtcuramt
            
set_pev(g_HatEnt[id], pev_rendercolorcurcolors
            
set_pev(g_HatEnt[id], pev_renderamtcuramt
        } else {                                
//If Team Specific, Red=T, Blue=CT 
            
if (get_user_team(id) == 1) { 
                
set_pev(g_HatEnt[id], pev_rendercolor, {200.00.00.0}) 
            } else if (
get_user_team(id) == 2) { 
                
set_pev(g_HatEnt[id], pev_rendercolor, {0.00.0200.0}) 
            } 
            
set_pev(g_HatEnt[id], pev_renderamt,    50.0
        } 
    } else { 
        
set_pev(g_HatEnt[id], pev_renderfx,    kRenderFxNone
        
set_pev(g_HatEnt[id], pev_renderamt,    0.0
    } 
    
fm_set_entity_visibility(g_HatEnt[id], 1
    return 


forcehat(idforceID) { 
    if (
forceID == 0forceID get_pcvar_num(P_ForceHat
    if (
forceID != 0) { 
        if (
forceID <= TotalHats 1) { 
            if (
forceID != CurrentHat[id]) Set_Hat(idforceID0
        } else { 
            
set_pcvar_num(P_ForceHat0
        } 
    } 


/*============================================================ 
                     Stocks! 
============================================================*/ 
stock ChatColor(const id, const input[], any:...) 

    new 
count 1players[32
    static 
msg[191
    
vformat(msg190input3
     
    
replace_all(msg190"!g""^4"// Green Color 
    
replace_all(msg190"!y""^1"// Default Color 
    
replace_all(msg190"!t""^3"// Team Color 

     
    
if (idplayers[0] = id; else get_players(playerscount"ch"
    { 
        for (new 
0counti++) 
        { 
            if (
is_user_connected(players[i])) 
            { 
            
message_begin(MSG_ONE_UNRELIABLEg_iMsgSayText_players[i])   
            
write_byte(players[i]); 
            
write_string(msg); 
            
message_end(); 
            } 
        } 
    } 

KleirPlays is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 08-03-2014 , 18:23   Re: Help, got a little compilation error.
Reply With Quote #4

Not that hard to change it yourself.
PHP Code:
#include <amxmodx>  
#include <amxmisc>  
#include <fakemeta>   

#define PLUG_NAME         "HATS"  
#define PLUG_AUTH         "SgtBane"  
#define PLUG_VERS         "1.8"  
#define PLUG_TAG         "Wicked"  
#define PLUG_ADMIN        ADMIN_RCON        //Access flags required to give/remove hats  
#define PLUG_ADMINB     ADMIN_CHAT        //Access flags required to set personal hat if admin only is enabled  

#define OFFSET_GLOWSET    100  

#define HAT_ALL            0  
#define HAT_ADMIN        1  
#define HAT_TERROR        2  
#define HAT_COUNTER        3  

#define menusize         220  
#define maxTry            15                //Number of tries to get someone a non-admin random hat before giving up.  
#define modelpath        "models/hat"  

stock fm_set_entity_visibility(indexvisible 1set_pev(indexpev_effectsvisible == pev(indexpev_effects) & ~EF_NODRAW pev(indexpev_effects) | EF_NODRAW)  

new 
g_HatEnt[33]  
new 
CurrentHat[33]  
new 
CurrentMenu[33]  

new 
HatFile[64]  
new 
MenuPagesTotalHats  

#define MAX_HATS 64  
new HATMDL[MAX_HATS][26]  
new 
HATNAME[MAX_HATS][26]  
new 
HATREST[MAX_HATS]  

new 
P_AdminOnly  
new P_AdminHats  
new P_RandomJoin  
new P_BotRandom  
new P_ForceHat  
new P_Glow  

new g_iMsgSayText 

public plugin_init() {  
    
register_plugin(PLUG_NAMEPLUG_VERSPLUG_AUTH)  
    
register_logevent("event_roundstart",     2,    "1=Round_Start")  
    
register_event("TeamInfo",                 "event_team_info",     "a" )  
      
    
register_concmd("amx_givehat",         "Give_Hat",     PLUG_ADMIN,     "<nick> <mdl #>")  
    
register_concmd("amx_removehats",     "Remove_Hat",     PLUG_ADMIN,     " - Removes hats from everyone.")  
      
    
register_menucmd(register_menuid("\yHat Menu: [Page"),    (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9),"MenuCommand")  
    
register_clcmd("say /hats",            "ShowMenu", -1,     "Shows Knife menu")  
      
    
P_AdminOnly        register_cvar("hat_adminonly",    "0")    //Only admins can use the menu  
    
P_AdminHats     register_cvar("hat_adminhats",    "1")    //Allow hats for admins only (if 0, hats specifically for admins can be used by anyone)  
    
P_RandomJoin    register_cvar("hat_random",        "1")    //Random hats for players as they join  
    
P_BotRandom        register_cvar("hat_bots",            "1")    //Random hats for bots as they join  
    
P_ForceHat        register_cvar("hat_force",        "0")    //Force a specific hat (if not 0)  
    
P_Glow            register_cvar("hat_glow",            "1")    //0=None,1=GlowWithPlayer,2=TeamColor  
     
    
g_iMsgSayText get_user_msgid("SayText"
}  

public 
ShowMenu(id) {  
    if ((
get_pcvar_num(P_AdminOnly) == && get_user_flags(id) & PLUG_ADMIN) || (get_pcvar_num(P_AdminOnly) == && get_pcvar_num(P_ForceHat) == 0)) {  
        
CurrentMenu[id] = 1  
        ShowHats
(id)  
    } else {  
        
ChatColor(id"!g%s !yOnly !tadmins!y may currently use this menu.",PLUG_TAG)  
    }  
    return 
PLUGIN_HANDLED  
}  

public 
ShowHats(id) {  
    new 
keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9)  
      
    new 
szMenuBody[menusize 1], WpnID  
    
new nLen format(szMenuBodymenusize"\yHat Menu: [Page %i/%i]^n",CurrentMenu[id],MenuPages)  
      
    new 
MnuClr[3]  
    
// Get Hat Names And Add Them To The List  
    
for (new hatid=0hatid 8hatid++) {  
        
WpnID = ((CurrentMenu[id] * 8) + hatid 8)  
        if (
WpnID TotalHats) {  
            
menucolor(idWpnIDMnuClr)  
            
nLen += format(szMenuBody[nLen], menusize-nLen"^n\w%i.%s %s"hatid 1MnuClrHATNAME[WpnID])  
        }  
    }  
      
    
// Next Page And Previous/Close  
    
if (CurrentMenu[id] == MenuPages) {  
        
nLen += format(szMenuBody[nLen], menusize-nLen"^n^n\d9. Next Page")  
    } else {  
        
nLen += format(szMenuBody[nLen], menusize-nLen"^n^n\w9. Next Page")  
    }  
      
    if (
CurrentMenu[id] > 1) {  
        
nLen += format(szMenuBody[nLen], menusize-nLen"^n\w0. Previous Page")  
    } else {  
        
nLen += format(szMenuBody[nLen], menusize-nLen"^n\w0. Close")  
    }  
    
show_menu(idkeysszMenuBody, -1)  
    return 
PLUGIN_HANDLED  
}  

public 
MenuCommand(idkey) {  
    switch(
key)  
    {  
        case 
8:        //9 - [Next Page]  
        
{  
            if (
CurrentMenu[id] < MenuPagesCurrentMenu[id]++  
            
ShowHats(id)  
            return 
PLUGIN_HANDLED  
        
}  
        case 
9:        //0 - [Close]  
        
{  
            
CurrentMenu[id]--  
            if (
CurrentMenu[id] > 0ShowHats(id)  
            return 
PLUGIN_HANDLED  
        
}  
        default:  
        {  
            new 
HatID = ((CurrentMenu[id] * 8) + key 8)  
            if (
HatID TotalHats) {  
                if ((
get_pcvar_num(P_AdminHats) == && HATREST[HatID] == HAT_ADMIN) || (get_pcvar_num(P_AdminHats) == && HATREST[HatID] == HAT_ADMIN && get_user_flags(id) & PLUG_ADMINB) || HATREST[HatID] == HAT_ALL || (HATREST[HatID] == get_user_team(id) + 1)) {  
                    
Set_Hat(id,HatID,id)  
                } else {  
                    if (
HATREST[HatID] == HAT_TERROR && get_user_team(id) == 2) {  
                        
client_print(id,print_chat,"[%s] This hat is currently set as a Terrorist Hat.",PLUG_TAG)  
                    } else if (
HATREST[HatID] == HAT_COUNTER && get_user_team(id) == 1) {  
                        
client_print(id,print_chat,"[%s] This hat is currently set as Counter Terrorist.",PLUG_TAG)  
                    } else {  
                        
client_print(id,print_chat,"[%s] This hat is currently set as Admin Only.",PLUG_TAG)  
                    }  
                }  
            }  
        }  
    }  
    return 
PLUGIN_HANDLED  
}  

public 
plugin_precache() {  
    new 
cfgDir[32]  
    
get_configsdir(cfgDir,31)  
    
formatex(HatFile,63,"%s/HatList.ini",cfgDir)  
    
command_load()  
    new 
tmpfile [101]  
    for (new 
1TotalHats; ++i) {  
        
format(tmpfile100"%s/%s"modelpathHATMDL[i])  
        if (
file_exists (tmpfile)) {  
            
precache_model(tmpfile)  
            
server_print("[%s] Precached %s"PLUG_TAGHATMDL[i])  
        } else {  
            
server_print("[%s] Failed to precache %s"PLUG_TAGtmpfile)  
        }  
    }  
}  

public 
client_putinserver(id) {  
    if (
get_pcvar_num(P_ForceHat) == 1) {  
        new 
forceID get_pcvar_num(P_ForceHat)  
        if (
forceID <= TotalHats 1) {  
            
forcehat(idforceID)  
        } else {  
            
set_pcvar_num(P_ForceHat0)  
        }  
    } else if (
get_pcvar_num(P_RandomJoin) == || (get_pcvar_num(P_BotRandom) == && is_user_bot(id))) {  
        if (
get_pcvar_num(P_ForceHat) == 0Random_Hat(id)  
    }  
    return 
PLUGIN_CONTINUE  
}  

public 
event_team_info() {  
    if (
get_pcvar_num(P_ForceHat) != 0) return  
    new 
id read_data(1)  
    if (
HATREST[CurrentHat[id]] == HAT_ALL) return  
    if (
HATREST[CurrentHat[id]] == HAT_ADMIN && get_user_flags(id) & PLUG_ADMINB) return  
      
    new 
team[3]  
    
read_data(2team2)  
    switch(
team[0]) {  
        case 
'C': {  
            if (
HATREST[CurrentHat[id]] != HAT_COUNTERRandom_Hat(id)  
        }  
        case 
'T': {  
            if (
HATREST[CurrentHat[id]] != HAT_TERRORRandom_Hat(id)  
        }  
        case 
'S': {  
            
Set_Hat(id00)  
        }  
    }  
    return  
}  
public 
event_roundstart() {  
    new 
forceID get_pcvar_num(P_ForceHat)  
    for (new 
0get_maxplayers(); ++i) {  
        if (
is_user_connected(i) && g_HatEnt[i] > 0) {  
            if (
forceID != 0) {  
                
forcehat(iforceID)  
            }  
            
glowhat(i)  
        }  
    }  
    return 
PLUGIN_CONTINUE  
}  

public 
Give_Hat(idreq_flag)  
{  
    if( !(
get_user_flags(id) & req_flag) )  
        return 
PLUGIN_HANDLED  
      
    
new smodelnum[5], name[32]  
    
read_argv(1,name,31)  
    
read_argv(2,smodelnum,4)  
      
    new 
player cmd_target(id,name,2)  
    if (!
player) {  
        
client_print(id,print_chat,"[%s] Player With That Name Does Not Exist.",PLUG_TAG)  
        return 
PLUGIN_HANDLED  
    
}  
      
    new 
imodelnum = (str_to_num(smodelnum))  
    if (
imodelnum MAX_HATS) return PLUGIN_HANDLED  
      
    Set_Hat
(player,imodelnum,id)  

    return 
PLUGIN_CONTINUE  
}  

public 
Remove_Hat(idreq_flag)  
{  
    if( !(
get_user_flags(id) & req_flag) )  
        return 
PLUGIN_HANDLED  

    
for (new 0get_maxplayers(); ++i) {  
        if (
is_user_connected(i) && g_HatEnt[i] > 0) {  
            
Set_Hat(id00)  
        }  
    }  
    
client_print(id,print_chat,"[%s] Removed hats from everyone.",PLUG_TAG)  
    return 
PLUGIN_CONTINUE  
}  

public 
Random_Hat(id) {  
    new 
bool:foundrnd falsecntTry 0randID random_num (1TotalHats 1)  
    while (
cntTry maxTry && foundrnd == false) {  
        
randID random_num (1TotalHats 1)  
        
cntTry += 1  
        
if (HATREST[randID] == HAT_ALLfoundrnd true  
        
if (HATREST[randID] == HAT_ADMIN && get_user_flags(id) & PLUG_ADMINBfoundrnd true  
        
if ((get_user_team(id) != 0) && HATREST[CurrentHat[id]] == get_user_team(id) + 1foundrnd true  
    
}  
    if (
foundrnd == true) {    //If a valid random hat is found, apply it.  
        
Set_Hat(idrandID 0)  
    } else {                
//Otherwise, don't use any hat.  
        
Set_Hat(id00)      
    }  
    return 
PLUGIN_CONTINUE  
}  

public 
Set_Hat(playerimodelnumtargeter) {  
    new 
name[32]  
    new 
tmpfile[101]  
    
format(tmpfile100"%s/%s"modelpathHATMDL[imodelnum])  
    
get_user_name(playername31)  
    if (
imodelnum == 0) {  
        if(
g_HatEnt[player] > 0) {  
            
fm_set_entity_visibility(g_HatEnt[player], 0)  
        }  
        if (
targeter != 0) {  
        
ChatColor(targeter"!g[%s]!n Removed hat from!t %s",PLUG_TAG,name)
        }  
    } else if (
file_exists(tmpfile)) {  
        if(
g_HatEnt[player] < 1) {  
            
g_HatEnt[player] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))  
            if(
g_HatEnt[player] > 0) {  
                
set_pev(g_HatEnt[player], pev_movetypeMOVETYPE_FOLLOW)  
                
set_pev(g_HatEnt[player], pev_aimentplayer)  
                
set_pev(g_HatEnt[player], pev_rendermode,     kRenderNormal)  
                
engfunc(EngFunc_SetModelg_HatEnt[player], tmpfile)  
            }  
        } else {  
            
engfunc(EngFunc_SetModelg_HatEnt[player], tmpfile)  
        }  
        
glowhat(player)  
        
CurrentHat[player] = imodelnum  
        
if (targeter != 0) {  
        
ChatColor(targeter"!g[%s]!n Set!g %s!n on!t %s",PLUG_TAG,HATNAME[imodelnum],name)
        }  
    }  
}  

public 
command_load() {  
    if(
file_exists(HatFile)) {  
        
HATMDL[0] = ""  
        
HATNAME[0] = "None"  
        
TotalHats 1  
        
new TempCrapA[2]  
        new 
sfLineData[128]  
        new 
file fopen(HatFile,"rt")  
        while(
file && !feof(file)) {  
            
fgets(file,sfLineData,127)  
              
            
// Skip Comment ; // and Empty Lines   
            
if (sfLineData[0] == ';' || strlen(sfLineData) < || (sfLineData[0] == '/' && sfLineData[1] == '/')) continue  
              
            
// BREAK IT UP!  
            
parse(sfLineDataHATMDL[TotalHats], 25HATNAME[TotalHats], 25TempCrapA1)  
              
            if (
TempCrapA[0] == 'A' || TempCrapA[0] == '1') {  
                
HATREST[TotalHats] = HAT_ADMIN  
            
} else if (TempCrapA[0] == 'T' || TempCrapA[0] == '2') {  
                
HATREST[TotalHats] = HAT_TERROR  
            
} else if (TempCrapA[0] == 'C' || TempCrapA[0] == '3') {  
                
HATREST[TotalHats] = HAT_COUNTER  
            
} else {  
                
HATREST[TotalHats] = HAT_ALL  
            
}  
            
TotalHats += 1  
            
if(TotalHats >= MAX_HATS) {  
                
server_print("[%s] Reached hat limit",PLUG_TAG)  
                break  
            }  
        }  
        if(
filefclose(file)  
    }  
    
MenuPages floatround((TotalHats 8.0), floatround_ceil)  
    
server_print("[%s] Loaded %i hats, and Generated %i pages",PLUG_TAG,TotalHats,MenuPages)  
}  


menucolor(idItemIDMnuClr[3]) {  
    
//If its the hat they currently have on  
    
if (ItemID == CurrentHat[id]) {  
        
MnuClr "\d"  
        
return  
    }  
    if (
HATREST[ItemID] != HAT_ALL) {  
        
//If its an AdminHat&They are NOT an admin  
        
if (HATREST[ItemID] == HAT_ADMIN && get_pcvar_num(P_AdminHats) == 1) {  
            if (
get_user_flags(id) & PLUG_ADMINB) {  
                
MnuClr "\y"  
            
} else {  
                
MnuClr "\r"  
            
}  
        
//If this is a hat set for there team or not  
        
} else if (HATREST[ItemID] != get_user_team(id) + 1) {  
            
MnuClr "\r"  
        
} else {  
            
MnuClr "\y"  
        
}  
    } else {  
        
MnuClr "\w"  
    
}  
    return  
}  

glowhat(id) {  
    if (!
pev_valid(g_HatEnt[id])) return  
    if (
get_pcvar_num(P_Glow) != 0) {    //If Glowing Hats Are Enabled  
        
set_pev(g_HatEnt[id], pev_renderfx,    kRenderFxGlowShell)  
        if (
get_pcvar_num(P_Glow) == 2) {    //If Not Team Specific, Use Player Glow On Hat  
            
new Float:curcolors[3], Float:curamt  
            pev
(idpev_rendercolorcurcolors)  
            
pev(idpev_renderamtcuramt)  
            
set_pev(g_HatEnt[id], pev_rendercolorcurcolors)  
            
set_pev(g_HatEnt[id], pev_renderamtcuramt)  
        } else {                                
//If Team Specific, Red=T, Blue=CT  
            
if (get_user_team(id) == 1) {  
                
set_pev(g_HatEnt[id], pev_rendercolor, {200.00.00.0})  
            } else if (
get_user_team(id) == 2) {  
                
set_pev(g_HatEnt[id], pev_rendercolor, {0.00.0200.0})  
            }  
            
set_pev(g_HatEnt[id], pev_renderamt,    50.0)  
        }  
    } else {  
        
set_pev(g_HatEnt[id], pev_renderfx,    kRenderFxNone)  
        
set_pev(g_HatEnt[id], pev_renderamt,    0.0)  
    }  
    
fm_set_entity_visibility(g_HatEnt[id], 1)  
    return  
}  

forcehat(idforceID) {  
    if (
forceID == 0forceID get_pcvar_num(P_ForceHat)  
    if (
forceID != 0) {  
        if (
forceID <= TotalHats 1) {  
            if (
forceID != CurrentHat[id]) Set_Hat(idforceID0)  
        } else {  
            
set_pcvar_num(P_ForceHat0)  
        }  
    }  
}  

/*============================================================  
                     Stocks!  
============================================================*/  
stock ChatColor(const id, const input[], any:...)  
{  
    new 
count 1players[32]  
    static 
msg[191]  
    
vformat(msg190input3)  
      
    
replace_all(msg190"!g""^4"// Green Color  
    
replace_all(msg190"!y""^1"// Default Color  
    
replace_all(msg190"!t""^3"// Team Color  

      
    
if (idplayers[0] = id; else get_players(playerscount"ch")  
    {  
        for (new 
0counti++)  
        {  
            if (
is_user_connected(players[i]))  
            {  
            
message_begin(MSG_ONE_UNRELIABLEg_iMsgSayText_players[i])    
            
write_byte(players[i]);  
            
write_string(msg);  
            
message_end();  
            }  
        }  
    }  

__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
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 11:19.


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