GHW Weapon Replacement

Сообщения
282
Реакции
34
Помог
3 раз(а)
Hello Everyone,

I use GHW Weapon Replacement because it has option to deliver to CT || T different type of the same weapon.
I've tried to change plugin code to make an option /skins so player can decide if he wants default skins (old) or new skins.
I broke my spine sitting on pc trying to configure it, but I always have the same problem:
Modified plugin works only on CT skins, and it gives to Terrorist skin of CT.

Here below is the code. If anyone can show me where is problem and know how to fix it, I would be glad to hear...
Thank you all !

Код:
/*
*   _______     _      _  __          __
*  | _____/    | |    | | \ \   __   / /
*  | |         | |    | |  | | /  \ | |
*  | |         | |____| |  | |/ __ \| |
*  | |   ___   | ______ |  |   /  \   |
*  | |  |_  |  | |    | |  |  /    \  |
*  | |    | |  | |    | |  | |      | |
*  | |____| |  | |    | |  | |      | |
*  |_______/   |_|    |_|  \_/      \_/
*
*
*
*  Last Edited: 06-12-08
*
*  ============
*   Changelog:
*  ============
*
*  v1.3
*    -Bug Fixes
*
*  v1.0
*    -Initial Release
*
*/

#define VERSION    "1.3"

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define MAX_SOUNDS    50
#define MAX_p_MODELS    50
#define MAX_v_MODELS    50
#define MAX_w_MODELS    50

#define MAP_CONFIGS    1

new new_sounds[MAX_SOUNDS][48]
new old_sounds[MAX_SOUNDS][48]
new sounds_team[MAX_SOUNDS]
new soundsnum

new new_p_models[MAX_p_MODELS][48]
new old_p_models[MAX_p_MODELS][48]
new p_models_team[MAX_p_MODELS]
new p_modelsnum

new new_v_models[MAX_v_MODELS][48]
new old_v_models[MAX_v_MODELS][48]
new v_models_team[MAX_p_MODELS]
new v_modelsnum

new new_w_models[MAX_w_MODELS][48]
new old_w_models[MAX_w_MODELS][48]
new w_models_team[MAX_p_MODELS]
new w_modelsnum

new maxplayers

public plugin_init()
{
    register_plugin("Weapon Model + Sound Replacement",VERSION,"GHW_Chronic")
    register_forward(FM_EmitSound,"Sound_Hook")
    register_forward(FM_SetModel,"W_Model_Hook",1)
    register_logevent("newround",2,"1=Round_Start")
    register_event("CurWeapon","Changeweapon_Hook","be","1=1")
    
    register_clcmd( "say /skins", "cmd_settings" )
    register_clcmd( "say_team /skins", "cmd_settings" )
    
    maxplayers = get_maxplayers()
}

public plugin_precache()
{
    new configfile[200]
    new configsdir[200]
    new map[32]
    get_configsdir(configsdir,199)
    get_mapname(map,31)
    format(configfile,199,"%s/new_weapons_%s.ini",configsdir,map)
    if(file_exists(configfile))
    {
        load_models(configfile)
    }
    else
    {
        format(configfile,199,"%s/new_weapons.ini",configsdir)
        load_models(configfile)
    }
}

public client_putinserver(id)
{
    new_v_models[id][v_modelsnum] = 1
    set_task(80.0,"notification",id,"",0,"b")
}

public cmd_settings(id)
{
        if(new_v_models[id][v_modelsnum] == 1)
        {
            new_v_models[id][v_modelsnum] = 0
            ChatColor(id,"You have deactivated the weapon skins!")
        }
        else
        {
            new_v_models[id][v_modelsnum] = 1
            ChatColor(id,"You have activated the weapon skins! ")
        }
} 

