Available Weapon models

Unpaid Requests, Public Plugins
User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#11

Post by Night Fury » 5 years ago

sPe3doN wrote: 5 years ago all players get weapon skins :/
  1. #define VERSION "1.3"
  2.  
  3. #include <zombie_escape>
  4. #include <ze_vip>
  5.  
  6. #define MAX_SOUNDS  50
  7. #define MAX_p_MODELS    50
  8. #define MAX_v_MODELS    50
  9. #define MAX_w_MODELS    50
  10.  
  11. #define MAP_CONFIGS 1
  12.  
  13. new new_sounds[MAX_SOUNDS][48]
  14. new old_sounds[MAX_SOUNDS][48]
  15. new sounds_team[MAX_SOUNDS]
  16. new soundsnum
  17.  
  18. new new_p_models[MAX_p_MODELS][48]
  19. new old_p_models[MAX_p_MODELS][48]
  20. new p_models_team[MAX_p_MODELS]
  21. new p_modelsnum
  22.  
  23. new new_v_models[MAX_v_MODELS][48]
  24. new old_v_models[MAX_v_MODELS][48]
  25. new v_models_team[MAX_p_MODELS]
  26. new v_modelsnum
  27.  
  28. new new_w_models[MAX_w_MODELS][48]
  29. new old_w_models[MAX_w_MODELS][48]
  30. new w_models_team[MAX_p_MODELS]
  31. new w_modelsnum
  32.  
  33. new maxplayers
  34.  
  35. public plugin_init()
  36. {
  37.     register_plugin("Weapon Model + Sound Replacement",VERSION,"GHW_Chronic")
  38.     register_forward(FM_EmitSound,"Sound_Hook")
  39.     register_forward(FM_SetModel,"W_Model_Hook",1)
  40.     register_event("CurWeapon","Changeweapon_Hook","be","1=1")
  41.     maxplayers = get_maxplayers()
  42. }
  43.  
  44. public plugin_precache()
  45. {
  46.     new configfile[200]
  47.     new configsdir[200]
  48.     new map[32]
  49.     get_configsdir(configsdir,199)
  50.     get_mapname(map,31)
  51.     format(configfile,199,"%s/new_weapons_%s.ini",configsdir,map)
  52.     if(file_exists(configfile))
  53.     {
  54.         load_models(configfile)
  55.     }
  56.     else
  57.     {
  58.         format(configfile,199,"%s/new_weapons.ini",configsdir)
  59.         load_models(configfile)
  60.     }
  61. }
  62.  
  63. public load_models(configfile[])
  64. {
  65.     if(file_exists(configfile))
  66.     {
  67.         new read[96], left[48], right[48], right2[32], trash, team
  68.         for(new i=0;i<file_size(configfile,1);i++)
  69.         {
  70.             read_file(configfile,i,read,95,trash)
  71.             if(containi(read,";")!=0 && containi(read," ")!=-1)
  72.             {
  73.                 argbreak(read,left,47,right,47)
  74.                 team=0
  75.                 if(containi(right," ")!=-1)
  76.                 {
  77.                     argbreak(right,right,47,right2,31)
  78.                     replace_all(right2,31,"^"","")
  79.                     if(
  80.                     equali(right2,"T") ||
  81.                     equali(right2,"Terrorist") ||
  82.                     equali(right2,"Terrorists") ||
  83.                     equali(right2,"Blue") ||
  84.                     equali(right2,"B") ||
  85.                     equali(right2,"Allies") ||
  86.                     equali(right2,"1")
  87.                     ) team=1
  88.                     else if(
  89.                     equali(right2,"CT") ||
  90.                     equali(right2,"Counter") ||
  91.                     equali(right2,"Counter-Terrorist") ||
  92.                     equali(right2,"Counter-Terrorists") ||
  93.                     equali(right2,"CounterTerrorists") ||
  94.                     equali(right2,"CounterTerrorist") ||
  95.                     equali(right2,"Red") ||
  96.                     equali(right2,"R") ||
  97.                     equali(right2,"Axis") ||
  98.                     equali(right2,"2")
  99.                     ) team=2
  100.                     else if(
  101.                     equali(right2,"Yellow") ||
  102.                     equali(right2,"Y") ||
  103.                     equali(right2,"3")
  104.                     ) team=3
  105.                     else if(
  106.                     equali(right2,"Green") ||
  107.                     equali(right2,"G") ||
  108.                     equali(right2,"4")
  109.                     ) team=4
  110.                 }
  111.                 replace_all(right,47,"^"","")
  112.                 if(file_exists(right))
  113.                 {
  114.                     if(containi(right,".mdl")==strlen(right)-4)
  115.                     {
  116.                         if(!precache_model(right))
  117.                         {
  118.                             log_amx("Error attempting to precache model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  119.                         }
  120.                         else if(containi(left,"models/p_")==0)
  121.                         {
  122.                             format(new_p_models[p_modelsnum],47,right)
  123.                             format(old_p_models[p_modelsnum],47,left)
  124.                             p_models_team[p_modelsnum]=team
  125.                             p_modelsnum++
  126.                         }
  127.                         else if(containi(left,"models/v_")==0)
  128.                         {
  129.                             format(new_v_models[v_modelsnum],47,right)
  130.                             format(old_v_models[v_modelsnum],47,left)
  131.                             v_models_team[v_modelsnum]=team
  132.                             v_modelsnum++
  133.                         }
  134.                         else if(containi(left,"models/w_")==0)
  135.                         {
  136.                             format(new_w_models[w_modelsnum],47,right)
  137.                             format(old_w_models[w_modelsnum],47,left)
  138.                             w_models_team[w_modelsnum]=team
  139.                             w_modelsnum++
  140.                         }
  141.                         else
  142.                         {
  143.                             log_amx("Model type(p_ / v_ / w_) unknown for model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  144.                         }
  145.                     }
  146.                     else if(containi(right,".wav")==strlen(right)-4 || containi(right,".mp3")==strlen(right)-4)
  147.                     {
  148.                         replace(right,47,"sound/","")
  149.                         replace(left,47,"sound/","")
  150.                         if(!precache_sound(right))
  151.                         {
  152.                             log_amx("Error attempting to precache sound: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  153.                         }
  154.                         else
  155.                         {
  156.                             format(new_sounds[soundsnum],47,right)
  157.                             format(old_sounds[soundsnum],47,left)
  158.                             sounds_team[soundsnum]=team
  159.                             soundsnum++
  160.                         }
  161.                     }
  162.                     else
  163.                     {
  164.                         log_amx("Invalid File: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  165.                     }
  166.                 }
  167.                 else
  168.                 {
  169.                     log_amx("File Inexistent: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  170.                 }
  171.                 /*if(!file_exists(left))
  172.                 {
  173.                     log_amx("Warning: File Inexistent: ^"%s^" (Line %d of new_weapons.ini). ONLY A WARNING. PLUGIN WILL STILL WORK!!!!",left,i+1)
  174.                 }*/
  175.             }
  176.         }
  177.     }
  178. }
  179.  
  180. public Changeweapon_Hook(id)
  181. {
  182.     if(!is_user_alive(id) || !ze_is_user_vip(id))
  183.     {
  184.         return PLUGIN_CONTINUE
  185.     }
  186.     static model[32], i, team
  187.  
  188.     team = get_user_team(id)
  189.  
  190.     pev(id,pev_viewmodel2,model,31)
  191.     for(i=0;i<v_modelsnum;i++)
  192.     {
  193.         if(equali(model,old_v_models[i]))
  194.         {
  195.             if(v_models_team[i]==team || !v_models_team[i])
  196.             {
  197.                 set_pev(id,pev_viewmodel2,new_v_models[i])
  198.                 break;
  199.             }
  200.         }
  201.     }
  202.  
  203.     pev(id,pev_weaponmodel2,model,31)
  204.     for(i=0;i<p_modelsnum;i++)
  205.     {
  206.         if(equali(model,old_p_models[i]))
  207.         {
  208.             if(p_models_team[i]==team || !p_models_team[i])
  209.             {
  210.                 set_pev(id,pev_weaponmodel2,new_p_models[i])
  211.                 break;
  212.             }
  213.         }
  214.     }
  215.     return PLUGIN_CONTINUE
  216. }
  217.  
  218. public Sound_Hook(id,channel,sample[])
  219. {
  220.     if(!is_user_alive(id) || !ze_is_user_vip(id))
  221.     {
  222.         return FMRES_IGNORED
  223.     }
  224.     if(channel!=CHAN_WEAPON && channel!=CHAN_ITEM)
  225.     {
  226.         return FMRES_IGNORED
  227.     }
  228.  
  229.     static i, team
  230.  
  231.     team = get_user_team(id)
  232.  
  233.     for(i=0;i<soundsnum;i++)
  234.     {
  235.         if(equali(sample,old_sounds[i]))
  236.         {
  237.             if(sounds_team[i]==team || !sounds_team[i])
  238.             {
  239.                 engfunc(EngFunc_EmitSound,id,CHAN_WEAPON,new_sounds[i],1.0,ATTN_NORM,0,PITCH_NORM)
  240.                 return FMRES_SUPERCEDE
  241.             }
  242.         }
  243.     }
  244.     return FMRES_IGNORED
  245. }
  246.  
  247. public W_Model_Hook(ent,model[])
  248. {
  249.     new iOwner = get_entvar(ent, var_owner);
  250.    
  251.     if(!pev_valid(ent) || !ze_is_user_vip(id))
  252.     {
  253.         return FMRES_IGNORED
  254.     }
  255.     static i
  256.     for(i=0;i<w_modelsnum;i++)
  257.     {
  258.         if(equali(model,old_w_models[i]))
  259.         {
  260.             engfunc(EngFunc_SetModel,ent,new_w_models[i])
  261.             return FMRES_SUPERCEDE
  262.         }
  263.     }
  264.     return FMRES_IGNORED
  265. }
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 258
Joined: 7 years ago
Contact:

#12

Post by sPe3doN » 5 years ago

Jack GamePlay wrote: 5 years ago
sPe3doN wrote: 5 years ago all players get weapon skins :/
  1. #define VERSION "1.3"
  2.  
  3. #include <zombie_escape>
  4. #include <ze_vip>
  5.  
  6. #define MAX_SOUNDS  50
  7. #define MAX_p_MODELS    50
  8. #define MAX_v_MODELS    50
  9. #define MAX_w_MODELS    50
  10.  
  11. #define MAP_CONFIGS 1
  12.  
  13. new new_sounds[MAX_SOUNDS][48]
  14. new old_sounds[MAX_SOUNDS][48]
  15. new sounds_team[MAX_SOUNDS]
  16. new soundsnum
  17.  
  18. new new_p_models[MAX_p_MODELS][48]
  19. new old_p_models[MAX_p_MODELS][48]
  20. new p_models_team[MAX_p_MODELS]
  21. new p_modelsnum
  22.  
  23. new new_v_models[MAX_v_MODELS][48]
  24. new old_v_models[MAX_v_MODELS][48]
  25. new v_models_team[MAX_p_MODELS]
  26. new v_modelsnum
  27.  
  28. new new_w_models[MAX_w_MODELS][48]
  29. new old_w_models[MAX_w_MODELS][48]
  30. new w_models_team[MAX_p_MODELS]
  31. new w_modelsnum
  32.  
  33. new maxplayers
  34.  
  35. public plugin_init()
  36. {
  37.     register_plugin("Weapon Model + Sound Replacement",VERSION,"GHW_Chronic")
  38.     register_forward(FM_EmitSound,"Sound_Hook")
  39.     register_forward(FM_SetModel,"W_Model_Hook",1)
  40.     register_event("CurWeapon","Changeweapon_Hook","be","1=1")
  41.     maxplayers = get_maxplayers()
  42. }
  43.  
  44. public plugin_precache()
  45. {
  46.     new configfile[200]
  47.     new configsdir[200]
  48.     new map[32]
  49.     get_configsdir(configsdir,199)
  50.     get_mapname(map,31)
  51.     format(configfile,199,"%s/new_weapons_%s.ini",configsdir,map)
  52.     if(file_exists(configfile))
  53.     {
  54.         load_models(configfile)
  55.     }
  56.     else
  57.     {
  58.         format(configfile,199,"%s/new_weapons.ini",configsdir)
  59.         load_models(configfile)
  60.     }
  61. }
  62.  
  63. public load_models(configfile[])
  64. {
  65.     if(file_exists(configfile))
  66.     {
  67.         new read[96], left[48], right[48], right2[32], trash, team
  68.         for(new i=0;i<file_size(configfile,1);i++)
  69.         {
  70.             read_file(configfile,i,read,95,trash)
  71.             if(containi(read,";")!=0 && containi(read," ")!=-1)
  72.             {
  73.                 argbreak(read,left,47,right,47)
  74.                 team=0
  75.                 if(containi(right," ")!=-1)
  76.                 {
  77.                     argbreak(right,right,47,right2,31)
  78.                     replace_all(right2,31,"^"","")
  79.                     if(
  80.                     equali(right2,"T") ||
  81.                     equali(right2,"Terrorist") ||
  82.                     equali(right2,"Terrorists") ||
  83.                     equali(right2,"Blue") ||
  84.                     equali(right2,"B") ||
  85.                     equali(right2,"Allies") ||
  86.                     equali(right2,"1")
  87.                     ) team=1
  88.                     else if(
  89.                     equali(right2,"CT") ||
  90.                     equali(right2,"Counter") ||
  91.                     equali(right2,"Counter-Terrorist") ||
  92.                     equali(right2,"Counter-Terrorists") ||
  93.                     equali(right2,"CounterTerrorists") ||
  94.                     equali(right2,"CounterTerrorist") ||
  95.                     equali(right2,"Red") ||
  96.                     equali(right2,"R") ||
  97.                     equali(right2,"Axis") ||
  98.                     equali(right2,"2")
  99.                     ) team=2
  100.                     else if(
  101.                     equali(right2,"Yellow") ||
  102.                     equali(right2,"Y") ||
  103.                     equali(right2,"3")
  104.                     ) team=3
  105.                     else if(
  106.                     equali(right2,"Green") ||
  107.                     equali(right2,"G") ||
  108.                     equali(right2,"4")
  109.                     ) team=4
  110.                 }
  111.                 replace_all(right,47,"^"","")
  112.                 if(file_exists(right))
  113.                 {
  114.                     if(containi(right,".mdl")==strlen(right)-4)
  115.                     {
  116.                         if(!precache_model(right))
  117.                         {
  118.                             log_amx("Error attempting to precache model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  119.                         }
  120.                         else if(containi(left,"models/p_")==0)
  121.                         {
  122.                             format(new_p_models[p_modelsnum],47,right)
  123.                             format(old_p_models[p_modelsnum],47,left)
  124.                             p_models_team[p_modelsnum]=team
  125.                             p_modelsnum++
  126.                         }
  127.                         else if(containi(left,"models/v_")==0)
  128.                         {
  129.                             format(new_v_models[v_modelsnum],47,right)
  130.                             format(old_v_models[v_modelsnum],47,left)
  131.                             v_models_team[v_modelsnum]=team
  132.                             v_modelsnum++
  133.                         }
  134.                         else if(containi(left,"models/w_")==0)
  135.                         {
  136.                             format(new_w_models[w_modelsnum],47,right)
  137.                             format(old_w_models[w_modelsnum],47,left)
  138.                             w_models_team[w_modelsnum]=team
  139.                             w_modelsnum++
  140.                         }
  141.                         else
  142.                         {
  143.                             log_amx("Model type(p_ / v_ / w_) unknown for model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  144.                         }
  145.                     }
  146.                     else if(containi(right,".wav")==strlen(right)-4 || containi(right,".mp3")==strlen(right)-4)
  147.                     {
  148.                         replace(right,47,"sound/","")
  149.                         replace(left,47,"sound/","")
  150.                         if(!precache_sound(right))
  151.                         {
  152.                             log_amx("Error attempting to precache sound: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  153.                         }
  154.                         else
  155.                         {
  156.                             format(new_sounds[soundsnum],47,right)
  157.                             format(old_sounds[soundsnum],47,left)
  158.                             sounds_team[soundsnum]=team
  159.                             soundsnum++
  160.                         }
  161.                     }
  162.                     else
  163.                     {
  164.                         log_amx("Invalid File: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  165.                     }
  166.                 }
  167.                 else
  168.                 {
  169.                     log_amx("File Inexistent: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  170.                 }
  171.                 /*if(!file_exists(left))
  172.                 {
  173.                     log_amx("Warning: File Inexistent: ^"%s^" (Line %d of new_weapons.ini). ONLY A WARNING. PLUGIN WILL STILL WORK!!!!",left,i+1)
  174.                 }*/
  175.             }
  176.         }
  177.     }
  178. }
  179.  
  180. public Changeweapon_Hook(id)
  181. {
  182.     if(!is_user_alive(id) || !ze_is_user_vip(id))
  183.     {
  184.         return PLUGIN_CONTINUE
  185.     }
  186.     static model[32], i, team
  187.  
  188.     team = get_user_team(id)
  189.  
  190.     pev(id,pev_viewmodel2,model,31)
  191.     for(i=0;i<v_modelsnum;i++)
  192.     {
  193.         if(equali(model,old_v_models[i]))
  194.         {
  195.             if(v_models_team[i]==team || !v_models_team[i])
  196.             {
  197.                 set_pev(id,pev_viewmodel2,new_v_models[i])
  198.                 break;
  199.             }
  200.         }
  201.     }
  202.  
  203.     pev(id,pev_weaponmodel2,model,31)
  204.     for(i=0;i<p_modelsnum;i++)
  205.     {
  206.         if(equali(model,old_p_models[i]))
  207.         {
  208.             if(p_models_team[i]==team || !p_models_team[i])
  209.             {
  210.                 set_pev(id,pev_weaponmodel2,new_p_models[i])
  211.                 break;
  212.             }
  213.         }
  214.     }
  215.     return PLUGIN_CONTINUE
  216. }
  217.  
  218. public Sound_Hook(id,channel,sample[])
  219. {
  220.     if(!is_user_alive(id) || !ze_is_user_vip(id))
  221.     {
  222.         return FMRES_IGNORED
  223.     }
  224.     if(channel!=CHAN_WEAPON && channel!=CHAN_ITEM)
  225.     {
  226.         return FMRES_IGNORED
  227.     }
  228.  
  229.     static i, team
  230.  
  231.     team = get_user_team(id)
  232.  
  233.     for(i=0;i<soundsnum;i++)
  234.     {
  235.         if(equali(sample,old_sounds[i]))
  236.         {
  237.             if(sounds_team[i]==team || !sounds_team[i])
  238.             {
  239.                 engfunc(EngFunc_EmitSound,id,CHAN_WEAPON,new_sounds[i],1.0,ATTN_NORM,0,PITCH_NORM)
  240.                 return FMRES_SUPERCEDE
  241.             }
  242.         }
  243.     }
  244.     return FMRES_IGNORED
  245. }
  246.  
  247. public W_Model_Hook(ent,model[])
  248. {
  249.     new iOwner = get_entvar(ent, var_owner);
  250.    
  251.     if(!pev_valid(ent) || !ze_is_user_vip(id))
  252.     {
  253.         return FMRES_IGNORED
  254.     }
  255.     static i
  256.     for(i=0;i<w_modelsnum;i++)
  257.     {
  258.         if(equali(model,old_w_models[i]))
  259.         {
  260.             engfunc(EngFunc_SetModel,ent,new_w_models[i])
  261.             return FMRES_SUPERCEDE
  262.         }
  263.     }
  264.     return FMRES_IGNORED
  265. }
Image errors and jack if you will fix it can you change it to ADMIN_LEVEL_H cuz i dont use vip system on my srw
Image

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 258
Joined: 7 years ago
Contact:

#13

Post by sPe3doN » 5 years ago

Jack can you fix it

Code: Select all

#include <zombie_escape>

#define VERSION "1.3"

#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
 
 
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_event("CurWeapon","Changeweapon_Hook","be","1=1")
}
 
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 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) && !(get_user_flags(id) & ADMIN_LEVEL_H))
    {
        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
}
 
public Sound_Hook(id,channel,sample[])
{
    if(!is_user_alive(id) && !(get_user_flags(id) & ADMIN_LEVEL_H))
    {
        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(id,model[])
{
    if(!pev_valid(id) && !(get_user_flags(id) & ADMIN_LEVEL_H))
    {
        return FMRES_IGNORED
    }
    static i
    for(i=0;i<w_modelsnum;i++)
    {
        if(equali(model,old_w_models[i]))
        {
            engfunc(EngFunc_SetModel,id,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)
    }
}*/
Image

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 258
Joined: 7 years ago
Contact:

#14

Post by sPe3doN » 5 years ago

up
Image

User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#15

Post by Night Fury » 5 years ago

sPe3doN wrote: 5 years ago Jack can you fix it
  1. #include <zombie_escape>
  2.  
  3. #define VERSION "1.3"
  4.  
  5. #define MAX_SOUNDS  50
  6. #define MAX_p_MODELS    50
  7. #define MAX_v_MODELS    50
  8. #define MAX_w_MODELS    50
  9.  
  10. #define MAP_CONFIGS 1
  11.  
  12. new new_sounds[MAX_SOUNDS][48]
  13. new old_sounds[MAX_SOUNDS][48]
  14. new sounds_team[MAX_SOUNDS]
  15. new soundsnum
  16.  
  17. new new_p_models[MAX_p_MODELS][48]
  18. new old_p_models[MAX_p_MODELS][48]
  19. new p_models_team[MAX_p_MODELS]
  20. new p_modelsnum
  21.  
  22. new new_v_models[MAX_v_MODELS][48]
  23. new old_v_models[MAX_v_MODELS][48]
  24. new v_models_team[MAX_p_MODELS]
  25. new v_modelsnum
  26.  
  27. new new_w_models[MAX_w_MODELS][48]
  28. new old_w_models[MAX_w_MODELS][48]
  29. new w_models_team[MAX_p_MODELS]
  30. new w_modelsnum
  31.  
  32.  
  33. public plugin_init()
  34. {
  35.     register_plugin("Weapon Model + Sound Replacement",VERSION,"GHW_Chronic")
  36.     register_forward(FM_EmitSound,"Sound_Hook")
  37.     register_forward(FM_SetModel,"W_Model_Hook",1)
  38.     register_event("CurWeapon","Changeweapon_Hook","be","1=1")
  39. }
  40.  
  41. public plugin_precache()
  42. {
  43.     new configfile[200]
  44.     new configsdir[200]
  45.     new map[32]
  46.     get_configsdir(configsdir,199)
  47.     get_mapname(map,31)
  48.     format(configfile,199,"%s/new_weapons_%s.ini",configsdir,map)
  49.     if(file_exists(configfile))
  50.     {
  51.         load_models(configfile)
  52.     }
  53.     else
  54.     {
  55.         format(configfile,199,"%s/new_weapons.ini",configsdir)
  56.         load_models(configfile)
  57.     }
  58. }
  59.  
  60. public load_models(configfile[])
  61. {
  62.     if(file_exists(configfile))
  63.     {
  64.         new read[96], left[48], right[48], right2[32], trash, team
  65.         for(new i=0;i<file_size(configfile,1);i++)
  66.         {
  67.             read_file(configfile,i,read,95,trash)
  68.             if(containi(read,";")!=0 && containi(read," ")!=-1)
  69.             {
  70.                 argbreak(read,left,47,right,47)
  71.                 team=0
  72.                 if(containi(right," ")!=-1)
  73.                 {
  74.                     argbreak(right,right,47,right2,31)
  75.                     replace_all(right2,31,"^"","")
  76.                     if(
  77.                     equali(right2,"T") ||
  78.                     equali(right2,"Terrorist") ||
  79.                     equali(right2,"Terrorists") ||
  80.                     equali(right2,"Blue") ||
  81.                     equali(right2,"B") ||
  82.                     equali(right2,"Allies") ||
  83.                     equali(right2,"1")
  84.                     ) team=1
  85.                     else if(
  86.                     equali(right2,"CT") ||
  87.                     equali(right2,"Counter") ||
  88.                     equali(right2,"Counter-Terrorist") ||
  89.                     equali(right2,"Counter-Terrorists") ||
  90.                     equali(right2,"CounterTerrorists") ||
  91.                     equali(right2,"CounterTerrorist") ||
  92.                     equali(right2,"Red") ||
  93.                     equali(right2,"R") ||
  94.                     equali(right2,"Axis") ||
  95.                     equali(right2,"2")
  96.                     ) team=2
  97.                     else if(
  98.                     equali(right2,"Yellow") ||
  99.                     equali(right2,"Y") ||
  100.                     equali(right2,"3")
  101.                     ) team=3
  102.                     else if(
  103.                     equali(right2,"Green") ||
  104.                     equali(right2,"G") ||
  105.                     equali(right2,"4")
  106.                     ) team=4
  107.                 }
  108.                 replace_all(right,47,"^"","")
  109.                 if(file_exists(right))
  110.                 {
  111.                     if(containi(right,".mdl")==strlen(right)-4)
  112.                     {
  113.                         if(!precache_model(right))
  114.                         {
  115.                             log_amx("Error attempting to precache model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  116.                         }
  117.                         else if(containi(left,"models/p_")==0)
  118.                         {
  119.                             format(new_p_models[p_modelsnum],47,right)
  120.                             format(old_p_models[p_modelsnum],47,left)
  121.                             p_models_team[p_modelsnum]=team
  122.                             p_modelsnum++
  123.                         }
  124.                         else if(containi(left,"models/v_")==0)
  125.                         {
  126.                             format(new_v_models[v_modelsnum],47,right)
  127.                             format(old_v_models[v_modelsnum],47,left)
  128.                             v_models_team[v_modelsnum]=team
  129.                             v_modelsnum++
  130.                         }
  131.                         else if(containi(left,"models/w_")==0)
  132.                         {
  133.                             format(new_w_models[w_modelsnum],47,right)
  134.                             format(old_w_models[w_modelsnum],47,left)
  135.                             w_models_team[w_modelsnum]=team
  136.                             w_modelsnum++
  137.                         }
  138.                         else
  139.                         {
  140.                             log_amx("Model type(p_ / v_ / w_) unknown for model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  141.                         }
  142.                     }
  143.                     else if(containi(right,".wav")==strlen(right)-4 || containi(right,".mp3")==strlen(right)-4)
  144.                     {
  145.                         replace(right,47,"sound/","")
  146.                         replace(left,47,"sound/","")
  147.                         if(!precache_sound(right))
  148.                         {
  149.                             log_amx("Error attempting to precache sound: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  150.                         }
  151.                         else
  152.                         {
  153.                             format(new_sounds[soundsnum],47,right)
  154.                             format(old_sounds[soundsnum],47,left)
  155.                             sounds_team[soundsnum]=team
  156.                             soundsnum++
  157.                         }
  158.                     }
  159.                     else
  160.                     {
  161.                         log_amx("Invalid File: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  162.                     }
  163.                 }
  164.                 else
  165.                 {
  166.                     log_amx("File Inexistent: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  167.                 }
  168.                 /*if(!file_exists(left))
  169.                 {
  170.                     log_amx("Warning: File Inexistent: ^"%s^" (Line %d of new_weapons.ini). ONLY A WARNING. PLUGIN WILL STILL WORK!!!!",left,i+1)
  171.                 }*/
  172.             }
  173.         }
  174.     }
  175. }
  176.  
  177. public Changeweapon_Hook(id)
  178. {
  179.     if(!is_user_alive(id) || !(get_user_flags(id) & ADMIN_LEVEL_H))
  180.     {
  181.         return PLUGIN_CONTINUE
  182.     }
  183.     static model[32], i, team
  184.  
  185.     team = get_user_team(id)
  186.  
  187.     pev(id,pev_viewmodel2,model,31)
  188.     for(i=0;i<v_modelsnum;i++)
  189.     {
  190.         if(equali(model,old_v_models[i]))
  191.         {
  192.             if(v_models_team[i]==team || !v_models_team[i])
  193.             {
  194.                 set_pev(id,pev_viewmodel2,new_v_models[i])
  195.                 break;
  196.             }
  197.         }
  198.     }
  199.  
  200.     pev(id,pev_weaponmodel2,model,31)
  201.     for(i=0;i<p_modelsnum;i++)
  202.     {
  203.         if(equali(model,old_p_models[i]))
  204.         {
  205.             if(p_models_team[i]==team || !p_models_team[i])
  206.             {
  207.                 set_pev(id,pev_weaponmodel2,new_p_models[i])
  208.                 break;
  209.             }
  210.         }
  211.     }
  212.     return PLUGIN_CONTINUE
  213. }
  214.  
  215. public Sound_Hook(id,channel,sample[])
  216. {
  217.     if(!is_user_alive(id) || !(get_user_flags(id) & ADMIN_LEVEL_H))
  218.     {
  219.         return FMRES_IGNORED
  220.     }
  221.     if(channel!=CHAN_WEAPON && channel!=CHAN_ITEM)
  222.     {
  223.         return FMRES_IGNORED
  224.     }
  225.  
  226.     static i, team
  227.  
  228.     team = get_user_team(id)
  229.  
  230.     for(i=0;i<soundsnum;i++)
  231.     {
  232.         if(equali(sample,old_sounds[i]))
  233.         {
  234.             if(sounds_team[i]==team || !sounds_team[i])
  235.             {
  236.                 engfunc(EngFunc_EmitSound,id,CHAN_WEAPON,new_sounds[i],1.0,ATTN_NORM,0,PITCH_NORM)
  237.                 return FMRES_SUPERCEDE
  238.             }
  239.         }
  240.     }
  241.     return FMRES_IGNORED
  242. }
  243.  
  244. public W_Model_Hook(id,model[])
  245. {
  246.     if(!pev_valid(id) || !(get_user_flags(id) & ADMIN_LEVEL_H))
  247.     {
  248.         return FMRES_IGNORED
  249.     }
  250.     static i
  251.     for(i=0;i<w_modelsnum;i++)
  252.     {
  253.         if(equali(model,old_w_models[i]))
  254.         {
  255.             engfunc(EngFunc_SetModel,id,new_w_models[i])
  256.             return FMRES_SUPERCEDE
  257.         }
  258.     }
  259.     return FMRES_IGNORED
  260. }
  261.  
  262. /*public newround()
  263. {
  264.     static ent, classname[8], model[32]
  265.     ent = engfunc(EngFunc_FindEntityInSphere,maxplayers,Float:{0.0,0.0,0.0},4800.0)
  266.     while(ent)
  267.     {
  268.         if(pev_valid(ent))
  269.         {
  270.             pev(ent,pev_classname,classname,7)
  271.             if(containi(classname,"armoury")!=-1)
  272.             {
  273.                 pev(ent,pev_model,model,31)
  274.                 W_Model_Hook(ent,model)
  275.             }
  276.         }
  277.         ent = engfunc(EngFunc_FindEntityInSphere,ent,Float:{0.0,0.0,0.0},4800.0)
  278.     }
  279. }*/
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 258
Joined: 7 years ago
Contact:

#16

Post by sPe3doN » 5 years ago

Jack GamePlay wrote: 5 years ago
sPe3doN wrote: 5 years ago Jack can you fix it
  1. #include <zombie_escape>
  2.  
  3. #define VERSION "1.3"
  4.  
  5. #define MAX_SOUNDS  50
  6. #define MAX_p_MODELS    50
  7. #define MAX_v_MODELS    50
  8. #define MAX_w_MODELS    50
  9.  
  10. #define MAP_CONFIGS 1
  11.  
  12. new new_sounds[MAX_SOUNDS][48]
  13. new old_sounds[MAX_SOUNDS][48]
  14. new sounds_team[MAX_SOUNDS]
  15. new soundsnum
  16.  
  17. new new_p_models[MAX_p_MODELS][48]
  18. new old_p_models[MAX_p_MODELS][48]
  19. new p_models_team[MAX_p_MODELS]
  20. new p_modelsnum
  21.  
  22. new new_v_models[MAX_v_MODELS][48]
  23. new old_v_models[MAX_v_MODELS][48]
  24. new v_models_team[MAX_p_MODELS]
  25. new v_modelsnum
  26.  
  27. new new_w_models[MAX_w_MODELS][48]
  28. new old_w_models[MAX_w_MODELS][48]
  29. new w_models_team[MAX_p_MODELS]
  30. new w_modelsnum
  31.  
  32.  
  33. public plugin_init()
  34. {
  35.     register_plugin("Weapon Model + Sound Replacement",VERSION,"GHW_Chronic")
  36.     register_forward(FM_EmitSound,"Sound_Hook")
  37.     register_forward(FM_SetModel,"W_Model_Hook",1)
  38.     register_event("CurWeapon","Changeweapon_Hook","be","1=1")
  39. }
  40.  
  41. public plugin_precache()
  42. {
  43.     new configfile[200]
  44.     new configsdir[200]
  45.     new map[32]
  46.     get_configsdir(configsdir,199)
  47.     get_mapname(map,31)
  48.     format(configfile,199,"%s/new_weapons_%s.ini",configsdir,map)
  49.     if(file_exists(configfile))
  50.     {
  51.         load_models(configfile)
  52.     }
  53.     else
  54.     {
  55.         format(configfile,199,"%s/new_weapons.ini",configsdir)
  56.         load_models(configfile)
  57.     }
  58. }
  59.  
  60. public load_models(configfile[])
  61. {
  62.     if(file_exists(configfile))
  63.     {
  64.         new read[96], left[48], right[48], right2[32], trash, team
  65.         for(new i=0;i<file_size(configfile,1);i++)
  66.         {
  67.             read_file(configfile,i,read,95,trash)
  68.             if(containi(read,";")!=0 && containi(read," ")!=-1)
  69.             {
  70.                 argbreak(read,left,47,right,47)
  71.                 team=0
  72.                 if(containi(right," ")!=-1)
  73.                 {
  74.                     argbreak(right,right,47,right2,31)
  75.                     replace_all(right2,31,"^"","")
  76.                     if(
  77.                     equali(right2,"T") ||
  78.                     equali(right2,"Terrorist") ||
  79.                     equali(right2,"Terrorists") ||
  80.                     equali(right2,"Blue") ||
  81.                     equali(right2,"B") ||
  82.                     equali(right2,"Allies") ||
  83.                     equali(right2,"1")
  84.                     ) team=1
  85.                     else if(
  86.                     equali(right2,"CT") ||
  87.                     equali(right2,"Counter") ||
  88.                     equali(right2,"Counter-Terrorist") ||
  89.                     equali(right2,"Counter-Terrorists") ||
  90.                     equali(right2,"CounterTerrorists") ||
  91.                     equali(right2,"CounterTerrorist") ||
  92.                     equali(right2,"Red") ||
  93.                     equali(right2,"R") ||
  94.                     equali(right2,"Axis") ||
  95.                     equali(right2,"2")
  96.                     ) team=2
  97.                     else if(
  98.                     equali(right2,"Yellow") ||
  99.                     equali(right2,"Y") ||
  100.                     equali(right2,"3")
  101.                     ) team=3
  102.                     else if(
  103.                     equali(right2,"Green") ||
  104.                     equali(right2,"G") ||
  105.                     equali(right2,"4")
  106.                     ) team=4
  107.                 }
  108.                 replace_all(right,47,"^"","")
  109.                 if(file_exists(right))
  110.                 {
  111.                     if(containi(right,".mdl")==strlen(right)-4)
  112.                     {
  113.                         if(!precache_model(right))
  114.                         {
  115.                             log_amx("Error attempting to precache model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  116.                         }
  117.                         else if(containi(left,"models/p_")==0)
  118.                         {
  119.                             format(new_p_models[p_modelsnum],47,right)
  120.                             format(old_p_models[p_modelsnum],47,left)
  121.                             p_models_team[p_modelsnum]=team
  122.                             p_modelsnum++
  123.                         }
  124.                         else if(containi(left,"models/v_")==0)
  125.                         {
  126.                             format(new_v_models[v_modelsnum],47,right)
  127.                             format(old_v_models[v_modelsnum],47,left)
  128.                             v_models_team[v_modelsnum]=team
  129.                             v_modelsnum++
  130.                         }
  131.                         else if(containi(left,"models/w_")==0)
  132.                         {
  133.                             format(new_w_models[w_modelsnum],47,right)
  134.                             format(old_w_models[w_modelsnum],47,left)
  135.                             w_models_team[w_modelsnum]=team
  136.                             w_modelsnum++
  137.                         }
  138.                         else
  139.                         {
  140.                             log_amx("Model type(p_ / v_ / w_) unknown for model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  141.                         }
  142.                     }
  143.                     else if(containi(right,".wav")==strlen(right)-4 || containi(right,".mp3")==strlen(right)-4)
  144.                     {
  145.                         replace(right,47,"sound/","")
  146.                         replace(left,47,"sound/","")
  147.                         if(!precache_sound(right))
  148.                         {
  149.                             log_amx("Error attempting to precache sound: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  150.                         }
  151.                         else
  152.                         {
  153.                             format(new_sounds[soundsnum],47,right)
  154.                             format(old_sounds[soundsnum],47,left)
  155.                             sounds_team[soundsnum]=team
  156.                             soundsnum++
  157.                         }
  158.                     }
  159.                     else
  160.                     {
  161.                         log_amx("Invalid File: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  162.                     }
  163.                 }
  164.                 else
  165.                 {
  166.                     log_amx("File Inexistent: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  167.                 }
  168.                 /*if(!file_exists(left))
  169.                 {
  170.                     log_amx("Warning: File Inexistent: ^"%s^" (Line %d of new_weapons.ini). ONLY A WARNING. PLUGIN WILL STILL WORK!!!!",left,i+1)
  171.                 }*/
  172.             }
  173.         }
  174.     }
  175. }
  176.  
  177. public Changeweapon_Hook(id)
  178. {
  179.     if(!is_user_alive(id) || !(get_user_flags(id) & ADMIN_LEVEL_H))
  180.     {
  181.         return PLUGIN_CONTINUE
  182.     }
  183.     static model[32], i, team
  184.  
  185.     team = get_user_team(id)
  186.  
  187.     pev(id,pev_viewmodel2,model,31)
  188.     for(i=0;i<v_modelsnum;i++)
  189.     {
  190.         if(equali(model,old_v_models[i]))
  191.         {
  192.             if(v_models_team[i]==team || !v_models_team[i])
  193.             {
  194.                 set_pev(id,pev_viewmodel2,new_v_models[i])
  195.                 break;
  196.             }
  197.         }
  198.     }
  199.  
  200.     pev(id,pev_weaponmodel2,model,31)
  201.     for(i=0;i<p_modelsnum;i++)
  202.     {
  203.         if(equali(model,old_p_models[i]))
  204.         {
  205.             if(p_models_team[i]==team || !p_models_team[i])
  206.             {
  207.                 set_pev(id,pev_weaponmodel2,new_p_models[i])
  208.                 break;
  209.             }
  210.         }
  211.     }
  212.     return PLUGIN_CONTINUE
  213. }
  214.  
  215. public Sound_Hook(id,channel,sample[])
  216. {
  217.     if(!is_user_alive(id) || !(get_user_flags(id) & ADMIN_LEVEL_H))
  218.     {
  219.         return FMRES_IGNORED
  220.     }
  221.     if(channel!=CHAN_WEAPON && channel!=CHAN_ITEM)
  222.     {
  223.         return FMRES_IGNORED
  224.     }
  225.  
  226.     static i, team
  227.  
  228.     team = get_user_team(id)
  229.  
  230.     for(i=0;i<soundsnum;i++)
  231.     {
  232.         if(equali(sample,old_sounds[i]))
  233.         {
  234.             if(sounds_team[i]==team || !sounds_team[i])
  235.             {
  236.                 engfunc(EngFunc_EmitSound,id,CHAN_WEAPON,new_sounds[i],1.0,ATTN_NORM,0,PITCH_NORM)
  237.                 return FMRES_SUPERCEDE
  238.             }
  239.         }
  240.     }
  241.     return FMRES_IGNORED
  242. }
  243.  
  244. public W_Model_Hook(id,model[])
  245. {
  246.     if(!pev_valid(id) || !(get_user_flags(id) & ADMIN_LEVEL_H))
  247.     {
  248.         return FMRES_IGNORED
  249.     }
  250.     static i
  251.     for(i=0;i<w_modelsnum;i++)
  252.     {
  253.         if(equali(model,old_w_models[i]))
  254.         {
  255.             engfunc(EngFunc_SetModel,id,new_w_models[i])
  256.             return FMRES_SUPERCEDE
  257.         }
  258.     }
  259.     return FMRES_IGNORED
  260. }
  261.  
  262. /*public newround()
  263. {
  264.     static ent, classname[8], model[32]
  265.     ent = engfunc(EngFunc_FindEntityInSphere,maxplayers,Float:{0.0,0.0,0.0},4800.0)
  266.     while(ent)
  267.     {
  268.         if(pev_valid(ent))
  269.         {
  270.             pev(ent,pev_classname,classname,7)
  271.             if(containi(classname,"armoury")!=-1)
  272.             {
  273.                 pev(ent,pev_model,model,31)
  274.                 W_Model_Hook(ent,model)
  275.             }
  276.         }
  277.         ent = engfunc(EngFunc_FindEntityInSphere,ent,Float:{0.0,0.0,0.0},4800.0)
  278.     }
  279. }*/
thx jack <3
Image

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 258
Joined: 7 years ago
Contact:

#17

Post by sPe3doN » 5 years ago

Code: Select all

L 09/15/2018 - 01:15:48: Invalid player id 105
L 09/15/2018 - 01:15:48: [AMXX] Displaying debug trace (plugin "vip_weapon.amxx", version "1.3")
L 09/15/2018 - 01:15:48: [AMXX] Run time error 10: native error (native "get_user_flags")
L 09/15/2018 - 01:15:48: [AMXX]    [0] vip_weapon.sma::W_Model_Hook (line 246)
Image

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#18

Post by Raheem » 5 years ago

This:
    1. public W_Model_Hook(id,model[])
    2. {
    3.     if(!pev_valid(id) || !(get_user_flags(id) & ADMIN_LEVEL_H))
    4.     {
    5.         return FMRES_IGNORED
    6.     }
    7.     static i
    8.     for(i=0;i<w_modelsnum;i++)
    9.     {
    10.         if(equali(model,old_w_models[i]))
    11.         {
    12.             engfunc(EngFunc_SetModel,id,new_w_models[i])
    13.             return FMRES_SUPERCEDE
    14.         }
    15.     }
    16.     return FMRES_IGNORED
    17. }
Maybe should:
    1. public W_Model_Hook(iEnt,model[])
    2. {
    3.     static id = get_member(iEnt, m_pPlayer)
    4.    
    5.     if(!pev_valid(iEnt) || !(get_user_flags(id) & ADMIN_LEVEL_H))
    6.     {
    7.         return FMRES_IGNORED
    8.     }
    9.    
    10.     static i
    11.     for(i=0;i<w_modelsnum;i++)
    12.     {
    13.         if(equali(model,old_w_models[i]))
    14.         {
    15.             engfunc(EngFunc_SetModel,id,new_w_models[i])
    16.             return FMRES_SUPERCEDE
    17.         }
    18.     }
    19.     return FMRES_IGNORED
    20. }
But anyway it's useless this check:
    1.     static id = get_member(iEnt, m_pPlayer)
    2.    
    3.     if(!pev_valid(iEnt) || !(get_user_flags(id) & ADMIN_LEVEL_H))
    4.     {
    5.         return FMRES_IGNORED
    6.     }
He who fails to plan is planning to fail

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 258
Joined: 7 years ago
Contact:

#19

Post by sPe3doN » 5 years ago

Raheem wrote: 5 years ago This:
    1. public W_Model_Hook(id,model[])
    2. {
    3.     if(!pev_valid(id) || !(get_user_flags(id) & ADMIN_LEVEL_H))
    4.     {
    5.         return FMRES_IGNORED
    6.     }
    7.     static i
    8.     for(i=0;i<w_modelsnum;i++)
    9.     {
    10.         if(equali(model,old_w_models[i]))
    11.         {
    12.             engfunc(EngFunc_SetModel,id,new_w_models[i])
    13.             return FMRES_SUPERCEDE
    14.         }
    15.     }
    16.     return FMRES_IGNORED
    17. }
Maybe should:
    1. public W_Model_Hook(iEnt,model[])
    2. {
    3.     static id = get_member(iEnt, m_pPlayer)
    4.    
    5.     if(!pev_valid(iEnt) || !(get_user_flags(id) & ADMIN_LEVEL_H))
    6.     {
    7.         return FMRES_IGNORED
    8.     }
    9.    
    10.     static i
    11.     for(i=0;i<w_modelsnum;i++)
    12.     {
    13.         if(equali(model,old_w_models[i]))
    14.         {
    15.             engfunc(EngFunc_SetModel,id,new_w_models[i])
    16.             return FMRES_SUPERCEDE
    17.         }
    18.     }
    19.     return FMRES_IGNORED
    20. }
But anyway it's useless this check:
    1.     static id = get_member(iEnt, m_pPlayer)
    2.    
    3.     if(!pev_valid(iEnt) || !(get_user_flags(id) & ADMIN_LEVEL_H))
    4.     {
    5.         return FMRES_IGNORED
    6.     }
Image
Image

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#20

Post by Mark » 5 years ago

sPe3doN wrote: 5 years ago
Raheem wrote: 5 years ago This:
    1. public W_Model_Hook(id,model[])
    2. {
    3.     if(!pev_valid(id) || !(get_user_flags(id) & ADMIN_LEVEL_H))
    4.     {
    5.         return FMRES_IGNORED
    6.     }
    7.     static i
    8.     for(i=0;i<w_modelsnum;i++)
    9.     {
    10.         if(equali(model,old_w_models[i]))
    11.         {
    12.             engfunc(EngFunc_SetModel,id,new_w_models[i])
    13.             return FMRES_SUPERCEDE
    14.         }
    15.     }
    16.     return FMRES_IGNORED
    17. }
Maybe should:
    1. public W_Model_Hook(iEnt,model[])
    2. {
    3.     static id = get_member(iEnt, m_pPlayer)
    4.    
    5.     if(!pev_valid(iEnt) || !(get_user_flags(id) & ADMIN_LEVEL_H))
    6.     {
    7.         return FMRES_IGNORED
    8.     }
    9.    
    10.     static i
    11.     for(i=0;i<w_modelsnum;i++)
    12.     {
    13.         if(equali(model,old_w_models[i]))
    14.         {
    15.             engfunc(EngFunc_SetModel,id,new_w_models[i])
    16.             return FMRES_SUPERCEDE
    17.         }
    18.     }
    19.     return FMRES_IGNORED
    20. }
But anyway it's useless this check:
    1.     static id = get_member(iEnt, m_pPlayer)
    2.    
    3.     if(!pev_valid(iEnt) || !(get_user_flags(id) & ADMIN_LEVEL_H))
    4.     {
    5.         return FMRES_IGNORED
    6.     }
Image
Post the full code after your edits.

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#21

Post by Mark » 5 years ago

Try this!
  1. #include <zombie_escape>
  2.  
  3. #define VERSION "1.3"
  4.  
  5. #define MAX_SOUNDS  50
  6. #define MAX_p_MODELS    50
  7. #define MAX_v_MODELS    50
  8. #define MAX_w_MODELS    50
  9.  
  10. #define MAP_CONFIGS 1
  11.  
  12. new new_sounds[MAX_SOUNDS][48]
  13. new old_sounds[MAX_SOUNDS][48]
  14. new sounds_team[MAX_SOUNDS]
  15. new soundsnum
  16.  
  17. new new_p_models[MAX_p_MODELS][48]
  18. new old_p_models[MAX_p_MODELS][48]
  19. new p_models_team[MAX_p_MODELS]
  20. new p_modelsnum
  21.  
  22. new new_v_models[MAX_v_MODELS][48]
  23. new old_v_models[MAX_v_MODELS][48]
  24. new v_models_team[MAX_p_MODELS]
  25. new v_modelsnum
  26.  
  27. new new_w_models[MAX_w_MODELS][48]
  28. new old_w_models[MAX_w_MODELS][48]
  29. new w_models_team[MAX_p_MODELS]
  30. new w_modelsnum
  31.  
  32.  
  33. public plugin_init()
  34. {
  35.     register_plugin("Weapon Model + Sound Replacement",VERSION,"GHW_Chronic")
  36.     register_forward(FM_EmitSound,"Sound_Hook")
  37.     register_forward(FM_SetModel,"W_Model_Hook",1)
  38.     register_event("CurWeapon","Changeweapon_Hook","be","1=1")
  39. }
  40.  
  41. public plugin_precache()
  42. {
  43.     new configfile[200]
  44.     new configsdir[200]
  45.     new map[32]
  46.     get_configsdir(configsdir,199)
  47.     get_mapname(map,31)
  48.     format(configfile,199,"%s/new_weapons_%s.ini",configsdir,map)
  49.     if(file_exists(configfile))
  50.     {
  51.         load_models(configfile)
  52.     }
  53.     else
  54.     {
  55.         format(configfile,199,"%s/new_weapons.ini",configsdir)
  56.         load_models(configfile)
  57.     }
  58. }
  59.  
  60. public load_models(configfile[])
  61. {
  62.     if(file_exists(configfile))
  63.     {
  64.         new read[96], left[48], right[48], right2[32], trash, team
  65.         for(new i=0;i<file_size(configfile,1);i++)
  66.         {
  67.             read_file(configfile,i,read,95,trash)
  68.             if(containi(read,";")!=0 && containi(read," ")!=-1)
  69.             {
  70.                 argbreak(read,left,47,right,47)
  71.                 team=0
  72.                 if(containi(right," ")!=-1)
  73.                 {
  74.                     argbreak(right,right,47,right2,31)
  75.                     replace_all(right2,31,"^"","")
  76.                     if(
  77.                     equali(right2,"T") ||
  78.                     equali(right2,"Terrorist") ||
  79.                     equali(right2,"Terrorists") ||
  80.                     equali(right2,"Blue") ||
  81.                     equali(right2,"B") ||
  82.                     equali(right2,"Allies") ||
  83.                     equali(right2,"1")
  84.                     ) team=1
  85.                     else if(
  86.                     equali(right2,"CT") ||
  87.                     equali(right2,"Counter") ||
  88.                     equali(right2,"Counter-Terrorist") ||
  89.                     equali(right2,"Counter-Terrorists") ||
  90.                     equali(right2,"CounterTerrorists") ||
  91.                     equali(right2,"CounterTerrorist") ||
  92.                     equali(right2,"Red") ||
  93.                     equali(right2,"R") ||
  94.                     equali(right2,"Axis") ||
  95.                     equali(right2,"2")
  96.                     ) team=2
  97.                     else if(
  98.                     equali(right2,"Yellow") ||
  99.                     equali(right2,"Y") ||
  100.                     equali(right2,"3")
  101.                     ) team=3
  102.                     else if(
  103.                     equali(right2,"Green") ||
  104.                     equali(right2,"G") ||
  105.                     equali(right2,"4")
  106.                     ) team=4
  107.                 }
  108.                 replace_all(right,47,"^"","")
  109.                 if(file_exists(right))
  110.                 {
  111.                     if(containi(right,".mdl")==strlen(right)-4)
  112.                     {
  113.                         if(!precache_model(right))
  114.                         {
  115.                             log_amx("Error attempting to precache model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  116.                         }
  117.                         else if(containi(left,"models/p_")==0)
  118.                         {
  119.                             format(new_p_models[p_modelsnum],47,right)
  120.                             format(old_p_models[p_modelsnum],47,left)
  121.                             p_models_team[p_modelsnum]=team
  122.                             p_modelsnum++
  123.                         }
  124.                         else if(containi(left,"models/v_")==0)
  125.                         {
  126.                             format(new_v_models[v_modelsnum],47,right)
  127.                             format(old_v_models[v_modelsnum],47,left)
  128.                             v_models_team[v_modelsnum]=team
  129.                             v_modelsnum++
  130.                         }
  131.                         else if(containi(left,"models/w_")==0)
  132.                         {
  133.                             format(new_w_models[w_modelsnum],47,right)
  134.                             format(old_w_models[w_modelsnum],47,left)
  135.                             w_models_team[w_modelsnum]=team
  136.                             w_modelsnum++
  137.                         }
  138.                         else
  139.                         {
  140.                             log_amx("Model type(p_ / v_ / w_) unknown for model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  141.                         }
  142.                     }
  143.                     else if(containi(right,".wav")==strlen(right)-4 || containi(right,".mp3")==strlen(right)-4)
  144.                     {
  145.                         replace(right,47,"sound/","")
  146.                         replace(left,47,"sound/","")
  147.                         if(!precache_sound(right))
  148.                         {
  149.                             log_amx("Error attempting to precache sound: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  150.                         }
  151.                         else
  152.                         {
  153.                             format(new_sounds[soundsnum],47,right)
  154.                             format(old_sounds[soundsnum],47,left)
  155.                             sounds_team[soundsnum]=team
  156.                             soundsnum++
  157.                         }
  158.                     }
  159.                     else
  160.                     {
  161.                         log_amx("Invalid File: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  162.                     }
  163.                 }
  164.                 else
  165.                 {
  166.                     log_amx("File Inexistent: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  167.                 }
  168.                 /*if(!file_exists(left))
  169.                 {
  170.                     log_amx("Warning: File Inexistent: ^"%s^" (Line %d of new_weapons.ini). ONLY A WARNING. PLUGIN WILL STILL WORK!!!!",left,i+1)
  171.                 }*/
  172.             }
  173.         }
  174.     }
  175. }
  176.  
  177. public Changeweapon_Hook(id)
  178. {
  179.     if(!is_user_alive(id) || !(get_user_flags(id) & ADMIN_LEVEL_H))
  180.     {
  181.         return PLUGIN_CONTINUE
  182.     }
  183.     static model[32], i, team
  184.  
  185.     team = get_user_team(id)
  186.  
  187.     pev(id,pev_viewmodel2,model,31)
  188.     for(i=0;i<v_modelsnum;i++)
  189.     {
  190.         if(equali(model,old_v_models[i]))
  191.         {
  192.             if(v_models_team[i]==team || !v_models_team[i])
  193.             {
  194.                 set_pev(id,pev_viewmodel2,new_v_models[i])
  195.                 break;
  196.             }
  197.         }
  198.     }
  199.  
  200.     pev(id,pev_weaponmodel2,model,31)
  201.     for(i=0;i<p_modelsnum;i++)
  202.     {
  203.         if(equali(model,old_p_models[i]))
  204.         {
  205.             if(p_models_team[i]==team || !p_models_team[i])
  206.             {
  207.                 set_pev(id,pev_weaponmodel2,new_p_models[i])
  208.                 break;
  209.             }
  210.         }
  211.     }
  212.     return PLUGIN_CONTINUE
  213. }
  214.  
  215. public Sound_Hook(id,channel,sample[])
  216. {
  217.     if(!is_user_alive(id) || !(get_user_flags(id) & ADMIN_LEVEL_H))
  218.     {
  219.         return FMRES_IGNORED
  220.     }
  221.     if(channel!=CHAN_WEAPON && channel!=CHAN_ITEM)
  222.     {
  223.         return FMRES_IGNORED
  224.     }
  225.  
  226.     static i, team
  227.  
  228.     team = get_user_team(id)
  229.  
  230.     for(i=0;i<soundsnum;i++)
  231.     {
  232.         if(equali(sample,old_sounds[i]))
  233.         {
  234.             if(sounds_team[i]==team || !sounds_team[i])
  235.             {
  236.                 engfunc(EngFunc_EmitSound,id,CHAN_WEAPON,new_sounds[i],1.0,ATTN_NORM,0,PITCH_NORM)
  237.                 return FMRES_SUPERCEDE
  238.             }
  239.         }
  240.     }
  241.     return FMRES_IGNORED
  242. }
  243.  
  244. public W_Model_Hook(iEnt,model[])
  245. {
  246.    
  247.     if(!pev_valid(iEnt) || !(get_user_flags(iEnt) & ADMIN_LEVEL_H))
  248.     {
  249.         return FMRES_IGNORED
  250.     }
  251.    
  252.     static i
  253.     for(i=0;i<w_modelsnum;i++)
  254.     {
  255.         if(equali(model,old_w_models[i]))
  256.         {
  257.             engfunc(EngFunc_SetModel,iEnt,new_w_models[i])
  258.             return FMRES_SUPERCEDE
  259.         }
  260.     }
  261.     return FMRES_IGNORED
  262. }
  263.  
  264. /*public newround()
  265. {
  266.     static ent, classname[8], model[32]
  267.     ent = engfunc(EngFunc_FindEntityInSphere,maxplayers,Float:{0.0,0.0,0.0},4800.0)
  268.     while(ent)
  269.     {
  270.         if(pev_valid(ent))
  271.         {
  272.             pev(ent,pev_classname,classname,7)
  273.             if(containi(classname,"armoury")!=-1)
  274.             {
  275.                 pev(ent,pev_model,model,31)
  276.                 W_Model_Hook(ent,model)
  277.             }
  278.         }
  279.         ent = engfunc(EngFunc_FindEntityInSphere,ent,Float:{0.0,0.0,0.0},4800.0)
  280.     }
  281. }*/

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 258
Joined: 7 years ago
Contact:

#22

Post by sPe3doN » 5 years ago

Mark wrote: 5 years ago Try this!
  1. #include <zombie_escape>
  2.  
  3. #define VERSION "1.3"
  4.  
  5. #define MAX_SOUNDS  50
  6. #define MAX_p_MODELS    50
  7. #define MAX_v_MODELS    50
  8. #define MAX_w_MODELS    50
  9.  
  10. #define MAP_CONFIGS 1
  11.  
  12. new new_sounds[MAX_SOUNDS][48]
  13. new old_sounds[MAX_SOUNDS][48]
  14. new sounds_team[MAX_SOUNDS]
  15. new soundsnum
  16.  
  17. new new_p_models[MAX_p_MODELS][48]
  18. new old_p_models[MAX_p_MODELS][48]
  19. new p_models_team[MAX_p_MODELS]
  20. new p_modelsnum
  21.  
  22. new new_v_models[MAX_v_MODELS][48]
  23. new old_v_models[MAX_v_MODELS][48]
  24. new v_models_team[MAX_p_MODELS]
  25. new v_modelsnum
  26.  
  27. new new_w_models[MAX_w_MODELS][48]
  28. new old_w_models[MAX_w_MODELS][48]
  29. new w_models_team[MAX_p_MODELS]
  30. new w_modelsnum
  31.  
  32.  
  33. public plugin_init()
  34. {
  35.     register_plugin("Weapon Model + Sound Replacement",VERSION,"GHW_Chronic")
  36.     register_forward(FM_EmitSound,"Sound_Hook")
  37.     register_forward(FM_SetModel,"W_Model_Hook",1)
  38.     register_event("CurWeapon","Changeweapon_Hook","be","1=1")
  39. }
  40.  
  41. public plugin_precache()
  42. {
  43.     new configfile[200]
  44.     new configsdir[200]
  45.     new map[32]
  46.     get_configsdir(configsdir,199)
  47.     get_mapname(map,31)
  48.     format(configfile,199,"%s/new_weapons_%s.ini",configsdir,map)
  49.     if(file_exists(configfile))
  50.     {
  51.         load_models(configfile)
  52.     }
  53.     else
  54.     {
  55.         format(configfile,199,"%s/new_weapons.ini",configsdir)
  56.         load_models(configfile)
  57.     }
  58. }
  59.  
  60. public load_models(configfile[])
  61. {
  62.     if(file_exists(configfile))
  63.     {
  64.         new read[96], left[48], right[48], right2[32], trash, team
  65.         for(new i=0;i<file_size(configfile,1);i++)
  66.         {
  67.             read_file(configfile,i,read,95,trash)
  68.             if(containi(read,";")!=0 && containi(read," ")!=-1)
  69.             {
  70.                 argbreak(read,left,47,right,47)
  71.                 team=0
  72.                 if(containi(right," ")!=-1)
  73.                 {
  74.                     argbreak(right,right,47,right2,31)
  75.                     replace_all(right2,31,"^"","")
  76.                     if(
  77.                     equali(right2,"T") ||
  78.                     equali(right2,"Terrorist") ||
  79.                     equali(right2,"Terrorists") ||
  80.                     equali(right2,"Blue") ||
  81.                     equali(right2,"B") ||
  82.                     equali(right2,"Allies") ||
  83.                     equali(right2,"1")
  84.                     ) team=1
  85.                     else if(
  86.                     equali(right2,"CT") ||
  87.                     equali(right2,"Counter") ||
  88.                     equali(right2,"Counter-Terrorist") ||
  89.                     equali(right2,"Counter-Terrorists") ||
  90.                     equali(right2,"CounterTerrorists") ||
  91.                     equali(right2,"CounterTerrorist") ||
  92.                     equali(right2,"Red") ||
  93.                     equali(right2,"R") ||
  94.                     equali(right2,"Axis") ||
  95.                     equali(right2,"2")
  96.                     ) team=2
  97.                     else if(
  98.                     equali(right2,"Yellow") ||
  99.                     equali(right2,"Y") ||
  100.                     equali(right2,"3")
  101.                     ) team=3
  102.                     else if(
  103.                     equali(right2,"Green") ||
  104.                     equali(right2,"G") ||
  105.                     equali(right2,"4")
  106.                     ) team=4
  107.                 }
  108.                 replace_all(right,47,"^"","")
  109.                 if(file_exists(right))
  110.                 {
  111.                     if(containi(right,".mdl")==strlen(right)-4)
  112.                     {
  113.                         if(!precache_model(right))
  114.                         {
  115.                             log_amx("Error attempting to precache model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  116.                         }
  117.                         else if(containi(left,"models/p_")==0)
  118.                         {
  119.                             format(new_p_models[p_modelsnum],47,right)
  120.                             format(old_p_models[p_modelsnum],47,left)
  121.                             p_models_team[p_modelsnum]=team
  122.                             p_modelsnum++
  123.                         }
  124.                         else if(containi(left,"models/v_")==0)
  125.                         {
  126.                             format(new_v_models[v_modelsnum],47,right)
  127.                             format(old_v_models[v_modelsnum],47,left)
  128.                             v_models_team[v_modelsnum]=team
  129.                             v_modelsnum++
  130.                         }
  131.                         else if(containi(left,"models/w_")==0)
  132.                         {
  133.                             format(new_w_models[w_modelsnum],47,right)
  134.                             format(old_w_models[w_modelsnum],47,left)
  135.                             w_models_team[w_modelsnum]=team
  136.                             w_modelsnum++
  137.                         }
  138.                         else
  139.                         {
  140.                             log_amx("Model type(p_ / v_ / w_) unknown for model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  141.                         }
  142.                     }
  143.                     else if(containi(right,".wav")==strlen(right)-4 || containi(right,".mp3")==strlen(right)-4)
  144.                     {
  145.                         replace(right,47,"sound/","")
  146.                         replace(left,47,"sound/","")
  147.                         if(!precache_sound(right))
  148.                         {
  149.                             log_amx("Error attempting to precache sound: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  150.                         }
  151.                         else
  152.                         {
  153.                             format(new_sounds[soundsnum],47,right)
  154.                             format(old_sounds[soundsnum],47,left)
  155.                             sounds_team[soundsnum]=team
  156.                             soundsnum++
  157.                         }
  158.                     }
  159.                     else
  160.                     {
  161.                         log_amx("Invalid File: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  162.                     }
  163.                 }
  164.                 else
  165.                 {
  166.                     log_amx("File Inexistent: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  167.                 }
  168.                 /*if(!file_exists(left))
  169.                 {
  170.                     log_amx("Warning: File Inexistent: ^"%s^" (Line %d of new_weapons.ini). ONLY A WARNING. PLUGIN WILL STILL WORK!!!!",left,i+1)
  171.                 }*/
  172.             }
  173.         }
  174.     }
  175. }
  176.  
  177. public Changeweapon_Hook(id)
  178. {
  179.     if(!is_user_alive(id) || !(get_user_flags(id) & ADMIN_LEVEL_H))
  180.     {
  181.         return PLUGIN_CONTINUE
  182.     }
  183.     static model[32], i, team
  184.  
  185.     team = get_user_team(id)
  186.  
  187.     pev(id,pev_viewmodel2,model,31)
  188.     for(i=0;i<v_modelsnum;i++)
  189.     {
  190.         if(equali(model,old_v_models[i]))
  191.         {
  192.             if(v_models_team[i]==team || !v_models_team[i])
  193.             {
  194.                 set_pev(id,pev_viewmodel2,new_v_models[i])
  195.                 break;
  196.             }
  197.         }
  198.     }
  199.  
  200.     pev(id,pev_weaponmodel2,model,31)
  201.     for(i=0;i<p_modelsnum;i++)
  202.     {
  203.         if(equali(model,old_p_models[i]))
  204.         {
  205.             if(p_models_team[i]==team || !p_models_team[i])
  206.             {
  207.                 set_pev(id,pev_weaponmodel2,new_p_models[i])
  208.                 break;
  209.             }
  210.         }
  211.     }
  212.     return PLUGIN_CONTINUE
  213. }
  214.  
  215. public Sound_Hook(id,channel,sample[])
  216. {
  217.     if(!is_user_alive(id) || !(get_user_flags(id) & ADMIN_LEVEL_H))
  218.     {
  219.         return FMRES_IGNORED
  220.     }
  221.     if(channel!=CHAN_WEAPON && channel!=CHAN_ITEM)
  222.     {
  223.         return FMRES_IGNORED
  224.     }
  225.  
  226.     static i, team
  227.  
  228.     team = get_user_team(id)
  229.  
  230.     for(i=0;i<soundsnum;i++)
  231.     {
  232.         if(equali(sample,old_sounds[i]))
  233.         {
  234.             if(sounds_team[i]==team || !sounds_team[i])
  235.             {
  236.                 engfunc(EngFunc_EmitSound,id,CHAN_WEAPON,new_sounds[i],1.0,ATTN_NORM,0,PITCH_NORM)
  237.                 return FMRES_SUPERCEDE
  238.             }
  239.         }
  240.     }
  241.     return FMRES_IGNORED
  242. }
  243.  
  244. public W_Model_Hook(iEnt,model[])
  245. {
  246.    
  247.     if(!pev_valid(iEnt) || !(get_user_flags(iEnt) & ADMIN_LEVEL_H))
  248.     {
  249.         return FMRES_IGNORED
  250.     }
  251.    
  252.     static i
  253.     for(i=0;i<w_modelsnum;i++)
  254.     {
  255.         if(equali(model,old_w_models[i]))
  256.         {
  257.             engfunc(EngFunc_SetModel,iEnt,new_w_models[i])
  258.             return FMRES_SUPERCEDE
  259.         }
  260.     }
  261.     return FMRES_IGNORED
  262. }
  263.  
  264. /*public newround()
  265. {
  266.     static ent, classname[8], model[32]
  267.     ent = engfunc(EngFunc_FindEntityInSphere,maxplayers,Float:{0.0,0.0,0.0},4800.0)
  268.     while(ent)
  269.     {
  270.         if(pev_valid(ent))
  271.         {
  272.             pev(ent,pev_classname,classname,7)
  273.             if(containi(classname,"armoury")!=-1)
  274.             {
  275.                 pev(ent,pev_model,model,31)
  276.                 W_Model_Hook(ent,model)
  277.             }
  278.         }
  279.         ent = engfunc(EngFunc_FindEntityInSphere,ent,Float:{0.0,0.0,0.0},4800.0)
  280.     }
  281. }*/
same error

Code: Select all

L 09/15/2018 - 18:45:49: Start of error session.
L 09/15/2018 - 18:45:49: Info (map "ze_egypt") (file "addons/amxmodx/logs/error_20180915.log")
L 09/15/2018 - 18:45:49: Invalid player id 263
Image

User avatar
Mark
VIP
VIP
United States of America
Posts: 283
Joined: 5 years ago
Location: Des Moines/USA
Contact:

#23

Post by Mark » 5 years ago

sPe3doN wrote: 5 years ago
Mark wrote: 5 years ago Try this!
  1. #include <zombie_escape>
  2.  
  3. #define VERSION "1.3"
  4.  
  5. #define MAX_SOUNDS  50
  6. #define MAX_p_MODELS    50
  7. #define MAX_v_MODELS    50
  8. #define MAX_w_MODELS    50
  9.  
  10. #define MAP_CONFIGS 1
  11.  
  12. new new_sounds[MAX_SOUNDS][48]
  13. new old_sounds[MAX_SOUNDS][48]
  14. new sounds_team[MAX_SOUNDS]
  15. new soundsnum
  16.  
  17. new new_p_models[MAX_p_MODELS][48]
  18. new old_p_models[MAX_p_MODELS][48]
  19. new p_models_team[MAX_p_MODELS]
  20. new p_modelsnum
  21.  
  22. new new_v_models[MAX_v_MODELS][48]
  23. new old_v_models[MAX_v_MODELS][48]
  24. new v_models_team[MAX_p_MODELS]
  25. new v_modelsnum
  26.  
  27. new new_w_models[MAX_w_MODELS][48]
  28. new old_w_models[MAX_w_MODELS][48]
  29. new w_models_team[MAX_p_MODELS]
  30. new w_modelsnum
  31.  
  32.  
  33. public plugin_init()
  34. {
  35.     register_plugin("Weapon Model + Sound Replacement",VERSION,"GHW_Chronic")
  36.     register_forward(FM_EmitSound,"Sound_Hook")
  37.     register_forward(FM_SetModel,"W_Model_Hook",1)
  38.     register_event("CurWeapon","Changeweapon_Hook","be","1=1")
  39. }
  40.  
  41. public plugin_precache()
  42. {
  43.     new configfile[200]
  44.     new configsdir[200]
  45.     new map[32]
  46.     get_configsdir(configsdir,199)
  47.     get_mapname(map,31)
  48.     format(configfile,199,"%s/new_weapons_%s.ini",configsdir,map)
  49.     if(file_exists(configfile))
  50.     {
  51.         load_models(configfile)
  52.     }
  53.     else
  54.     {
  55.         format(configfile,199,"%s/new_weapons.ini",configsdir)
  56.         load_models(configfile)
  57.     }
  58. }
  59.  
  60. public load_models(configfile[])
  61. {
  62.     if(file_exists(configfile))
  63.     {
  64.         new read[96], left[48], right[48], right2[32], trash, team
  65.         for(new i=0;i<file_size(configfile,1);i++)
  66.         {
  67.             read_file(configfile,i,read,95,trash)
  68.             if(containi(read,";")!=0 && containi(read," ")!=-1)
  69.             {
  70.                 argbreak(read,left,47,right,47)
  71.                 team=0
  72.                 if(containi(right," ")!=-1)
  73.                 {
  74.                     argbreak(right,right,47,right2,31)
  75.                     replace_all(right2,31,"^"","")
  76.                     if(
  77.                     equali(right2,"T") ||
  78.                     equali(right2,"Terrorist") ||
  79.                     equali(right2,"Terrorists") ||
  80.                     equali(right2,"Blue") ||
  81.                     equali(right2,"B") ||
  82.                     equali(right2,"Allies") ||
  83.                     equali(right2,"1")
  84.                     ) team=1
  85.                     else if(
  86.                     equali(right2,"CT") ||
  87.                     equali(right2,"Counter") ||
  88.                     equali(right2,"Counter-Terrorist") ||
  89.                     equali(right2,"Counter-Terrorists") ||
  90.                     equali(right2,"CounterTerrorists") ||
  91.                     equali(right2,"CounterTerrorist") ||
  92.                     equali(right2,"Red") ||
  93.                     equali(right2,"R") ||
  94.                     equali(right2,"Axis") ||
  95.                     equali(right2,"2")
  96.                     ) team=2
  97.                     else if(
  98.                     equali(right2,"Yellow") ||
  99.                     equali(right2,"Y") ||
  100.                     equali(right2,"3")
  101.                     ) team=3
  102.                     else if(
  103.                     equali(right2,"Green") ||
  104.                     equali(right2,"G") ||
  105.                     equali(right2,"4")
  106.                     ) team=4
  107.                 }
  108.                 replace_all(right,47,"^"","")
  109.                 if(file_exists(right))
  110.                 {
  111.                     if(containi(right,".mdl")==strlen(right)-4)
  112.                     {
  113.                         if(!precache_model(right))
  114.                         {
  115.                             log_amx("Error attempting to precache model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  116.                         }
  117.                         else if(containi(left,"models/p_")==0)
  118.                         {
  119.                             format(new_p_models[p_modelsnum],47,right)
  120.                             format(old_p_models[p_modelsnum],47,left)
  121.                             p_models_team[p_modelsnum]=team
  122.                             p_modelsnum++
  123.                         }
  124.                         else if(containi(left,"models/v_")==0)
  125.                         {
  126.                             format(new_v_models[v_modelsnum],47,right)
  127.                             format(old_v_models[v_modelsnum],47,left)
  128.                             v_models_team[v_modelsnum]=team
  129.                             v_modelsnum++
  130.                         }
  131.                         else if(containi(left,"models/w_")==0)
  132.                         {
  133.                             format(new_w_models[w_modelsnum],47,right)
  134.                             format(old_w_models[w_modelsnum],47,left)
  135.                             w_models_team[w_modelsnum]=team
  136.                             w_modelsnum++
  137.                         }
  138.                         else
  139.                         {
  140.                             log_amx("Model type(p_ / v_ / w_) unknown for model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  141.                         }
  142.                     }
  143.                     else if(containi(right,".wav")==strlen(right)-4 || containi(right,".mp3")==strlen(right)-4)
  144.                     {
  145.                         replace(right,47,"sound/","")
  146.                         replace(left,47,"sound/","")
  147.                         if(!precache_sound(right))
  148.                         {
  149.                             log_amx("Error attempting to precache sound: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  150.                         }
  151.                         else
  152.                         {
  153.                             format(new_sounds[soundsnum],47,right)
  154.                             format(old_sounds[soundsnum],47,left)
  155.                             sounds_team[soundsnum]=team
  156.                             soundsnum++
  157.                         }
  158.                     }
  159.                     else
  160.                     {
  161.                         log_amx("Invalid File: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  162.                     }
  163.                 }
  164.                 else
  165.                 {
  166.                     log_amx("File Inexistent: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  167.                 }
  168.                 /*if(!file_exists(left))
  169.                 {
  170.                     log_amx("Warning: File Inexistent: ^"%s^" (Line %d of new_weapons.ini). ONLY A WARNING. PLUGIN WILL STILL WORK!!!!",left,i+1)
  171.                 }*/
  172.             }
  173.         }
  174.     }
  175. }
  176.  
  177. public Changeweapon_Hook(id)
  178. {
  179.     if(!is_user_alive(id) || !(get_user_flags(id) & ADMIN_LEVEL_H))
  180.     {
  181.         return PLUGIN_CONTINUE
  182.     }
  183.     static model[32], i, team
  184.  
  185.     team = get_user_team(id)
  186.  
  187.     pev(id,pev_viewmodel2,model,31)
  188.     for(i=0;i<v_modelsnum;i++)
  189.     {
  190.         if(equali(model,old_v_models[i]))
  191.         {
  192.             if(v_models_team[i]==team || !v_models_team[i])
  193.             {
  194.                 set_pev(id,pev_viewmodel2,new_v_models[i])
  195.                 break;
  196.             }
  197.         }
  198.     }
  199.  
  200.     pev(id,pev_weaponmodel2,model,31)
  201.     for(i=0;i<p_modelsnum;i++)
  202.     {
  203.         if(equali(model,old_p_models[i]))
  204.         {
  205.             if(p_models_team[i]==team || !p_models_team[i])
  206.             {
  207.                 set_pev(id,pev_weaponmodel2,new_p_models[i])
  208.                 break;
  209.             }
  210.         }
  211.     }
  212.     return PLUGIN_CONTINUE
  213. }
  214.  
  215. public Sound_Hook(id,channel,sample[])
  216. {
  217.     if(!is_user_alive(id) || !(get_user_flags(id) & ADMIN_LEVEL_H))
  218.     {
  219.         return FMRES_IGNORED
  220.     }
  221.     if(channel!=CHAN_WEAPON && channel!=CHAN_ITEM)
  222.     {
  223.         return FMRES_IGNORED
  224.     }
  225.  
  226.     static i, team
  227.  
  228.     team = get_user_team(id)
  229.  
  230.     for(i=0;i<soundsnum;i++)
  231.     {
  232.         if(equali(sample,old_sounds[i]))
  233.         {
  234.             if(sounds_team[i]==team || !sounds_team[i])
  235.             {
  236.                 engfunc(EngFunc_EmitSound,id,CHAN_WEAPON,new_sounds[i],1.0,ATTN_NORM,0,PITCH_NORM)
  237.                 return FMRES_SUPERCEDE
  238.             }
  239.         }
  240.     }
  241.     return FMRES_IGNORED
  242. }
  243.  
  244. public W_Model_Hook(iEnt,model[])
  245. {
  246.    
  247.     if(!pev_valid(iEnt) || !(get_user_flags(iEnt) & ADMIN_LEVEL_H))
  248.     {
  249.         return FMRES_IGNORED
  250.     }
  251.    
  252.     static i
  253.     for(i=0;i<w_modelsnum;i++)
  254.     {
  255.         if(equali(model,old_w_models[i]))
  256.         {
  257.             engfunc(EngFunc_SetModel,iEnt,new_w_models[i])
  258.             return FMRES_SUPERCEDE
  259.         }
  260.     }
  261.     return FMRES_IGNORED
  262. }
  263.  
  264. /*public newround()
  265. {
  266.     static ent, classname[8], model[32]
  267.     ent = engfunc(EngFunc_FindEntityInSphere,maxplayers,Float:{0.0,0.0,0.0},4800.0)
  268.     while(ent)
  269.     {
  270.         if(pev_valid(ent))
  271.         {
  272.             pev(ent,pev_classname,classname,7)
  273.             if(containi(classname,"armoury")!=-1)
  274.             {
  275.                 pev(ent,pev_model,model,31)
  276.                 W_Model_Hook(ent,model)
  277.             }
  278.         }
  279.         ent = engfunc(EngFunc_FindEntityInSphere,ent,Float:{0.0,0.0,0.0},4800.0)
  280.     }
  281. }*/
same error

Code: Select all

L 09/15/2018 - 18:45:49: Start of error session.
L 09/15/2018 - 18:45:49: Info (map "ze_egypt") (file "addons/amxmodx/logs/error_20180915.log")
L 09/15/2018 - 18:45:49: Invalid player id 263
this?
  1. #include <zombie_escape>
  2.  
  3. #define VERSION "1.3"
  4.  
  5. #define MAX_SOUNDS  50
  6. #define MAX_p_MODELS    50
  7. #define MAX_v_MODELS    50
  8. #define MAX_w_MODELS    50
  9.  
  10. #define MAP_CONFIGS 1
  11.  
  12. new new_sounds[MAX_SOUNDS][48]
  13. new old_sounds[MAX_SOUNDS][48]
  14. new sounds_team[MAX_SOUNDS]
  15. new soundsnum
  16.  
  17. new new_p_models[MAX_p_MODELS][48]
  18. new old_p_models[MAX_p_MODELS][48]
  19. new p_models_team[MAX_p_MODELS]
  20. new p_modelsnum
  21.  
  22. new new_v_models[MAX_v_MODELS][48]
  23. new old_v_models[MAX_v_MODELS][48]
  24. new v_models_team[MAX_p_MODELS]
  25. new v_modelsnum
  26.  
  27. new new_w_models[MAX_w_MODELS][48]
  28. new old_w_models[MAX_w_MODELS][48]
  29. new w_models_team[MAX_p_MODELS]
  30. new w_modelsnum
  31.  
  32. new maxplayers
  33.  
  34. public plugin_init()
  35. {
  36.     register_plugin("Weapon Model + Sound Replacement",VERSION,"GHW_Chronic")
  37.     register_forward(FM_EmitSound,"Sound_Hook")
  38.     register_forward(FM_SetModel,"W_Model_Hook",1)
  39.     register_logevent("newround",2,"1=Round_Start")
  40.     register_event("CurWeapon","Changeweapon_Hook","be","1=1")
  41.     maxplayers = get_maxplayers()
  42. }
  43.  
  44. public plugin_precache()
  45. {
  46.     new configfile[200]
  47.     new configsdir[200]
  48.     new map[32]
  49.     get_configsdir(configsdir,199)
  50.     get_mapname(map,31)
  51.     format(configfile,199,"%s/new_weapons_%s.ini",configsdir,map)
  52.     if(file_exists(configfile))
  53.     {
  54.         load_models(configfile)
  55.     }
  56.     else
  57.     {
  58.         format(configfile,199,"%s/new_weapons.ini",configsdir)
  59.         load_models(configfile)
  60.     }
  61. }
  62.  
  63. public load_models(configfile[])
  64. {
  65.     if(file_exists(configfile))
  66.     {
  67.         new read[96], left[48], right[48], right2[32], trash, team
  68.         for(new i=0;i<file_size(configfile,1);i++)
  69.         {
  70.             read_file(configfile,i,read,95,trash)
  71.             if(containi(read,";")!=0 && containi(read," ")!=-1)
  72.             {
  73.                 argbreak(read,left,47,right,47)
  74.                 team=0
  75.                 if(containi(right," ")!=-1)
  76.                 {
  77.                     argbreak(right,right,47,right2,31)
  78.                     replace_all(right2,31,"^"","")
  79.                     if(
  80.                     equali(right2,"T") ||
  81.                     equali(right2,"Terrorist") ||
  82.                     equali(right2,"Terrorists") ||
  83.                     equali(right2,"Blue") ||
  84.                     equali(right2,"B") ||
  85.                     equali(right2,"Allies") ||
  86.                     equali(right2,"1")
  87.                     ) team=1
  88.                     else if(
  89.                     equali(right2,"CT") ||
  90.                     equali(right2,"Counter") ||
  91.                     equali(right2,"Counter-Terrorist") ||
  92.                     equali(right2,"Counter-Terrorists") ||
  93.                     equali(right2,"CounterTerrorists") ||
  94.                     equali(right2,"CounterTerrorist") ||
  95.                     equali(right2,"Red") ||
  96.                     equali(right2,"R") ||
  97.                     equali(right2,"Axis") ||
  98.                     equali(right2,"2")
  99.                     ) team=2
  100.                     else if(
  101.                     equali(right2,"Yellow") ||
  102.                     equali(right2,"Y") ||
  103.                     equali(right2,"3")
  104.                     ) team=3
  105.                     else if(
  106.                     equali(right2,"Green") ||
  107.                     equali(right2,"G") ||
  108.                     equali(right2,"4")
  109.                     ) team=4
  110.                 }
  111.                 replace_all(right,47,"^"","")
  112.                 if(file_exists(right))
  113.                 {
  114.                     if(containi(right,".mdl")==strlen(right)-4)
  115.                     {
  116.                         if(!precache_model(right))
  117.                         {
  118.                             log_amx("Error attempting to precache model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  119.                         }
  120.                         else if(containi(left,"models/p_")==0)
  121.                         {
  122.                             format(new_p_models[p_modelsnum],47,right)
  123.                             format(old_p_models[p_modelsnum],47,left)
  124.                             p_models_team[p_modelsnum]=team
  125.                             p_modelsnum++
  126.                         }
  127.                         else if(containi(left,"models/v_")==0)
  128.                         {
  129.                             format(new_v_models[v_modelsnum],47,right)
  130.                             format(old_v_models[v_modelsnum],47,left)
  131.                             v_models_team[v_modelsnum]=team
  132.                             v_modelsnum++
  133.                         }
  134.                         else if(containi(left,"models/w_")==0)
  135.                         {
  136.                             format(new_w_models[w_modelsnum],47,right)
  137.                             format(old_w_models[w_modelsnum],47,left)
  138.                             w_models_team[w_modelsnum]=team
  139.                             w_modelsnum++
  140.                         }
  141.                         else
  142.                         {
  143.                             log_amx("Model type(p_ / v_ / w_) unknown for model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  144.                         }
  145.                     }
  146.                     else if(containi(right,".wav")==strlen(right)-4 || containi(right,".mp3")==strlen(right)-4)
  147.                     {
  148.                         replace(right,47,"sound/","")
  149.                         replace(left,47,"sound/","")
  150.                         if(!precache_sound(right))
  151.                         {
  152.                             log_amx("Error attempting to precache sound: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  153.                         }
  154.                         else
  155.                         {
  156.                             format(new_sounds[soundsnum],47,right)
  157.                             format(old_sounds[soundsnum],47,left)
  158.                             sounds_team[soundsnum]=team
  159.                             soundsnum++
  160.                         }
  161.                     }
  162.                     else
  163.                     {
  164.                         log_amx("Invalid File: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  165.                     }
  166.                 }
  167.                 else
  168.                 {
  169.                     log_amx("File Inexistent: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  170.                 }
  171.                 /*if(!file_exists(left))
  172.                 {
  173.                     log_amx("Warning: File Inexistent: ^"%s^" (Line %d of new_weapons.ini). ONLY A WARNING. PLUGIN WILL STILL WORK!!!!",left,i+1)
  174.                 }*/
  175.             }
  176.         }
  177.     }
  178. }
  179.  
  180. public Changeweapon_Hook(id)
  181. {
  182.     if(!is_user_alive(id) || !(get_user_flags(id) & ADMIN_LEVEL_H))
  183.     {
  184.         return PLUGIN_CONTINUE
  185.     }
  186.     static model[32], i, team
  187.  
  188.     team = get_user_team(id)
  189.  
  190.     pev(id,pev_viewmodel2,model,31)
  191.     for(i=0;i<v_modelsnum;i++)
  192.     {
  193.         if(equali(model,old_v_models[i]))
  194.         {
  195.             if(v_models_team[i]==team || !v_models_team[i])
  196.             {
  197.                 set_pev(id,pev_viewmodel2,new_v_models[i])
  198.                 break;
  199.             }
  200.         }
  201.     }
  202.  
  203.     pev(id,pev_weaponmodel2,model,31)
  204.     for(i=0;i<p_modelsnum;i++)
  205.     {
  206.         if(equali(model,old_p_models[i]))
  207.         {
  208.             if(p_models_team[i]==team || !p_models_team[i])
  209.             {
  210.                 set_pev(id,pev_weaponmodel2,new_p_models[i])
  211.                 break;
  212.             }
  213.         }
  214.     }
  215.     return PLUGIN_CONTINUE
  216. }
  217.  
  218. public Sound_Hook(id,channel,sample[])
  219. {
  220.     if(!is_user_alive(id))
  221.     {
  222.         return FMRES_IGNORED
  223.     }
  224.     if(channel!=CHAN_WEAPON && channel!=CHAN_ITEM)
  225.     {
  226.         return FMRES_IGNORED
  227.     }
  228.  
  229.     static i, team
  230.  
  231.     team = get_user_team(id)
  232.  
  233.     for(i=0;i<soundsnum;i++)
  234.     {
  235.         if(equali(sample,old_sounds[i]))
  236.         {
  237.             if(sounds_team[i]==team || !sounds_team[i])
  238.             {
  239.                 engfunc(EngFunc_EmitSound,id,CHAN_WEAPON,new_sounds[i],1.0,ATTN_NORM,0,PITCH_NORM)
  240.                 return FMRES_SUPERCEDE
  241.             }
  242.         }
  243.     }
  244.     return FMRES_IGNORED
  245. }
  246.  
  247. public W_Model_Hook(ent,model[])
  248. {
  249.     if(!pev_valid(ent))
  250.     {
  251.         return FMRES_IGNORED
  252.     }
  253.     static i
  254.     for(i=0;i<w_modelsnum;i++)
  255.     {
  256.         if(equali(model,old_w_models[i]))
  257.         {
  258.             engfunc(EngFunc_SetModel,ent,new_w_models[i])
  259.             return FMRES_SUPERCEDE
  260.         }
  261.     }
  262.     return FMRES_IGNORED
  263. }
  264.  
  265. public newround()
  266. {
  267.     static ent, classname[8], model[32]
  268.     ent = engfunc(EngFunc_FindEntityInSphere,maxplayers,Float:{0.0,0.0,0.0},4800.0)
  269.     while(ent)
  270.     {
  271.         if(pev_valid(ent))
  272.         {
  273.             pev(ent,pev_classname,classname,7)
  274.             if(containi(classname,"armoury")!=-1)
  275.             {
  276.                 pev(ent,pev_model,model,31)
  277.                 W_Model_Hook(ent,model)
  278.             }
  279.         }
  280.         ent = engfunc(EngFunc_FindEntityInSphere,ent,Float:{0.0,0.0,0.0},4800.0)
  281.     }
  282. }
IF that don't work try this.
  1. #include <zombie_escape>
  2.  
  3. #define VERSION "1.3"
  4.  
  5. #define MAX_SOUNDS  50
  6. #define MAX_p_MODELS    50
  7. #define MAX_v_MODELS    50
  8. #define MAX_w_MODELS    50
  9.  
  10. #define MAP_CONFIGS 1
  11.  
  12. new new_sounds[MAX_SOUNDS][48]
  13. new old_sounds[MAX_SOUNDS][48]
  14. new sounds_team[MAX_SOUNDS]
  15. new soundsnum
  16.  
  17. new new_p_models[MAX_p_MODELS][48]
  18. new old_p_models[MAX_p_MODELS][48]
  19. new p_models_team[MAX_p_MODELS]
  20. new p_modelsnum
  21.  
  22. new new_v_models[MAX_v_MODELS][48]
  23. new old_v_models[MAX_v_MODELS][48]
  24. new v_models_team[MAX_p_MODELS]
  25. new v_modelsnum
  26.  
  27. new new_w_models[MAX_w_MODELS][48]
  28. new old_w_models[MAX_w_MODELS][48]
  29. new w_models_team[MAX_p_MODELS]
  30. new w_modelsnum
  31.  
  32. new maxplayers
  33.  
  34. public plugin_init()
  35. {
  36.     register_plugin("Weapon Model + Sound Replacement",VERSION,"GHW_Chronic")
  37.     register_forward(FM_EmitSound,"Sound_Hook")
  38.     register_forward(FM_SetModel,"W_Model_Hook",1)
  39.     register_logevent("newround",2,"1=Round_Start")
  40.     register_event("CurWeapon","Changeweapon_Hook","be","1=1")
  41.     maxplayers = get_maxplayers()
  42. }
  43.  
  44. public plugin_precache()
  45. {
  46.     new configfile[200]
  47.     new configsdir[200]
  48.     new map[32]
  49.     get_configsdir(configsdir,199)
  50.     get_mapname(map,31)
  51.     format(configfile,199,"%s/new_weapons_%s.ini",configsdir,map)
  52.     if(file_exists(configfile))
  53.     {
  54.         load_models(configfile)
  55.     }
  56.     else
  57.     {
  58.         format(configfile,199,"%s/new_weapons.ini",configsdir)
  59.         load_models(configfile)
  60.     }
  61. }
  62.  
  63. public load_models(configfile[])
  64. {
  65.     if(file_exists(configfile))
  66.     {
  67.         new read[96], left[48], right[48], right2[32], trash, team
  68.         for(new i=0;i<file_size(configfile,1);i++)
  69.         {
  70.             read_file(configfile,i,read,95,trash)
  71.             if(containi(read,";")!=0 && containi(read," ")!=-1)
  72.             {
  73.                 argbreak(read,left,47,right,47)
  74.                 team=0
  75.                 if(containi(right," ")!=-1)
  76.                 {
  77.                     argbreak(right,right,47,right2,31)
  78.                     replace_all(right2,31,"^"","")
  79.                     if(
  80.                     equali(right2,"T") ||
  81.                     equali(right2,"Terrorist") ||
  82.                     equali(right2,"Terrorists") ||
  83.                     equali(right2,"Blue") ||
  84.                     equali(right2,"B") ||
  85.                     equali(right2,"Allies") ||
  86.                     equali(right2,"1")
  87.                     ) team=1
  88.                     else if(
  89.                     equali(right2,"CT") ||
  90.                     equali(right2,"Counter") ||
  91.                     equali(right2,"Counter-Terrorist") ||
  92.                     equali(right2,"Counter-Terrorists") ||
  93.                     equali(right2,"CounterTerrorists") ||
  94.                     equali(right2,"CounterTerrorist") ||
  95.                     equali(right2,"Red") ||
  96.                     equali(right2,"R") ||
  97.                     equali(right2,"Axis") ||
  98.                     equali(right2,"2")
  99.                     ) team=2
  100.                     else if(
  101.                     equali(right2,"Yellow") ||
  102.                     equali(right2,"Y") ||
  103.                     equali(right2,"3")
  104.                     ) team=3
  105.                     else if(
  106.                     equali(right2,"Green") ||
  107.                     equali(right2,"G") ||
  108.                     equali(right2,"4")
  109.                     ) team=4
  110.                 }
  111.                 replace_all(right,47,"^"","")
  112.                 if(file_exists(right))
  113.                 {
  114.                     if(containi(right,".mdl")==strlen(right)-4)
  115.                     {
  116.                         if(!precache_model(right))
  117.                         {
  118.                             log_amx("Error attempting to precache model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  119.                         }
  120.                         else if(containi(left,"models/p_")==0)
  121.                         {
  122.                             format(new_p_models[p_modelsnum],47,right)
  123.                             format(old_p_models[p_modelsnum],47,left)
  124.                             p_models_team[p_modelsnum]=team
  125.                             p_modelsnum++
  126.                         }
  127.                         else if(containi(left,"models/v_")==0)
  128.                         {
  129.                             format(new_v_models[v_modelsnum],47,right)
  130.                             format(old_v_models[v_modelsnum],47,left)
  131.                             v_models_team[v_modelsnum]=team
  132.                             v_modelsnum++
  133.                         }
  134.                         else if(containi(left,"models/w_")==0)
  135.                         {
  136.                             format(new_w_models[w_modelsnum],47,right)
  137.                             format(old_w_models[w_modelsnum],47,left)
  138.                             w_models_team[w_modelsnum]=team
  139.                             w_modelsnum++
  140.                         }
  141.                         else
  142.                         {
  143.                             log_amx("Model type(p_ / v_ / w_) unknown for model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  144.                         }
  145.                     }
  146.                     else if(containi(right,".wav")==strlen(right)-4 || containi(right,".mp3")==strlen(right)-4)
  147.                     {
  148.                         replace(right,47,"sound/","")
  149.                         replace(left,47,"sound/","")
  150.                         if(!precache_sound(right))
  151.                         {
  152.                             log_amx("Error attempting to precache sound: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  153.                         }
  154.                         else
  155.                         {
  156.                             format(new_sounds[soundsnum],47,right)
  157.                             format(old_sounds[soundsnum],47,left)
  158.                             sounds_team[soundsnum]=team
  159.                             soundsnum++
  160.                         }
  161.                     }
  162.                     else
  163.                     {
  164.                         log_amx("Invalid File: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  165.                     }
  166.                 }
  167.                 else
  168.                 {
  169.                     log_amx("File Inexistent: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  170.                 }
  171.                 /*if(!file_exists(left))
  172.                 {
  173.                     log_amx("Warning: File Inexistent: ^"%s^" (Line %d of new_weapons.ini). ONLY A WARNING. PLUGIN WILL STILL WORK!!!!",left,i+1)
  174.                 }*/
  175.             }
  176.         }
  177.     }
  178. }
  179.  
  180. public Changeweapon_Hook(id)
  181. {
  182.     if(!is_user_alive(id) || !(get_user_flags(id) && ADMIN_LEVEL_H))
  183.     {
  184.         return PLUGIN_CONTINUE
  185.     }
  186.     static model[32], i, team
  187.  
  188.     team = get_user_team(id)
  189.  
  190.     pev(id,pev_viewmodel2,model,31)
  191.     for(i=0;i<v_modelsnum;i++)
  192.     {
  193.         if(equali(model,old_v_models[i]))
  194.         {
  195.             if(v_models_team[i]==team || !v_models_team[i])
  196.             {
  197.                 set_pev(id,pev_viewmodel2,new_v_models[i])
  198.                 break;
  199.             }
  200.         }
  201.     }
  202.  
  203.     pev(id,pev_weaponmodel2,model,31)
  204.     for(i=0;i<p_modelsnum;i++)
  205.     {
  206.         if(equali(model,old_p_models[i]))
  207.         {
  208.             if(p_models_team[i]==team || !p_models_team[i])
  209.             {
  210.                 set_pev(id,pev_weaponmodel2,new_p_models[i])
  211.                 break;
  212.             }
  213.         }
  214.     }
  215.     return PLUGIN_CONTINUE
  216. }
  217.  
  218. public Sound_Hook(id,channel,sample[])
  219. {
  220.     if(!is_user_alive(id))
  221.     {
  222.         return FMRES_IGNORED
  223.     }
  224.     if(channel!=CHAN_WEAPON && channel!=CHAN_ITEM)
  225.     {
  226.         return FMRES_IGNORED
  227.     }
  228.  
  229.     static i, team
  230.  
  231.     team = get_user_team(id)
  232.  
  233.     for(i=0;i<soundsnum;i++)
  234.     {
  235.         if(equali(sample,old_sounds[i]))
  236.         {
  237.             if(sounds_team[i]==team || !sounds_team[i])
  238.             {
  239.                 engfunc(EngFunc_EmitSound,id,CHAN_WEAPON,new_sounds[i],1.0,ATTN_NORM,0,PITCH_NORM)
  240.                 return FMRES_SUPERCEDE
  241.             }
  242.         }
  243.     }
  244.     return FMRES_IGNORED
  245. }
  246.  
  247. public W_Model_Hook(ent,model[])
  248. {
  249.     if(!pev_valid(ent))
  250.     {
  251.         return FMRES_IGNORED
  252.     }
  253.     static i
  254.     for(i=0;i<w_modelsnum;i++)
  255.     {
  256.         if(equali(model,old_w_models[i]))
  257.         {
  258.             engfunc(EngFunc_SetModel,ent,new_w_models[i])
  259.             return FMRES_SUPERCEDE
  260.         }
  261.     }
  262.     return FMRES_IGNORED
  263. }
  264.  
  265. public newround()
  266. {
  267.     static ent, classname[8], model[32]
  268.     ent = engfunc(EngFunc_FindEntityInSphere,maxplayers,Float:{0.0,0.0,0.0},4800.0)
  269.     while(ent)
  270.     {
  271.         if(pev_valid(ent))
  272.         {
  273.             pev(ent,pev_classname,classname,7)
  274.             if(containi(classname,"armoury")!=-1)
  275.             {
  276.                 pev(ent,pev_model,model,31)
  277.                 W_Model_Hook(ent,model)
  278.             }
  279.         }
  280.         ent = engfunc(EngFunc_FindEntityInSphere,ent,Float:{0.0,0.0,0.0},4800.0)
  281.     }
  282. }

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 258
Joined: 7 years ago
Contact:

#24

Post by sPe3doN » 5 years ago

Mark wrote: 5 years ago
sPe3doN wrote: 5 years ago
Mark wrote: 5 years ago Try this!
  1. #include <zombie_escape>
  2.  
  3. #define VERSION "1.3"
  4.  
  5. #define MAX_SOUNDS  50
  6. #define MAX_p_MODELS    50
  7. #define MAX_v_MODELS    50
  8. #define MAX_w_MODELS    50
  9.  
  10. #define MAP_CONFIGS 1
  11.  
  12. new new_sounds[MAX_SOUNDS][48]
  13. new old_sounds[MAX_SOUNDS][48]
  14. new sounds_team[MAX_SOUNDS]
  15. new soundsnum
  16.  
  17. new new_p_models[MAX_p_MODELS][48]
  18. new old_p_models[MAX_p_MODELS][48]
  19. new p_models_team[MAX_p_MODELS]
  20. new p_modelsnum
  21.  
  22. new new_v_models[MAX_v_MODELS][48]
  23. new old_v_models[MAX_v_MODELS][48]
  24. new v_models_team[MAX_p_MODELS]
  25. new v_modelsnum
  26.  
  27. new new_w_models[MAX_w_MODELS][48]
  28. new old_w_models[MAX_w_MODELS][48]
  29. new w_models_team[MAX_p_MODELS]
  30. new w_modelsnum
  31.  
  32.  
  33. public plugin_init()
  34. {
  35.     register_plugin("Weapon Model + Sound Replacement",VERSION,"GHW_Chronic")
  36.     register_forward(FM_EmitSound,"Sound_Hook")
  37.     register_forward(FM_SetModel,"W_Model_Hook",1)
  38.     register_event("CurWeapon","Changeweapon_Hook","be","1=1")
  39. }
  40.  
  41. public plugin_precache()
  42. {
  43.     new configfile[200]
  44.     new configsdir[200]
  45.     new map[32]
  46.     get_configsdir(configsdir,199)
  47.     get_mapname(map,31)
  48.     format(configfile,199,"%s/new_weapons_%s.ini",configsdir,map)
  49.     if(file_exists(configfile))
  50.     {
  51.         load_models(configfile)
  52.     }
  53.     else
  54.     {
  55.         format(configfile,199,"%s/new_weapons.ini",configsdir)
  56.         load_models(configfile)
  57.     }
  58. }
  59.  
  60. public load_models(configfile[])
  61. {
  62.     if(file_exists(configfile))
  63.     {
  64.         new read[96], left[48], right[48], right2[32], trash, team
  65.         for(new i=0;i<file_size(configfile,1);i++)
  66.         {
  67.             read_file(configfile,i,read,95,trash)
  68.             if(containi(read,";")!=0 && containi(read," ")!=-1)
  69.             {
  70.                 argbreak(read,left,47,right,47)
  71.                 team=0
  72.                 if(containi(right," ")!=-1)
  73.                 {
  74.                     argbreak(right,right,47,right2,31)
  75.                     replace_all(right2,31,"^"","")
  76.                     if(
  77.                     equali(right2,"T") ||
  78.                     equali(right2,"Terrorist") ||
  79.                     equali(right2,"Terrorists") ||
  80.                     equali(right2,"Blue") ||
  81.                     equali(right2,"B") ||
  82.                     equali(right2,"Allies") ||
  83.                     equali(right2,"1")
  84.                     ) team=1
  85.                     else if(
  86.                     equali(right2,"CT") ||
  87.                     equali(right2,"Counter") ||
  88.                     equali(right2,"Counter-Terrorist") ||
  89.                     equali(right2,"Counter-Terrorists") ||
  90.                     equali(right2,"CounterTerrorists") ||
  91.                     equali(right2,"CounterTerrorist") ||
  92.                     equali(right2,"Red") ||
  93.                     equali(right2,"R") ||
  94.                     equali(right2,"Axis") ||
  95.                     equali(right2,"2")
  96.                     ) team=2
  97.                     else if(
  98.                     equali(right2,"Yellow") ||
  99.                     equali(right2,"Y") ||
  100.                     equali(right2,"3")
  101.                     ) team=3
  102.                     else if(
  103.                     equali(right2,"Green") ||
  104.                     equali(right2,"G") ||
  105.                     equali(right2,"4")
  106.                     ) team=4
  107.                 }
  108.                 replace_all(right,47,"^"","")
  109.                 if(file_exists(right))
  110.                 {
  111.                     if(containi(right,".mdl")==strlen(right)-4)
  112.                     {
  113.                         if(!precache_model(right))
  114.                         {
  115.                             log_amx("Error attempting to precache model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  116.                         }
  117.                         else if(containi(left,"models/p_")==0)
  118.                         {
  119.                             format(new_p_models[p_modelsnum],47,right)
  120.                             format(old_p_models[p_modelsnum],47,left)
  121.                             p_models_team[p_modelsnum]=team
  122.                             p_modelsnum++
  123.                         }
  124.                         else if(containi(left,"models/v_")==0)
  125.                         {
  126.                             format(new_v_models[v_modelsnum],47,right)
  127.                             format(old_v_models[v_modelsnum],47,left)
  128.                             v_models_team[v_modelsnum]=team
  129.                             v_modelsnum++
  130.                         }
  131.                         else if(containi(left,"models/w_")==0)
  132.                         {
  133.                             format(new_w_models[w_modelsnum],47,right)
  134.                             format(old_w_models[w_modelsnum],47,left)
  135.                             w_models_team[w_modelsnum]=team
  136.                             w_modelsnum++
  137.                         }
  138.                         else
  139.                         {
  140.                             log_amx("Model type(p_ / v_ / w_) unknown for model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  141.                         }
  142.                     }
  143.                     else if(containi(right,".wav")==strlen(right)-4 || containi(right,".mp3")==strlen(right)-4)
  144.                     {
  145.                         replace(right,47,"sound/","")
  146.                         replace(left,47,"sound/","")
  147.                         if(!precache_sound(right))
  148.                         {
  149.                             log_amx("Error attempting to precache sound: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  150.                         }
  151.                         else
  152.                         {
  153.                             format(new_sounds[soundsnum],47,right)
  154.                             format(old_sounds[soundsnum],47,left)
  155.                             sounds_team[soundsnum]=team
  156.                             soundsnum++
  157.                         }
  158.                     }
  159.                     else
  160.                     {
  161.                         log_amx("Invalid File: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  162.                     }
  163.                 }
  164.                 else
  165.                 {
  166.                     log_amx("File Inexistent: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  167.                 }
  168.                 /*if(!file_exists(left))
  169.                 {
  170.                     log_amx("Warning: File Inexistent: ^"%s^" (Line %d of new_weapons.ini). ONLY A WARNING. PLUGIN WILL STILL WORK!!!!",left,i+1)
  171.                 }*/
  172.             }
  173.         }
  174.     }
  175. }
  176.  
  177. public Changeweapon_Hook(id)
  178. {
  179.     if(!is_user_alive(id) || !(get_user_flags(id) & ADMIN_LEVEL_H))
  180.     {
  181.         return PLUGIN_CONTINUE
  182.     }
  183.     static model[32], i, team
  184.  
  185.     team = get_user_team(id)
  186.  
  187.     pev(id,pev_viewmodel2,model,31)
  188.     for(i=0;i<v_modelsnum;i++)
  189.     {
  190.         if(equali(model,old_v_models[i]))
  191.         {
  192.             if(v_models_team[i]==team || !v_models_team[i])
  193.             {
  194.                 set_pev(id,pev_viewmodel2,new_v_models[i])
  195.                 break;
  196.             }
  197.         }
  198.     }
  199.  
  200.     pev(id,pev_weaponmodel2,model,31)
  201.     for(i=0;i<p_modelsnum;i++)
  202.     {
  203.         if(equali(model,old_p_models[i]))
  204.         {
  205.             if(p_models_team[i]==team || !p_models_team[i])
  206.             {
  207.                 set_pev(id,pev_weaponmodel2,new_p_models[i])
  208.                 break;
  209.             }
  210.         }
  211.     }
  212.     return PLUGIN_CONTINUE
  213. }
  214.  
  215. public Sound_Hook(id,channel,sample[])
  216. {
  217.     if(!is_user_alive(id) || !(get_user_flags(id) & ADMIN_LEVEL_H))
  218.     {
  219.         return FMRES_IGNORED
  220.     }
  221.     if(channel!=CHAN_WEAPON && channel!=CHAN_ITEM)
  222.     {
  223.         return FMRES_IGNORED
  224.     }
  225.  
  226.     static i, team
  227.  
  228.     team = get_user_team(id)
  229.  
  230.     for(i=0;i<soundsnum;i++)
  231.     {
  232.         if(equali(sample,old_sounds[i]))
  233.         {
  234.             if(sounds_team[i]==team || !sounds_team[i])
  235.             {
  236.                 engfunc(EngFunc_EmitSound,id,CHAN_WEAPON,new_sounds[i],1.0,ATTN_NORM,0,PITCH_NORM)
  237.                 return FMRES_SUPERCEDE
  238.             }
  239.         }
  240.     }
  241.     return FMRES_IGNORED
  242. }
  243.  
  244. public W_Model_Hook(iEnt,model[])
  245. {
  246.    
  247.     if(!pev_valid(iEnt) || !(get_user_flags(iEnt) & ADMIN_LEVEL_H))
  248.     {
  249.         return FMRES_IGNORED
  250.     }
  251.    
  252.     static i
  253.     for(i=0;i<w_modelsnum;i++)
  254.     {
  255.         if(equali(model,old_w_models[i]))
  256.         {
  257.             engfunc(EngFunc_SetModel,iEnt,new_w_models[i])
  258.             return FMRES_SUPERCEDE
  259.         }
  260.     }
  261.     return FMRES_IGNORED
  262. }
  263.  
  264. /*public newround()
  265. {
  266.     static ent, classname[8], model[32]
  267.     ent = engfunc(EngFunc_FindEntityInSphere,maxplayers,Float:{0.0,0.0,0.0},4800.0)
  268.     while(ent)
  269.     {
  270.         if(pev_valid(ent))
  271.         {
  272.             pev(ent,pev_classname,classname,7)
  273.             if(containi(classname,"armoury")!=-1)
  274.             {
  275.                 pev(ent,pev_model,model,31)
  276.                 W_Model_Hook(ent,model)
  277.             }
  278.         }
  279.         ent = engfunc(EngFunc_FindEntityInSphere,ent,Float:{0.0,0.0,0.0},4800.0)
  280.     }
  281. }*/
same error

Code: Select all

L 09/15/2018 - 18:45:49: Start of error session.
L 09/15/2018 - 18:45:49: Info (map "ze_egypt") (file "addons/amxmodx/logs/error_20180915.log")
L 09/15/2018 - 18:45:49: Invalid player id 263
this?
  1. #include <zombie_escape>
  2.  
  3. #define VERSION "1.3"
  4.  
  5. #define MAX_SOUNDS  50
  6. #define MAX_p_MODELS    50
  7. #define MAX_v_MODELS    50
  8. #define MAX_w_MODELS    50
  9.  
  10. #define MAP_CONFIGS 1
  11.  
  12. new new_sounds[MAX_SOUNDS][48]
  13. new old_sounds[MAX_SOUNDS][48]
  14. new sounds_team[MAX_SOUNDS]
  15. new soundsnum
  16.  
  17. new new_p_models[MAX_p_MODELS][48]
  18. new old_p_models[MAX_p_MODELS][48]
  19. new p_models_team[MAX_p_MODELS]
  20. new p_modelsnum
  21.  
  22. new new_v_models[MAX_v_MODELS][48]
  23. new old_v_models[MAX_v_MODELS][48]
  24. new v_models_team[MAX_p_MODELS]
  25. new v_modelsnum
  26.  
  27. new new_w_models[MAX_w_MODELS][48]
  28. new old_w_models[MAX_w_MODELS][48]
  29. new w_models_team[MAX_p_MODELS]
  30. new w_modelsnum
  31.  
  32. new maxplayers
  33.  
  34. public plugin_init()
  35. {
  36.     register_plugin("Weapon Model + Sound Replacement",VERSION,"GHW_Chronic")
  37.     register_forward(FM_EmitSound,"Sound_Hook")
  38.     register_forward(FM_SetModel,"W_Model_Hook",1)
  39.     register_logevent("newround",2,"1=Round_Start")
  40.     register_event("CurWeapon","Changeweapon_Hook","be","1=1")
  41.     maxplayers = get_maxplayers()
  42. }
  43.  
  44. public plugin_precache()
  45. {
  46.     new configfile[200]
  47.     new configsdir[200]
  48.     new map[32]
  49.     get_configsdir(configsdir,199)
  50.     get_mapname(map,31)
  51.     format(configfile,199,"%s/new_weapons_%s.ini",configsdir,map)
  52.     if(file_exists(configfile))
  53.     {
  54.         load_models(configfile)
  55.     }
  56.     else
  57.     {
  58.         format(configfile,199,"%s/new_weapons.ini",configsdir)
  59.         load_models(configfile)
  60.     }
  61. }
  62.  
  63. public load_models(configfile[])
  64. {
  65.     if(file_exists(configfile))
  66.     {
  67.         new read[96], left[48], right[48], right2[32], trash, team
  68.         for(new i=0;i<file_size(configfile,1);i++)
  69.         {
  70.             read_file(configfile,i,read,95,trash)
  71.             if(containi(read,";")!=0 && containi(read," ")!=-1)
  72.             {
  73.                 argbreak(read,left,47,right,47)
  74.                 team=0
  75.                 if(containi(right," ")!=-1)
  76.                 {
  77.                     argbreak(right,right,47,right2,31)
  78.                     replace_all(right2,31,"^"","")
  79.                     if(
  80.                     equali(right2,"T") ||
  81.                     equali(right2,"Terrorist") ||
  82.                     equali(right2,"Terrorists") ||
  83.                     equali(right2,"Blue") ||
  84.                     equali(right2,"B") ||
  85.                     equali(right2,"Allies") ||
  86.                     equali(right2,"1")
  87.                     ) team=1
  88.                     else if(
  89.                     equali(right2,"CT") ||
  90.                     equali(right2,"Counter") ||
  91.                     equali(right2,"Counter-Terrorist") ||
  92.                     equali(right2,"Counter-Terrorists") ||
  93.                     equali(right2,"CounterTerrorists") ||
  94.                     equali(right2,"CounterTerrorist") ||
  95.                     equali(right2,"Red") ||
  96.                     equali(right2,"R") ||
  97.                     equali(right2,"Axis") ||
  98.                     equali(right2,"2")
  99.                     ) team=2
  100.                     else if(
  101.                     equali(right2,"Yellow") ||
  102.                     equali(right2,"Y") ||
  103.                     equali(right2,"3")
  104.                     ) team=3
  105.                     else if(
  106.                     equali(right2,"Green") ||
  107.                     equali(right2,"G") ||
  108.                     equali(right2,"4")
  109.                     ) team=4
  110.                 }
  111.                 replace_all(right,47,"^"","")
  112.                 if(file_exists(right))
  113.                 {
  114.                     if(containi(right,".mdl")==strlen(right)-4)
  115.                     {
  116.                         if(!precache_model(right))
  117.                         {
  118.                             log_amx("Error attempting to precache model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  119.                         }
  120.                         else if(containi(left,"models/p_")==0)
  121.                         {
  122.                             format(new_p_models[p_modelsnum],47,right)
  123.                             format(old_p_models[p_modelsnum],47,left)
  124.                             p_models_team[p_modelsnum]=team
  125.                             p_modelsnum++
  126.                         }
  127.                         else if(containi(left,"models/v_")==0)
  128.                         {
  129.                             format(new_v_models[v_modelsnum],47,right)
  130.                             format(old_v_models[v_modelsnum],47,left)
  131.                             v_models_team[v_modelsnum]=team
  132.                             v_modelsnum++
  133.                         }
  134.                         else if(containi(left,"models/w_")==0)
  135.                         {
  136.                             format(new_w_models[w_modelsnum],47,right)
  137.                             format(old_w_models[w_modelsnum],47,left)
  138.                             w_models_team[w_modelsnum]=team
  139.                             w_modelsnum++
  140.                         }
  141.                         else
  142.                         {
  143.                             log_amx("Model type(p_ / v_ / w_) unknown for model: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  144.                         }
  145.                     }
  146.                     else if(containi(right,".wav")==strlen(right)-4 || containi(right,".mp3")==strlen(right)-4)
  147.                     {
  148.                         replace(right,47,"sound/","")
  149.                         replace(left,47,"sound/","")
  150.                         if(!precache_sound(right))
  151.                         {
  152.                             log_amx("Error attempting to precache sound: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  153.                         }
  154.                         else
  155.                         {
  156.                             format(new_sounds[soundsnum],47,right)
  157.                             format(old_sounds[soundsnum],47,left)
  158.                             sounds_team[soundsnum]=team
  159.                             soundsnum++
  160.                         }
  161.                     }
  162.                     else
  163.                     {
  164.                         log_amx("Invalid File: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  165.                     }
  166.                 }
  167.                 else
  168.                 {
  169.                     log_amx("File Inexistent: ^"%s^" (Line %d of new_weapons.ini)",right,i+1)
  170.                 }
  171.                 /*if(!file_exists(left))
  172.                 {
  173.                     log_amx("Warning: File Inexistent: ^"%s^" (Line %d of new_weapons.ini). ONLY A WARNING. PLUGIN WILL STILL WORK!!!!",left,i+1)
  174.                 }*/
  175.             }
  176.         }
  177.     }
  178. }
  179.  
  180. public Changeweapon_Hook(id)
  181. {
  182.     if(!is_user_alive(id) || !(get_user_flags(id) & ADMIN_LEVEL_H))
  183.     {
  184.         return PLUGIN_CONTINUE
  185.     }
  186.     static model[32], i, team
  187.  
  188.     team = get_user_team(id)
  189.  
  190.     pev(id,pev_viewmodel2,model,31)
  191.     for(i=0;i<v_modelsnum;i++)
  192.     {
  193.         if(equali(model,old_v_models[i]))
  194.         {
  195.             if(v_models_team[i]==team || !v_models_team[i])
  196.             {
  197.                 set_pev(id,pev_viewmodel2,new_v_models[i])
  198.                 break;
  199.             }
  200.         }
  201.     }
  202.  
  203.     pev(id,pev_weaponmodel2,model,31)
  204.     for(i=0;i<p_modelsnum;i++)
  205.     {
  206.         if(equali(model,old_p_models[i]))
  207.         {
  208.             if(p_models_team[i]==team || !p_models_team[i])
  209.             {
  210.                 set_pev(id,pev_weaponmodel2,new_p_models[i])
  211.                 break;
  212.             }
  213.         }
  214.     }
  215.     return PLUGIN_CONTINUE
  216. }
  217.  
  218. public Sound_Hook(id,channel,sample[])
  219. {
  220.     if(!is_user_alive(id))
  221.     {
  222.         return FMRES_IGNORED
  223.     }
  224.     if(channel!=CHAN_WEAPON && channel!=CHAN_ITEM)
  225.     {
  226.         return FMRES_IGNORED
  227.     }
  228.  
  229.     static i, team
  230.  
  231.     team = get_user_team(id)
  232.  
  233.     for(i=0;i<soundsnum;i++)
  234.     {
  235.         if(equali(sample,old_sounds[i]))
  236.         {
  237.             if(sounds_team[i]==team || !sounds_team[i])
  238.             {
  239.                 engfunc(EngFunc_EmitSound,id,CHAN_WEAPON,new_sounds[i],1.0,ATTN_NORM,0,PITCH_NORM)
  240.                 return FMRES_SUPERCEDE
  241.             }
  242.         }
  243.     }
  244.     return FMRES_IGNORED
  245. }
  246.  
  247. public W_Model_Hook(ent,model[])
  248. {
  249.     if(!pev_valid(ent))
  250.     {
  251.         return FMRES_IGNORED
  252.     }
  253.     static i
  254.     for(i=0;i<w_modelsnum;i++)
  255.     {
  256.         if(equali(model,old_w_models[i]))
  257.         {
  258.             engfunc(EngFunc_SetModel,ent,new_w_models[i])
  259.             return FMRES_SUPERCEDE
  260.         }
  261.     }
  262.     return FMRES_IGNORED
  263. }
  264.  
  265. public newround()
  266. {
  267.     static ent, classname[8], model[32]
  268.     ent = engfunc(EngFunc_FindEntityInSphere,maxplayers,Float:{0.0,0.0,0.0},4800.0)
  269.     while(ent)
  270.     {
  271.         if(pev_valid(ent))
  272.         {
  273.             pev(ent,pev_classname,classname,7)
  274.             if(containi(classname,"armoury")!=-1)
  275.             {
  276.                 pev(ent,pev_model,model,31)
  277.                 W_Model_Hook(ent,model)
  278.             }
  279.         }
  280.         ent = engfunc(EngFunc_FindEntityInSphere,ent,Float:{0.0,0.0,0.0},4800.0)
  281.     }
  282. }
Thx man this work :D
Image

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 6 guests