hlmod.hu
https://hlmod.hu/

Segítség kérés - HIBÁS AWP LIMIT
https://hlmod.hu/viewtopic.php?f=9&t=27585
Oldal: 1 / 1

Szerző:  attila2660 [ 2017.04.16. 20:58 ]
Hozzászólás témája:  Segítség kérés - HIBÁS AWP LIMIT

Sziasztok! Olyan problémám lenne ennél a pluginnál --> viewtopic.php?f=101&t=13787 <-- hogy beteszem és beállítottam hogy 4v4-től engedélyezze az AWP használatát de 6v6-nál is azt írta hogy 4v4-től lehet awp-zni pedig már 6v6-volt. Mi lehet a baj? Esetleg más plugint ajánl valaki ami hasonló? Vagy itt is meglehet csak elnéztem valamit?

Szerző:  jokypapa [ 2017.04.26. 12:13 ]
Hozzászólás témája:  Re: Segítség kérés - HIBÁS AWP LIMIT

attila2660 írta:
Sziasztok! Olyan problémám lenne ennél a pluginnál --> viewtopic.php?f=101&t=13787 <-- hogy beteszem és beállítottam hogy 4v4-től engedélyezze az AWP használatát de 6v6-nál is azt írta hogy 4v4-től lehet awp-zni pedig már 6v6-volt. Mi lehet a baj? Esetleg más plugint ajánl valaki ami hasonló? Vagy itt is meglehet csak elnéztem valamit?


Gondolom kibukott volna már ha rossz lenne a plugin!
A többi cvar beállítottad? amxx.cfg-be beírtad a dolgokat?

Szerző:  attila2660 [ 2017.04.26. 12:29 ]
Hozzászólás témája:  Re: Segítség kérés - HIBÁS AWP LIMIT

Be, valaki letudná tesztelni hogy neki működik. Az ide feltoltott "AWP limit" plugin?

Szerző:  kengurumancs [ 2017.04.27. 20:09 ]
Hozzászólás témája:  Re: Segítség kérés - HIBÁS AWP LIMIT

Ha jól tudom rehlds-es szervered van..