public settings_handler(id, menu, item)
{
    new data[6], iName[64]
    new access, callback

    menu_item_getinfo(menu, item, access, data,5, iName, 63, callback)
    
    new key = str_to_num(data)

    switch(key)
    {
        case 1:
        {
            if(new_v_models[id][v_modelsnum])
            {
                new_v_models[id][v_modelsnum] = 0
            }
            else
            {
                new_v_models[id][v_modelsnum] = 1
            }
            cmd_settings(id)
        }
        case 2:
        {
        }
    }
    menu_destroy(menu)
    return PLUGIN_HANDLED
}

public load_models(configfile[])
{
    if(file_exists(configfile))
    {
        new read[96], left[48], right[48], right2[32], trash, team
        for(new i=0;i<file_size(configfile,1);i++)
        {
            read_file(configfile,i,read,95,trash)
            if(containi(read,";")!=0 && containi(read," ")!=-1)
            {
                argbreak(read,left,47,right,47)
                team=0
                if(containi(right," ")!=-1)
                {
                    argbreak(right,right,47,right2,31)
                    replace_all(right2,31,"^"","")
                    if(
                    equali(right2,"T") ||
                    equali(right2,"Terrorist") ||
                    equali(right2,"Terrorists") ||
                    equali(right2,"Blue") ||
                    equali(right2,"B") ||
                    equali(right2,"Allies") ||
                    equali(right2,"1")
                    ) team=1
                    else if(
                    equali(right2,"CT") ||
                    equali(right2,"Counter") ||
                    equali(right2,"Counter-Terrorist") ||
                    equali(right2,"Counter-Terrorists") ||
                    equali(right2,"CounterTerrorists") ||
                    equali(right2,"CounterTerrorist") ||
                    equali(right2,"Red") ||
                    equali(right2,"R") ||
                    equali(right2,"Axis") ||
                    equali(right2,"2")
                    ) team=2
                    else if(
                    equali(right2,"Yellow") ||
                    equali(right2,"Y") ||
                    equali(right2,"3")
                    ) team=3
                    else if(
                    equali(right2,"Green") ||
                    equali(right2,"G") ||
                    equali(right2,"4")
                    ) team=4
                }
                replace_all(right,47,"^"","")
                if(file_exists(right))
                {
                    if(containi(right,".mdl")==strlen(right)-4)
                    {
                        if(!precache_model(right))
                        {
                            log_amx("Error attempting to precache model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
                        }
                        else if(containi(left,"models/p_")==0)
                        {
                            format(new_p_models[p_modelsnum],47,right)
                            format(old_p_models[p_modelsnum],47,left)
                            p_models_team[p_modelsnum]=team
                            p_modelsnum++
                        }
                        else if(containi(left,"models/v_")==0)
                        {
                            format(new_v_models[v_modelsnum],47,right)
                            format(old_v_models[v_modelsnum],47,left)
                            v_models_team[v_modelsnum]=team
                            v_modelsnum++
                        }
                        else if(containi(left,"models/w_")==0)
                        {
                            format(new_w_models[w_modelsnum],47,right)
                            format(old_w_models[w_modelsnum],47,left)
                            w_models_team[w_modelsnum]=team
                            w_modelsnum++
                        }
                        else
                        {
                            log_amx("Model type(p_ / v_ / w_) unknown for model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
                        }
                    }
                    else if(containi(right,".wav")==strlen(right)-4 || containi(right,".mp3")==strlen(right)-4)
                    {
                        replace(right,47,"sound/","")
                        replace(left,47,"sound/","")
                        if(!precache_sound(right))
                        {
                            log_amx("Error attempting to precache sound: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
                        }
                        else
                        {
                            format(new_sounds[soundsnum],47,right)
                            format(old_sounds[soundsnum],47,left)
                            sounds_team[soundsnum]=team
                            soundsnum++
                        }
                    }
                    else
                    {
                        log_amx("Invalid File: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
                    }
                }
                else
                {
                    log_amx("File Inexistent: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
                }
                /*if(!file_exists(left))
                {
                    log_amx("Warning: File Inexistent: ^"%s^" (Line %d of new_weapons.ini). ONLY A WARNING. PLUGIN WILL STILL WORK!!!!",left,i+1)
                }*/
            }
        }
    }
}

public Changeweapon_Hook(id)
{
    if(!is_user_alive(id))
    {
        return PLUGIN_CONTINUE
    }
    static model[32], i, team

    team = get_user_team(id)
    if(new_v_models[id][v_modelsnum])
    {
    pev(id,pev_viewmodel2,model,31)
    for(i=0;i<v_modelsnum;i++)
    {
        if(equali(model,old_v_models[i]))
        {
            if(v_models_team[i]==team || !v_models_team[i])
            {
                set_pev(id,pev_viewmodel2,new_v_models[i])
                break;
            }
        }
    }
    pev(id,pev_weaponmodel2,model,31)
    for(i=0;i<p_modelsnum;i++)
    {
        if(equali(model,old_p_models[i]))
        {
            if(p_models_team[i]==team || !p_models_team[i])
            {
                set_pev(id,pev_weaponmodel2,new_p_models[i])
                break;
            }
        }
    }
    }
    return PLUGIN_CONTINUE
}

public Sound_Hook(id,channel,sample[])
{
    if(!is_user_alive(id))
    {
        return FMRES_IGNORED
    }
    if(channel!=CHAN_WEAPON && channel!=CHAN_ITEM)
    {
        return FMRES_IGNORED
    }

    static i, team

    team = get_user_team(id)

    for(i=0;i<soundsnum;i++)
    {
        if(equali(sample,old_sounds[i]))
        {
            if(sounds_team[i]==team || !sounds_team[i])
            {
                engfunc(EngFunc_EmitSound,id,CHAN_WEAPON,new_sounds[i],1.0,ATTN_NORM,0,PITCH_NORM)
                return FMRES_SUPERCEDE
            }
        }
    }
    return FMRES_IGNORED
}

public W_Model_Hook(ent,model[])
{
    if(!pev_valid(ent))
    {
        return FMRES_IGNORED
    }
    static i
    for(i=0;i<w_modelsnum;i++)
    {
        if(equali(model,old_w_models[i]))
        {
            engfunc(EngFunc_SetModel,ent,new_w_models[i])
            return FMRES_SUPERCEDE
        }
    }
    return FMRES_IGNORED
}

public newround()
{
    static ent, classname[8], model[32]
    ent = engfunc(EngFunc_FindEntityInSphere,maxplayers,Float:{0.0,0.0,0.0},4800.0)
    while(ent)
    {
        if(pev_valid(ent))
        {
            pev(ent,pev_classname,classname,7)
            if(containi(classname,"armoury")!=-1)
            {
                pev(ent,pev_model,model,31)
                W_Model_Hook(ent,model)
            }
        }
        ent = engfunc(EngFunc_FindEntityInSphere,ent,Float:{0.0,0.0,0.0},4800.0)
    }
}

public notification(id)
{
    ChatColor(id, "!gMessage !y: Special skins - !g/skins")
}
stock ChatColor(const id, const input[], any:...)
{
    new count = 1, players[32]
    static msg[191]
    vformat(msg, 190, input, 3)
    
    replace_all(msg, 190, "!g", "^4") // Green Color
    replace_all(msg, 190, "!y", "^1") // Default Color
    replace_all(msg, 190, "!team", "^3") // Team Color
    replace_all(msg, 190, "!team2", "^0") // Team2 Color
    
    if (id) players[0] = id; else get_players(players, count, "ch")
    {
        for (new i = 0; i < count; i++)
        {
            if (is_user_connected(players[i]))
            {
                message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
                write_byte(players[i]);
                write_string(msg);
                message_end();
            }
        }
    }
}
 
Сообщения
282
Реакции
34
Помог
3 раз(а)
Official version from website works (with strbreak instead argbreak). When I've changed to argbreak it stopped working.
Are there some differences because in amxmodx I see all the same?
 
Сообщения
892
Реакции
149
Помог
25 раз(а)
Try to change your public.
Код:
public Changeweapon_Hook(id)
{
    if(!is_user_alive(id) || !new_v_models[id][v_modelsnum])
    {
        return PLUGIN_CONTINUE
    }
    static model[32], i, team

    team = get_user_team(id)
    pev(id,pev_viewmodel2,model,31)
    for(i=0;i<v_modelsnum;i++)
    {
        if(equali(model,old_v_models[i]))
        {
            if(v_models_team[i]==team || !v_models_team[i])
            {
                set_pev(id,pev_viewmodel2,new_v_models[i])
                break;
            }
        }
    }
    pev(id,pev_weaponmodel2,model,31)
    for(i=0;i<p_modelsnum;i++)
    {
        if(equali(model,old_p_models[i]))
        {
            if(p_models_team[i]==team || !p_models_team[i])
            {
                set_pev(id,pev_weaponmodel2,new_p_models[i])
                break;
            }
        }
    }
    return PLUGIN_CONTINUE
}
 
Сообщения
282
Реакции
34
Помог
3 раз(а)
Try to change your public.
Код:
public Changeweapon_Hook(id)
{
    if(!is_user_alive(id) || !new_v_models[id][v_modelsnum])
    {
        return PLUGIN_CONTINUE
    }
    static model[32], i, team

    team = get_user_team(id)
    pev(id,pev_viewmodel2,model,31)
    for(i=0;i<v_modelsnum;i++)
    {
        if(equali(model,old_v_models[i]))
        {
            if(v_models_team[i]==team || !v_models_team[i])
            {
                set_pev(id,pev_viewmodel2,new_v_models[i])
                break;
            }
        }
    }
    pev(id,pev_weaponmodel2,model,31)
    for(i=0;i<p_modelsnum;i++)
    {
        if(equali(model,old_p_models[i]))
        {
            if(p_models_team[i]==team || !p_models_team[i])
            {
                set_pev(id,pev_weaponmodel2,new_p_models[i])
                break;
            }
        }
    }
    return PLUGIN_CONTINUE
}
It does not work. I still think problem is in strbreak/argbreak.
Concerning option say: /skins :
It worked when I was alone on server, but when I put bots or real players (+10) it crashed.
It crashed in a moment when I tried to turn on models after i turned them off.
 
Сообщения
282
Реакции
34
Помог
3 раз(а)
[QUOTE = "Benzogang_BabyTape, post: 115750, member: 7895"]
My advice to you is to use analogs, this plugin is very old. [DOUBLEPOST = 1637695024] [/ DOUBLEPOST] U can use this plugin - Models Replacement
[/ QUOTE]
I totally agree with you!
Oh ... I really like this plugin which you shared but it does not have option to separate CT from T skins ... :(
 
Сообщения
282
Реакции
34
Помог
3 раз(а)
[QUOTE = "Benzogang_BabyTape, post: 115753, member: 7895"]
I can make a check for the player's team.
[/QUOTE]
I you could, could you add both / skins option and part for declaring CT / T?

I think that could be good update for this plugin aswell. Probably most of the people will use it ...
 
Сообщения
282
Реакции
34
Помог
3 раз(а)
Could you, please, share the code inside of that plugin's comment section, so everyone could reach it easier or contact plugin maker with code to update the plugin?

thank you !
 
Сообщения
366
Реакции
5
Предупреждения
5
Помог
1 раз(а)
Мне нужно изменить модель только для администратора
 
Сообщения
43
Реакции
4
Предупреждения
16
Se_IaQe,
добавьте этот код в функцию Changeweapon_hook

замените
if(!is_user_alive(id) || !new_v_models[id][v_modelsnum])
{
return PLUGIN_CONTINUE
}
на
new sAccessFlag[2],iAccessFlag;
if(!is_user_alive(id) || !new_v_models[id][v_modelsnum])
{
return PLUGIN_CONTINUE
}
copy(sAccessFlag, 32, "a")
iAccessFlag = read_flags(sAccessFlag);
if (!((get_user_flags(id)& iAccessFlag) && id))
}
return PLUGIN_CONTINUE
}

где "a" это флаг admin_immunity (замените на свой)

;ADMIN_IMMUNITY 1 (1<<0) //Flag "a", immunity
;ADMIN_RESERVATION 2 (1<<1) //Flag "b", reservation
;ADMIN_KICK 4 (1<<2) //Flag "c", kick
;ADMIN_BAN 8 (1<<3) //Flag "d", ban
;ADMIN_SLAY 16 (1<<4) //Flag "e", slay
;ADMIN_MAP 32 (1<<5) //Flag "f", map change
;ADMIN_CVAR 64 (1<<6) //Flag "g", cvar change
;ADMIN_CFG 128 (1<<7) //Flag "h", config execution
;ADMIN_CHAT 256 (1<<8) //Flag "i", chat
;ADMIN_VOTE 512 (1<<9) //Flag "j", vote
;ADMIN_PASSWORD 1024 (1<<10) //Flag "k", sv_password
;ADMIN_RCON 2048 (1<<11) //Flag "l", rcon access
;ADMIN_LEVEL_A 4096 (1<<12) //Flag "m", custom
;ADMIN_LEVEL_B 8192 (1<<13) //Flag "n", custom
;ADMIN_LEVEL_C 16384 (1<<14) //Flag "o", custom
;ADMIN_LEVEL_D 32768 (1<<15) //Flag "p", custom
;ADMIN_LEVEL_E 65536 (1<<16) //Flag "q", custom
;ADMIN_LEVEL_F 131072 (1<<17) //Flag "r", custom
;ADMIN_LEVEL_G 262144 (1<<18) //Flag "s", custom
;ADMIN_LEVEL_H 524288 (1<<19) //Flag "t", custom
;ADMIN_MENU 1048576 (1<<20) //Flag "u", menus
 
Сообщения
366
Реакции
5
Предупреждения
5
Помог
1 раз(а)
public Changeweapon_Hook(id)

{

new sAccessFlag[2],iAccessFlag;
if(!is_user_alive(id) || !new_v_models[id][v_modelsnum])
{
return PLUGIN_CONTINUE
}
copy(sAccessFlag, 32, "a")
iAccessFlag = read_flags(sAccessFlag);
if (!((get_user_flags(id)& iAccessFlag) && id))

}
выдает ошибку
 
Сообщения
43
Реакции
4
Предупреждения
16
Se_IaQe,
new sAccessFlag[2],iAccessFlag;
copy(sAccessFlag, 32, "a")
iAccessFlag = read_flags(sAccessFlag);
if (!((get_user_flags(id)& iAccessFlag) && id))
{
return PLUGIN_CONTINUE
}

была ошибка в фигурной скобке } стояла а нужна {
 
Сообщения
366
Реакции
5
Предупреждения
5
Помог
1 раз(а)
Se_IaQe,
new sAccessFlag[2],iAccessFlag;
copy(sAccessFlag, 32, "a")
iAccessFlag = read_flags(sAccessFlag);
if (!((get_user_flags(id)& iAccessFlag) && id))
{
return PLUGIN_CONTINUE
}

была ошибка в фигурной скобке } стояла а нужна {
public Changeweapon_Hook(id)
{
if(!is_user_alive(id) || (!(get_user_flags(id) & ADMIN_RESERVATION)))
{
return PLUGIN_CONTINUE
}
static model[32], i, team

team = get_user_team(id)

pev(id,pev_viewmodel2,model,31)
for(i=0;i<v_modelsnum;i++)
{
if(equali(model,old_v_models))
{
if(v_models_team==team || !v_models_team)
{
set_pev(id,pev_viewmodel2,new_v_models)
break;
}
}
}
work
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу