银闪闪 发表于 2010-12-23 20:14:04

请问这是哪里的错误?谢谢

加截限制AWP的插件,大约每十秒中就有错误报告,经常造成服务器重启,请达人帮忙看看,谢谢!

以下是错误logs

L 12/23/2010 - 19:55:41: Run time error 4: index out of bounds
L 12/23/2010 - 19:55:41:     awplimitnowin.sma::client_connect (line 128)
L 12/23/2010 - 19:55:47: Displaying debug trace (plugin "awplimitnowin.amxx")
L 12/23/2010 - 19:55:47: Run time error 4: index out of bounds
L 12/23/2010 - 19:55:47:     awplimitnowin.sma::check_winning_team (line 163)
L 12/23/2010 - 19:56:26: Displaying debug trace (plugin "awplimitnowin.amxx")
L 12/23/2010 - 19:56:26: Run time error 4: index out of bounds
L 12/23/2010 - 19:56:26:     awplimitnowin.sma::check_winning_team (line 163)
L 12/23/2010 - 19:56:40: Displaying debug trace (plugin "awplimitnowin.amxx")
L 12/23/2010 - 19:56:40: Run time error 4: index out of bounds
L 12/23/2010 - 19:56:40:     awplimitnowin.sma::handle_death (line 115)
L 12/23/2010 - 19:56:43: Displaying debug trace (plugin "awplimitnowin.amxx")
L 12/23/2010 - 19:56:43: Run time error 4: index out of bounds
L 12/23/2010 - 19:56:43:     awplimitnowin.sma::client_disconnect (line 136)
L 12/23/2010 - 19:56:43: Displaying debug trace (plugin "awplimitnowin.amxx")
L 12/23/2010 - 19:56:43: Run time error 4: index out of bounds
L 12/23/2010 - 19:56:43:     awplimitnowin.sma::client_connect (line 128)
L 12/23/2010 - 19:56:46: Displaying debug trace (plugin "awplimitnowin.amxx")
L 12/23/2010 - 19:56:46: Run time error 4: index out of bounds
L 12/23/2010 - 19:56:46:     awplimitnowin.sma::check_winning_team (line 163)
L 12/23/2010 - 19:56:48: Displaying debug trace (plugin "awplimitnowin.amxx")
L 12/23/2010 - 19:56:48: Run time error 4: index out of bounds
L 12/23/2010 - 19:56:48:     awplimitnowin.sma::check_winning_team (line 163)
L 12/23/2010 - 19:56:56: Displaying debug trace (plugin "awplimitnowin.amxx")
L 12/23/2010 - 19:56:56: Run time error 4: index out of bounds

--------------------------------------分割线--------------------------

以下是我用的源码

/* AMX Mod script.
*
* Drop AWP with Team Limit and Win limit 0.4 (CS 1.6)
* By SuicideDog
*
* Modded orignal from JustinHoMi
*
* Allows no more than "X" (MAXAWPS) awps per team.
* If on winning team (WINSPREAD), then no AWP
*
*/

#include <amxmodx>

#define MAXAWPS 2 // number of awps a team can have
#define WINSPREAD 50 // the difference when it starts restricting awps for winning team

new plist = { 0, ... }   // 0 = no awp; 1 = carrying awp
new awp_count         // 1 = T; 2 = CT
new ctscore = 0
new tscore = 0

/* handles restricting the menu */
public menu_awp(id,key) {
   if (get_cvar_num("awplimit")!=1) return PLUGIN_CONTINUE
   new team = get_user_team(id)
   
   if((team == 2 && ctscore-tscore >= WINSPREAD) || (team == 1 && tscore-ctscore >= WINSPREAD))
   {
      engclient_cmd(id,"menuselect","10")
      client_print(id,print_center,"You are on the winning team and cannot use AWP's")
      return PLUGIN_HANDLED
   }
   
   if(awp_count >= MAXAWPS)
   {
      
      engclient_cmd(id,"menuselect","10")
      client_print(id,print_center,"Too many people on your team have AWP's")
      return PLUGIN_HANDLED
   }
   return PLUGIN_CONTINUE
}

/* handles if they script the AWP buy*/
public cmdawp(id)
{
   if (get_cvar_num("awplimit")!=1) return PLUGIN_CONTINUE
   new team = get_user_team(id)
   
   if((team == 2 && ctscore-tscore >= WINSPREAD) || (team == 1 && tscore-ctscore >= WINSPREAD))
   {
      client_print(id,print_center,"You are on the winning team and cannot use AWP's")
      return PLUGIN_HANDLED
   }
   
   if(awp_count >= MAXAWPS)
   {
      client_print(id,print_center,"Too many people on your team have AWP's")
      return PLUGIN_HANDLED
   }
   return PLUGIN_CONTINUE
}

/* handles when a player drops their weapon */
public handle_drop(id) {
   if (get_cvar_num("awplimit")!=1) return PLUGIN_CONTINUE
   if (plist == 1)
   {
      new tmp1,tmp2
      new curweapon = get_user_weapon(id,tmp1,tmp2)

      if (curweapon == 18)
      {
         plist = 0
         new team = get_user_team(id)
         awp_count--
      }
   }
   return PLUGIN_CONTINUE
}

/* handles when a player picks up an awp */
public handle_pickup(id) {

   if (get_cvar_num("awplimit")!=1) return PLUGIN_CONTINUE
   new team = get_user_team(id)

   if((team == 2 && ctscore-tscore >= WINSPREAD) || (team == 1 && tscore-ctscore >= WINSPREAD))
   {
      client_print(id,print_center,"You are on the winning team and cannot use AWP's")
      client_cmd(id,"weapon_awp;wait;wait;wait;drop")
      return PLUGIN_CONTINUE      
   }

   if (awp_count >= MAXAWPS)
   {
      client_print(id,print_center,"Too many people on your team have AWP's")
      client_cmd(id,"weapon_awp;wait;wait;wait;drop")
      return PLUGIN_CONTINUE      
   }
   else
   {
      plist = 1
      awp_count++
   }
   return PLUGIN_CONTINUE
}

/* removes awp when player dies */
public handle_death() {
   if (get_cvar_num("awplimit")!=1) return PLUGIN_CONTINUE
   new idx = read_data(2)

   if(plist == 1)
   {
      new team = get_user_team(idx)
      awp_count--

      plist = 0
   }
   return PLUGIN_CONTINUE
}

/* clear vars when player connects */
public client_connect(id) {
   if (get_cvar_num("awplimit")!=1) return PLUGIN_CONTINUE
   plist = 0 // just to make sure
   return PLUGIN_CONTINUE
}

/* clear vars when player disconnects */
public client_disconnect(id) {

   if (get_cvar_num("awplimit")!=1) return PLUGIN_CONTINUE
   if (plist == 1)
   {
      new team = get_user_team(id)
      awp_count--
   }
   plist = 0
   return PLUGIN_CONTINUE
}

public team_score()
{
   if (get_cvar_num("awplimit")!=1) return PLUGIN_CONTINUE
   new team
   read_data(1,team,32)

   if (equal(team,"CT")){
      ctscore = read_data(2)
   }
   else if (equal(team,"TERRORIST")){
      tscore = read_data(2)
   }
   return PLUGIN_CONTINUE
}

public check_winning_team(id)
{
   if (get_cvar_num("awplimit")!=1) return PLUGIN_CONTINUE
   if (plist == 1)
   {
      new team = get_user_team(id)
   
      if((team == 2 && ctscore-tscore >= WINSPREAD) || (team == 1 && tscore-ctscore >= WINSPREAD))
      {
         client_print(id,print_center,"You are on the winning team and cannot use AWP's")
         client_cmd(id,"weapon_awp;wait;wait;wait;drop")
         return PLUGIN_CONTINUE
      }
   }
   return PLUGIN_CONTINUE
}

public plugin_init(){
    register_plugin("AWP Limit (Team/Win)","0.5","SuicideDog")
    register_menucmd(-31,1<<5,"menu_awp")
    register_clcmd("drop","handle_drop")
    register_clcmd("awp","cmdawp")
    register_cvar("awplimit","1")
    register_event("TeamScore", "team_score", "a")
    register_event("WeapPickup","handle_pickup","b","1=18")
    register_event("DeathMsg","handle_death","a")
    register_event("ResetHUD","check_winning_team","b")
    return PLUGIN_CONTINUE
}

心静如水 发表于 2010-12-23 21:10:48

参考以下


#include <amxmodx>
#include <fakemeta>

new plist = { 0, ... }   // 0 = no awp; 1 = carrying awp
new plist2 = {0, ... }   // 0 = no auto; 1 = carrying auto
new awp_count         // 1 = T; 2 = CT
new auto_count      // 1 = T; 2 = CT
new ctscore = 0
new tscore = 0
new pl_team

/* PCvars */
new pv_awplimit
new pv_max_awps
new pv_winspread_awp
new pv_autolimit
new pv_max_autos
new pv_winspread_auto
new pv_checkrebuy
new pv_minplayers

/* handles restricting the menu */
public menu_awp(id,key)
{
        if (get_pcvar_num(pv_awplimit) != 1) return PLUGIN_CONTINUE
       
        new team = get_user_team(id)
        new winspread_awp = get_pcvar_num(pv_winspread_awp)
        new min_players = get_pcvar_num(pv_minplayers)
        new team1_num, team2_num
        new players

        get_players(players,team1_num,"e","TERRORIST")
        get_players(players,team2_num,"e","CT")

        if ((team1_num < min_players) || (team2_num < min_players))
        {
                engclient_cmd(id,"menuselect","10")
                client_print(id,print_center,"Not enough people in one team to allow AWP's.")
                return PLUGIN_HANDLED
        }

        if (((team == 2 && ctscore-tscore >= winspread_awp) || (team == 1 && tscore-ctscore >= winspread_awp))
                && winspread_awp)
        {
                engclient_cmd(id,"menuselect","10")
                client_print(id,print_center,"You are on the winning team and cannot use AWP's")
                return PLUGIN_HANDLED
        }

        if (awp_count >= get_pcvar_num(pv_max_awps))
        {
                engclient_cmd(id,"menuselect","10")
                client_print(id,print_center,"Too many people on your team have AWP's")
                return PLUGIN_HANDLED
        }

        return PLUGIN_CONTINUE
}

/* handles restricting the menu */
public menu_auto(id,key)
{
        if (get_pcvar_num(pv_autolimit) != 1) return PLUGIN_CONTINUE

        new team = get_user_team(id)
        new winspread_auto = get_pcvar_num(pv_winspread_auto)
        new min_players = get_pcvar_num(pv_minplayers)
        new team1_num, team2_num
        new players

        get_players(players,team1_num,"e","TERRORIST")
        get_players(players,team2_num,"e","CT")

        if ((team1_num < min_players) || (team2_num < min_players))
        {
                engclient_cmd(id,"menuselect","10")
                client_print(id,print_center,"Not enough people in one team to allow AUTO's.")
                return PLUGIN_HANDLED
        }

        if (((team == 2 && ctscore-tscore >= winspread_auto) || (team == 1 && tscore-ctscore >= winspread_auto))
                && winspread_auto)
        {
                engclient_cmd(id,"menuselect","10")
                client_print(id,print_center,"You are on the winning team and cannot use AUTO's")
                return PLUGIN_HANDLED
        }

        if (auto_count >= get_pcvar_num(pv_max_autos))
        {
                engclient_cmd(id,"menuselect","10")
                client_print(id,print_center,"Too many people on your team have AUTO's")
                return PLUGIN_HANDLED
        }

        return PLUGIN_CONTINUE
}

/* handles if they script the AWP buy*/
public cmdawp(id)
{
        if (get_pcvar_num(pv_awplimit) != 1) return PLUGIN_CONTINUE

        new team = get_user_team(id)

        if ((team < 1) || (team > 2)) return PLUGIN_CONTINUE

        new winspread_awp = get_pcvar_num(pv_winspread_awp)
        new name
        get_user_name(id,name,31)
        new min_players = get_pcvar_num(pv_minplayers)
        new team1_num, team2_num
        new players

        get_players(players,team1_num,"e","TERRORIST")
        get_players(players,team2_num,"e","CT")

        if ((team1_num < min_players) || (team2_num < min_players))
        {
                engclient_cmd(id,"menuselect","10")
                client_print(id,print_center,"Not enough people in one team to allow AWP's.")
                return PLUGIN_HANDLED
        }

        if (((team == 2 && ctscore-tscore >= winspread_awp) || (team == 1 && tscore-ctscore >= winspread_awp))
                && winspread_awp)
        {
                client_print(id,print_center,"You are on the winning team and cannot use AWP's")
                return PLUGIN_HANDLED
   }

        if (awp_count >= get_pcvar_num(pv_max_awps))
        {
                client_print(id,print_center,"Too many people on your team have AWP's")
//                client_print(id,print_chat,"You are about to buy an awp. There was currently %d awps in Your team %d - too many to buy.", awp_count, team)
//                log_message("The player %s was about to buy an awp. There was %d awps in his team %d - too many to buy.", name, awp_count, team)
                return PLUGIN_HANDLED
        }
//        client_print(id,print_chat,"You are about to buy an awp. There was currently %d awps in Your team before You bought it.", awp_count)
//        log_message("The player %s is about to buy an awp. There was %d awps in his team %d before he bought it.", name, awp_count, team)
       
        return PLUGIN_CONTINUE
}

/* handles if they script the AUTO buy*/
public cmdauto(id)
{
        if (get_pcvar_num(pv_autolimit) != 1) return PLUGIN_CONTINUE

        new team = get_user_team(id)
        new winspread_auto = get_pcvar_num(pv_winspread_auto)
        new min_players = get_pcvar_num(pv_minplayers)
        new team1_num, team2_num
        new players

        get_players(players,team1_num,"e","TERRORIST")
        get_players(players,team2_num,"e","CT")

        if ((team1_num < min_players) || (team2_num < min_players))
        {
                engclient_cmd(id,"menuselect","10")
                client_print(id,print_center,"Not enough people in one team to allow AUTO's.")
                return PLUGIN_HANDLED
        }

        if (((team == 2 && ctscore-tscore >= winspread_auto) || (team == 1 && tscore-ctscore >= winspread_auto))
                && winspread_auto)
        {
                client_print(id,print_center,"You are on the winning team and cannot use AUTO's")
                return PLUGIN_HANDLED
        }

        if (auto_count >= get_pcvar_num(pv_max_autos))
        {
                client_print(id,print_center,"Too many people on your team have AUTO's")
                return PLUGIN_HANDLED
        }
        return PLUGIN_CONTINUE
}

/* handles when a player drops his weapon */
public handle_drop_weapon(id)
{
        new tmp1,tmp2
        new curweapon = get_user_weapon(id,tmp1,tmp2)
        new team = get_user_team(id)
       
/* handles when a player drops their awp */       
        if (curweapon == CSW_AWP)
        {
                if (get_pcvar_num(pv_awplimit) != 1)
                        return PLUGIN_CONTINUE

                if ((plist==1) && (awp_count > 0))
                        awp_count--
                plist = 0                       
                return PLUGIN_CONTINUE
   }
/* handles when a player drops his auto */
        else if ((curweapon == CSW_SG550) || (curweapon == CSW_G3SG1))
        {
                if (get_pcvar_num(pv_autolimit) != 1)
                        return PLUGIN_CONTINUE

                if ((plist2==1) && (auto_count > 0))
                        auto_count--
                plist2 = 0
                return PLUGIN_CONTINUE
   }
        return PLUGIN_CONTINUE
}


/* handles when a player picks up an awp */
public handle_pickup_awp(id)
{
        if (get_pcvar_num(pv_awplimit) != 1) return PLUGIN_CONTINUE

        new team = get_user_team(id)
        new winspread_awp = get_pcvar_num(pv_winspread_awp)
        new name
        get_user_name(id,name,31)
        new min_players = get_pcvar_num(pv_minplayers)
        new team1_num, team2_num
        new players

        get_players(players,team1_num,"e","TERRORIST")
        get_players(players,team2_num,"e","CT")

        if ((team1_num < min_players) || (team2_num < min_players))
        {
                set_task(0.5, "drop_awp", id)
                client_print(id,print_center,"Not enough people in one team to allow AWP's.")
                return PLUGIN_CONTINUE
        }

        if (((team == 2 && ctscore-tscore >= winspread_awp) || (team == 1 && tscore-ctscore >= winspread_awp))
                && winspread_awp)
        {
                client_print(id,print_center,"You are on the winning team and cannot use AWP's")
                set_task(0.5, "drop_awp", id)
                return PLUGIN_CONTINUE
   }

        if (awp_count >= get_pcvar_num(pv_max_awps))
   {
                client_print(id,print_center,"Too many people on your team have AWP's")
//                log_message("The player %s bought or picked-up an awp. There is %d awps in his %d team. He should drop it.", name, awp_count, team)
                set_task(0.5, "drop_awp", id)
//                engclient_cmd(id, "drop", "weapon_awp")
//                client_cmd(id,"weapon_awp;wait;wait;wait;drop")
                return PLUGIN_CONTINUE
        }
        else
        {
                plist = 1
                awp_count++
//                client_print(id,print_chat,"You have bought or picked-up an awp. There is %d awps in Your team.", awp_count)
//                log_message("The player %s bought or picked-up an awp. There is %d awps in his team %d.", name, awp_count, team)
        }
        return PLUGIN_CONTINUE
}

public drop_awp(id)
{
        new team

        if (!is_user_connected(id)) return

        engclient_cmd(id, "drop", "weapon_awp")

        if (is_user_bot(id)) // we cannot hook when the bot drops his weapon
        {
                team = get_user_team(id)
                plist = 0
                if (awp_count > 0)
                        awp_count--
        }
}

/* handles when a player picks up a g3sg1 */
public handle_pickup_g3sg1(id)
{
        if (get_pcvar_num(pv_autolimit) != 1) return PLUGIN_CONTINUE

        new team = get_user_team(id)
        new winspread_auto = get_pcvar_num(pv_winspread_auto)
        new min_players = get_pcvar_num(pv_minplayers)
        new team1_num, team2_num
        new players

        get_players(players,team1_num,"e","TERRORIST")
        get_players(players,team2_num,"e","CT")

        if ((team1_num < min_players) || (team2_num < min_players))
        {
                client_print(id,print_center,"Not enough people in one team to allow AUTO's.")
                set_task(0.5, "drop_g3sg1", id)
                return PLUGIN_CONTINUE
        }

        if (((team == 2 && ctscore-tscore >= winspread_auto) || (team == 1 && tscore-ctscore >= winspread_auto))
                && winspread_auto)
        {
                client_print(id,print_center,"You are on the winning team and cannot use AUTO's")
                set_task(0.5, "drop_g3sg1", id)
                return PLUGIN_CONTINUE
        }

        if (auto_count >= get_pcvar_num(pv_max_autos))
        {
                client_print(id,print_center,"Too many people on your team have AUTO's")
                set_task(0.5, "drop_g3sg1", id)
                return PLUGIN_CONTINUE
        }
        else
        {
                plist2 = 1
                auto_count++
        }
        return PLUGIN_CONTINUE
}

心静如水 发表于 2010-12-23 21:12:33

public drop_g3sg1(id)
{
        new team

        if (!is_user_connected(id)) return

        engclient_cmd(id, "drop", "weapon_g3sg1")

        if (is_user_bot(id)) // we cannot hook when the bot drops his weapon
        {
                team = get_user_team(id)
                plist2 = 0
                if (auto_count > 0)
                        auto_count--
        }
}

/* handles when a player picks up a sg550 */
public handle_pickup_sg550(id)
{
        if (get_pcvar_num(pv_autolimit) != 1) return PLUGIN_CONTINUE

        new team = get_user_team(id)
        new winspread_auto = get_pcvar_num(pv_winspread_auto)
        new min_players = get_pcvar_num(pv_minplayers)
        new team1_num, team2_num
        new players

        get_players(players,team1_num,"e","TERRORIST")
        get_players(players,team2_num,"e","CT")

        if ((team1_num < min_players) || (team2_num < min_players))
        {
                client_print(id,print_center,"Not enough people in one team to allow AUTO's.")
                set_task(0.5, "drop_sg550", id)
                return PLUGIN_CONTINUE
        }

        if (((team == 2 && ctscore-tscore >= winspread_auto) || (team == 1 && tscore-ctscore >= winspread_auto))
                && winspread_auto)
        {
                client_print(id,print_center,"You are on the winning team and cannot use AUTO's")
                set_task(0.5, "drop_sg550", id)
                return PLUGIN_CONTINUE
        }

        if (auto_count >= get_pcvar_num(pv_max_autos))
        {
                client_print(id,print_center,"Too many people on your team have AUTO's")
                set_task(0.5, "drop_sg550", id)
                return PLUGIN_CONTINUE
        }
        else
        {
                plist2 = 1
                auto_count++
        }
        return PLUGIN_CONTINUE
}

public drop_sg550(id)
{
        new team

        if (!is_user_connected(id)) return

        engclient_cmd(id, "drop", "weapon_sg550")

        if (is_user_bot(id)) // we cannot hook when the bot drops his weapon
        {
                team = get_user_team(id)
                plist2 = 0
                if (auto_count > 0)
                        auto_count--
        }
}

/* removes awp and auto when player dies */
public handle_death()
{
        if ((get_pcvar_num(pv_awplimit) != 1) && (get_pcvar_num(pv_autolimit) != 1))
                return PLUGIN_CONTINUE

        new idx = read_data(2)
       
        if (plist == 1)
        {
                new team = get_user_team(idx)
                if (awp_count > 0)
                        awp_count--
                plist = 0
        }
        if (plist2 == 1)
        {
                new team = get_user_team(idx)
                if (auto_count > 0)
                        auto_count--
                plist2 = 0
        }
        return PLUGIN_CONTINUE
}

/* clear vars when player connects */
public client_connect(id)
{
        plist = 0
        plist2 = 0
        return PLUGIN_CONTINUE
}

/* clear vars when player disconnects */
public client_disconnect(id)
{
        if (plist == 1)
        {
                new team = get_user_team(id)
                if (awp_count > 0)
                        awp_count--
        }
        if (plist2 == 1)
        {
                new team = get_user_team(id)
                if (auto_count > 0)
                        auto_count--
        }
        plist = 0
        plist2 = 0

        return PLUGIN_CONTINUE
}

public team_score()
{
        if ((get_pcvar_num(pv_awplimit) != 1) && (get_pcvar_num(pv_autolimit) != 1))
                return PLUGIN_CONTINUE

        new team
        read_data(1,team,32)

        if (equal(team,"CT"))
        {
                ctscore = read_data(2)
        }
        else if (equal(team,"TERRORIST"))
        {
                tscore = read_data(2)
        }
        return PLUGIN_CONTINUE
}

public check_winning_team(id)
{
        if ((get_pcvar_num(pv_awplimit) != 1) && (get_pcvar_num(pv_autolimit) != 1)) return PLUGIN_CONTINUE
        if (!id || id > get_maxplayers()) return PLUGIN_CONTINUE
       
        new team = get_user_team(id)
        if (plist == 1)
        {
                new winspread_awp = get_pcvar_num(pv_winspread_awp)
                if (((team == 2 && ctscore-tscore >= winspread_awp) || (team == 1 && tscore-ctscore >= winspread_awp))
                        && winspread_awp)
                {
                        client_print(id,print_center,"You are on the winning team and cannot use AWP's")
                        engclient_cmd(id, "drop", "weapon_awp")
                        return PLUGIN_CONTINUE
                }
                return PLUGIN_CONTINUE
        }
        if (plist2 == 1)
        {
                new winspread_auto = get_pcvar_num(pv_winspread_auto)
                if (((team == 2 && ctscore-tscore >= winspread_auto) || (team == 1 && tscore-ctscore >= winspread_auto))
                        && winspread_auto)
                {
                        client_print(id,print_center,"You are on the winning team and cannot use AUTO's")
                        new iwpn, iwpns, nwpn
                        get_user_weapons(id, iwpns, iwpn)
                        for (new a = 0; a < iwpn; ++a)
                        {
                                get_weaponname(iwpns, nwpn, 31)
                                if (equali(nwpn,"weapon_g3sg1") || equali(nwpn,"weapon_sg550"))
                                        engclient_cmd(id, "drop", nwpn)
                        }
                        return PLUGIN_CONTINUE
                }
                return PLUGIN_CONTINUE
        }
        return PLUGIN_CONTINUE
}


/*
* 1 = T's: AWP Key 4, AUTOSNIPER Key 5
* 2 = CT's: AWP Key 5, AUTOSNIPER Key 4
*/
public via_me(id,key)
{
        new team = get_user_team(id)

        if ((team==1 && key==5) || (team==2 && key==4))
                menu_auto(id, key)
        if ((team==1 && key==4) || (team==2 && key==5))
                menu_awp(id, key)

        return PLUGIN_CONTINUE
}

public check_rebuy(id)
{
        if (get_pcvar_num(pv_checkrebuy) != 1) return PLUGIN_CONTINUE
        client_print(id,print_center,"Sorry Rebuy command is blocked on this server")

        return PLUGIN_HANDLED
}

public total_snipers()
{
        new players, numPlayerCount, idxPlayer
       
        // 1 = T; 2 = CT
        awp_count = 0
        auto_count = 0

        get_players(players, numPlayerCount,"he","TERRORIST")
        for(idxPlayer = 0; idxPlayer < numPlayerCount; idxPlayer++)
        {
                new Weapons
                new numWeapons, i
                get_user_weapons(players, Weapons, numWeapons)
                plist] = 0
                plist2] = 0
                for (i=0; i<numWeapons; i++)
                {
                        if (Weapons == CSW_AWP)
                        {
                                plist] = 1
                                awp_count++
                        }
                        if ((Weapons == CSW_G3SG1) || (Weapons == CSW_SG550))
                        {
                                plist2] = 1
                                auto_count++
                        }
                }
        }

        awp_count = 0
        auto_count = 0
       
        get_players(players, numPlayerCount,"he","CT")
        for(idxPlayer = 0; idxPlayer < numPlayerCount; idxPlayer++)
        {
                new Weapons
                new numWeapons, i
                get_user_weapons(players, Weapons, numWeapons)
                plist] = 0
                plist2] = 0               
                for (i=0; i<numWeapons; i++)
                {
                        if (Weapons == CSW_AWP)
                        {
                                plist] = 1
                                awp_count++
                        }
                        if ((Weapons == CSW_G3SG1) || (Weapons == CSW_SG550))
                        {
                                plist2] = 1
                                auto_count++
                        }
                }
        }
}

public round_start()
{
        total_snipers()
        return PLUGIN_CONTINUE
}

心静如水 发表于 2010-12-23 21:13:54

public hook_touch(ptr, ptd)
{
        static ptrClass
        static ptdClass
        static ptrModel
        static team
        static min_players
        static team1_num, team2_num
        static players
        static winspread_auto

        if ((get_pcvar_num(pv_awplimit) != 1) && (get_pcvar_num(pv_autolimit) != 1))
                return PLUGIN_CONTINUE

        if (ptd > get_maxplayers() || ptd < 1 || ptr < 1 )
                return PLUGIN_CONTINUE
               
        if ( (!pev_valid(ptr)) || (!pev_valid(ptd)) )
                return PLUGIN_CONTINUE

        if (!is_user_connected(ptd))
                return PLUGIN_CONTINUE

        pev(ptr, pev_classname, ptrClass, 31)
        pev(ptr, pev_model, ptrModel, 127)
        pev(ptd, pev_classname, ptdClass, 31)
       
        if (!equal(ptrClass, "weaponbox"))
                return PLUGIN_CONTINUE
       
        if (equal(ptdClass, "player"))
        {
                team = get_user_team(ptd)
                min_players = get_pcvar_num(pv_minplayers)
                get_players(players,team1_num,"e","TERRORIST")
                get_players(players,team2_num,"e","CT")
               
                if (equal(ptrModel, "models/w_awp.mdl"))
                {
                        if ((team1_num < min_players) || (team2_num < min_players))
                        {
                                client_print(ptd,print_center,"Not enough people in one team to allow AWP's.")
                                return FMRES_SUPERCEDE
                        }

                        if (awp_count >= get_pcvar_num(pv_max_awps))
                        {
                                client_print(ptd,print_center,"Too many people on your team have AWP's")
                                return FMRES_SUPERCEDE
                        }

                        new winspread_awp = get_pcvar_num(pv_winspread_awp)
                        if (((team == 2 && ctscore-tscore >= winspread_awp) || (team == 1 && tscore-ctscore >= winspread_awp))
                                && winspread_awp)
                        {
                                client_print(ptd,print_center,"You are on the winning team and cannot use AWP's")
                                return FMRES_SUPERCEDE
                        }

                        return PLUGIN_CONTINUE
                }
                if ((equal(ptrModel, "models/w_g3sg1.mdl")) || (equal(ptrModel, "models/w_sg550.mdl")))
                {
                        if ((team1_num < min_players) || (team2_num < min_players))
                        {
                                client_print(ptd,print_center,"Not enough people in one team to allow AUTO's.")
                                return FMRES_SUPERCEDE
                        }

                        if (auto_count >= get_pcvar_num(pv_max_autos))
                        {
                                client_print(ptd,print_center,"Too many people on your team have AUTO's")
                                return FMRES_SUPERCEDE
                        }

                        winspread_auto = get_pcvar_num(pv_winspread_auto)
                        if (((team == 2 && ctscore-tscore >= winspread_auto) || (team == 1 && tscore-ctscore >= winspread_auto))
                                && winspread_auto)
                        {
                                client_print(ptd,print_center,"You are on the winning team and cannot use AUTO's")
                                return FMRES_SUPERCEDE
                        }
                        return PLUGIN_CONTINUE
                }
        }       
        return PLUGIN_CONTINUE
}

public team_assign()
{
        new arg, team
        new id = read_data(1)
        read_data(2,arg,1)
        if ( arg == 'C')
                team = 2
        else if ( arg == 'T' )
                team = 1
        else
                team = 0

        if (!is_user_connected(id) || !is_user_alive(id) || (!plist && !plist2)
                || (pl_team == team))
        {
                pl_team = team
                return PLUGIN_CONTINUE
        }
        pl_team = team
        total_snipers()
        new name
        get_user_name(id,name,31)
/*
        if (plist)
   {
                client_print(id,print_center,"You had an awp and got transferred alive to the new team.")
                log_message("The player %s with an awp changed the team alive. There is now %d awps for team 1 and %d for team 2.",
                        name, awp_count, awp_count)
        }
*/
        return PLUGIN_CONTINUE
}


public plugin_init()
{
        register_plugin("AWP/AUTO Limit (Team/Win)","1.52","SuicideDog/MattOG/DaSoul")
        register_menucmd(-31,(1<<4),"via_me" )                                    //T: AWP, CT: Sig SG-550 Sniper       - VGUI
        register_menucmd(-31,(1<<5),"via_me" )                                    // CT: AWP, T:H&K G3SG-1 Sniper Rifle - VGUI
        register_menucmd(register_menuid("BuyRifle",1),(1<<4),"via_me" )          //T: AWP, CT: Sig SG-550 Sniper       - STANDARD
        register_menucmd(register_menuid("BuyRifle",1),(1<<5),"via_me" )          // CT: AWP, T:H&K G3SG-1 Sniper Rifle - STANDARD
        register_clcmd("drop","handle_drop_weapon")

        register_clcmd("awp","cmdawp")
        register_clcmd("magnum","cmdawp")
        register_clcmd("g3sg1","cmdauto")
        register_clcmd("d3au1","cmdauto")
        register_clcmd("sg550","cmdauto")
        register_clcmd("krieg550","cmdauto")
        register_clcmd("rebuy","check_rebuy")

        pv_awplimit = register_cvar("awplimit","1")
        pv_autolimit = register_cvar("autolimit","1")
        pv_checkrebuy = register_cvar("checkrebuy","1")
        pv_max_awps = register_cvar("max_awps","2")
        pv_max_autos = register_cvar("max_autos","1")
        pv_minplayers = register_cvar("min_players","5")
        pv_winspread_awp = register_cvar("winspread_awp","3")
        pv_winspread_auto = register_cvar("winspread_auto","2")

        register_event("TeamScore", "team_score", "a")
        register_event("TeamInfo","team_assign","a")
        register_event("WeapPickup","handle_pickup_awp","b","1=18")
        register_event("WeapPickup","handle_pickup_sg550","b","1=13")
        register_event("WeapPickup","handle_pickup_g3sg1","b","1=24")
        register_event("DeathMsg","handle_death","a")

        register_event("ResetHUD","check_winning_team","b")

        register_logevent("round_start", 2, "1=Round_Start")
        register_forward(FM_Touch, "hook_touch")
}

银闪闪 发表于 2010-12-24 23:30:00

看不懂

干脆你直接给我个限制AWP插件吧?

就是双方各两把AWP,不管谁输谁赢,双方都只能各两把

心静如水 发表于 2010-12-25 00:22:22

没有服务器测试..................

LittleKu 发表于 2010-12-25 00:27:39

一楼的,把new plist = { 0, ... }   // 0 = no awp; 1 = carrying awp 改成new plist = { 0, ... }   // 0 = no awp; 1 = carrying awp
页: [1]
查看完整版本: 请问这是哪里的错误?谢谢