Kód:
#define MIN_AWP         1 <--- hány AWP-t akarsz csapatonként. 


  1. #include <amxmodx>
  2. #include <reapi>
  3.  
  4. #define MIN_AWP         1  
  5. #define PERCENT_BY_ONLINE   20
  6.  
  7. new bool:g_bUseAwp[33];
  8. new g_iAwpOnTeam[any:TEAM_SPECTATOR];
  9.  
  10. public plugin_init()
  11. {
  12.     register_plugin("AWP Limit", "1.1", "neugomon");
  13.    
  14.     RegisterHookChain(RG_CSGameRules_RestartRound, "RestartRound_Pre", false);
  15.     RegisterHookChain(RG_CBasePlayer_HasRestrictItem, "HasRestrictItem_Pre", false);
  16.     RegisterHookChain(RG_CBasePlayer_RemovePlayerItem, "RemovePlayerItem_Post", true);
  17. }
  18.  
  19. #if AMXX_VERSION_NUM < 183
  20.     #define client_disconnected client_disconnect
  21. #endif 
  22. public client_disconnected(id)
  23. {
  24.     if(g_bUseAwp[id])
  25.     {
  26.         g_iAwpOnTeam[get_member(id, m_iTeam)]--;
  27.         g_bUseAwp[id] = false;
  28.     }
  29. }
  30.  
  31. public RestartRound_Pre()
  32. {
  33.     arrayset(g_iAwpOnTeam, 0, any:TEAM_SPECTATOR);
  34.     arrayset(g_bUseAwp, false, sizeof g_bUseAwp);
  35.    
  36.     new players[32], pnum;
  37.     get_players(players, pnum, "h");
  38.     for(new i; i < pnum; i++)
  39.     {
  40.         if(get_entvar(players[i], var_weapons) & WEAPON_AWP)
  41.         {
  42.             switch(get_member(players[i], m_iTeam))
  43.             {
  44.                 case TEAM_TERRORIST:
  45.                     g_iAwpOnTeam[TEAM_TERRORIST]++;
  46.                 case TEAM_CT:
  47.                     g_iAwpOnTeam[TEAM_CT]++;
  48.                 default: continue;
  49.             }
  50.             g_bUseAwp[players[i]] = true;
  51.         }
  52.     }
  53.    
  54.     new limit;
  55.    
  56.     limit = GetLimit(get_member_game(m_iNumTerrorist));
  57.     if(g_iAwpOnTeam[TEAM_TERRORIST] > limit)
  58.         RemoveAwpForTeam(TEAM_TERRORIST, limit, "TERRORIST");
  59.    
  60.     limit = GetLimit(get_member_game(m_iNumCT));
  61.     if(g_iAwpOnTeam[TEAM_CT] > limit)
  62.         RemoveAwpForTeam(TEAM_CT, limit, "CT");
  63. }
  64.  
  65. public HasRestrictItem_Pre(const id, const ItemID:item, ItemRestType:type)
  66. {
  67.     if(item == ITEM_AWP)
  68.     {
  69.         new playersnum, team = get_member(id, m_iTeam);
  70.        
  71.         switch(team)
  72.         {
  73.             case TEAM_TERRORIST:
  74.                 playersnum = get_member_game(m_iNumTerrorist);
  75.             case TEAM_CT:
  76.                 playersnum = get_member_game(m_iNumCT);
  77.             default:return HC_CONTINUE;
  78.         }
  79.  
  80.         if(g_iAwpOnTeam[team] >= GetLimit(playersnum))
  81.         {
  82.             client_print(id, print_center, "* Use AWP denied! *");
  83.  
  84.             SetHookChainReturn(ATYPE_INTEGER, 1);
  85.             return HC_SUPERCEDE;
  86.         }
  87.         else if(!g_bUseAwp[id])
  88.         {
  89.             g_iAwpOnTeam[team]++;
  90.             g_bUseAwp[id] = true;
  91.         }
  92.     }
  93.     return HC_CONTINUE;
  94. }
  95.  
  96. public RemovePlayerItem_Post(const id, const pItem)
  97. {
  98.     if(g_bUseAwp[id])
  99.     {
  100.         if(~get_entvar(id, var_weapons) & WEAPON_AWP)
  101.         {
  102.             new team = get_member(id, m_iTeam);
  103.             g_iAwpOnTeam[team]--;
  104.             g_bUseAwp[id] = false;     
  105.         }
  106.     }  
  107. }
  108.  
  109. stock RemoveAwpForTeam(TeamName:team, limit, teamName[])
  110. {
  111.     new players[32], pnum, rand;
  112.     get_players(players, pnum, "eh", teamName);
  113.     while(g_iAwpOnTeam[team] > limit)
  114.     {
  115.         rand = random(pnum - 1);
  116.         if(get_entvar(players[rand], var_weapons) & WEAPON_AWP)
  117.         {
  118.             rg_remove_item(players[rand], "weapon_awp");
  119.             g_bUseAwp[players[rand]] = false;
  120.             g_iAwpOnTeam[team]--;
  121.         }
  122.     }
  123. }
  124.  
  125. stock GetLimit(playersnum)
  126. {
  127.     new limit = floatround(playersnum * PERCENT_BY_ONLINE / 100.0);
  128.     if(limit < MIN_AWP)
  129.         limit = MIN_AWP;
  130.     return limit;
  131. }

Szerző:  dumbass1116 [ 2017.04.27. 20:15 ]
Hozzászólás témája:  Re: Segítség kérés - HIBÁS AWP LIMIT

kengurumancs írta:
Ha jól tudom rehlds-es szervered van..

Kód:
#define MIN_AWP         1 <--- hány AWP-t akarsz csapatonként.


  1. #include <amxmodx>
  2. #include <reapi>
  3.  
  4. #define MIN_AWP         1  
  5. #define PERCENT_BY_ONLINE   20
  6.  
  7. new bool:g_bUseAwp[33];
  8. new g_iAwpOnTeam[any:TEAM_SPECTATOR];
  9.  
  10. public plugin_init()
  11. {
  12.     register_plugin("AWP Limit", "1.1", "neugomon");
  13.    
  14.     RegisterHookChain(RG_CSGameRules_RestartRound, "RestartRound_Pre", false);
  15.     RegisterHookChain(RG_CBasePlayer_HasRestrictItem, "HasRestrictItem_Pre", false);
  16.     RegisterHookChain(RG_CBasePlayer_RemovePlayerItem, "RemovePlayerItem_Post", true);
  17. }
  18.  
  19. #if AMXX_VERSION_NUM < 183
  20.     #define client_disconnected client_disconnect
  21. #endif 
  22. public client_disconnected(id)
  23. {
  24.     if(g_bUseAwp[id])
  25.     {
  26.         g_iAwpOnTeam[get_member(id, m_iTeam)]--;
  27.         g_bUseAwp[id] = false;
  28.     }
  29. }
  30.  
  31. public RestartRound_Pre()
  32. {
  33.     arrayset(g_iAwpOnTeam, 0, any:TEAM_SPECTATOR);
  34.     arrayset(g_bUseAwp, false, sizeof g_bUseAwp);
  35.    
  36.     new players[32], pnum;
  37.     get_players(players, pnum, "h");
  38.     for(new i; i < pnum; i++)
  39.     {
  40.         if(get_entvar(players[i], var_weapons) & WEAPON_AWP)
  41.         {
  42.             switch(get_member(players[i], m_iTeam))
  43.             {
  44.                 case TEAM_TERRORIST:
  45.                     g_iAwpOnTeam[TEAM_TERRORIST]++;
  46.                 case TEAM_CT:
  47.                     g_iAwpOnTeam[TEAM_CT]++;
  48.                 default: continue;
  49.             }
  50.             g_bUseAwp[players[i]] = true;
  51.         }
  52.     }
  53.    
  54.     new limit;
  55.    
  56.     limit = GetLimit(get_member_game(m_iNumTerrorist));
  57.     if(g_iAwpOnTeam[TEAM_TERRORIST] > limit)
  58.         RemoveAwpForTeam(TEAM_TERRORIST, limit, "TERRORIST");
  59.    
  60.     limit = GetLimit(get_member_game(m_iNumCT));
  61.     if(g_iAwpOnTeam[TEAM_CT] > limit)
  62.         RemoveAwpForTeam(TEAM_CT, limit, "CT");
  63. }
  64.  
  65. public HasRestrictItem_Pre(const id, const ItemID:item, ItemRestType:type)
  66. {
  67.     if(item == ITEM_AWP)
  68.     {
  69.         new playersnum, team = get_member(id, m_iTeam);
  70.        
  71.         switch(team)
  72.         {
  73.             case TEAM_TERRORIST:
  74.                 playersnum = get_member_game(m_iNumTerrorist);
  75.             case TEAM_CT:
  76.                 playersnum = get_member_game(m_iNumCT);
  77.             default:return HC_CONTINUE;
  78.         }
  79.  
  80.         if(g_iAwpOnTeam[team] >= GetLimit(playersnum))
  81.         {
  82.             client_print(id, print_center, "* Use AWP denied! *");
  83.  
  84.             SetHookChainReturn(ATYPE_INTEGER, 1);
  85.             return HC_SUPERCEDE;
  86.         }
  87.         else if(!g_bUseAwp[id])
  88.         {
  89.             g_iAwpOnTeam[team]++;
  90.             g_bUseAwp[id] = true;
  91.         }
  92.     }
  93.     return HC_CONTINUE;
  94. }
  95.  
  96. public RemovePlayerItem_Post(const id, const pItem)
  97. {
  98.     if(g_bUseAwp[id])
  99.     {
  100.         if(~get_entvar(id, var_weapons) & WEAPON_AWP)
  101.         {
  102.             new team = get_member(id, m_iTeam);
  103.             g_iAwpOnTeam[team]--;
  104.             g_bUseAwp[id] = false;     
  105.         }
  106.     }  
  107. }
  108.  
  109. stock RemoveAwpForTeam(TeamName:team, limit, teamName[])
  110. {
  111.     new players[32], pnum, rand;
  112.     get_players(players, pnum, "eh", teamName);
  113.     while(g_iAwpOnTeam[team] > limit)
  114.     {
  115.         rand = random(pnum - 1);
  116.         if(get_entvar(players[rand], var_weapons) & WEAPON_AWP)
  117.         {
  118.             rg_remove_item(players[rand], "weapon_awp");
  119.             g_bUseAwp[players[rand]] = false;
  120.             g_iAwpOnTeam[team]--;
  121.         }
  122.     }
  123. }
  124.  
  125. stock GetLimit(playersnum)
  126. {
  127.     new limit = floatround(playersnum * PERCENT_BY_ONLINE / 100.0);
  128.     if(limit < MIN_AWP)
  129.         limit = MIN_AWP;
  130.     return limit;
  131. }

Köszönöm.:)

Oldal: 1 / 1 Minden időpont UTC+02:00 időzóna szerinti
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/