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

Weapon Restrictions


Post New Thread Reply   
 
Thread Tools Display Modes
Ravager01
Member
Join Date: Jul 2006
Old 05-18-2008 , 19:12   Re: Weapon Restrictions
Reply With Quote #51

Did you happen to get this error?

Code:
[SM] Plugin encountered error 15: Array index is out of bounds
[SM] Displaying call stack trace for plugin "restrict.smx":
[SM]   [0]  Line 240, restrict.sp::Command_Restrict()
I get this when attempting to restrict the smoke grenade. All other weapons, including the HE and Flash grenades, can be restricted without any errors.

Last edited by Ravager01; 05-18-2008 at 19:15.
Ravager01 is offline
Liam
SourceMod Developer
Join Date: Jan 2008
Location: Atlanta, GA
Old 05-19-2008 , 00:19   Re: Weapon Restrictions
Reply With Quote #52

Okay, so here is what I've found:

Code:

// Lets parse our input and then restrict the weapons
f_Weapon = LookupWeaponNumber(f_WeaponString);
f_Amount = StringToInt(f_AmountString);
f_Team = LookupTeam(f_TeamString);
RestrictWeapon(client, f_Weapon, f_Amount, f_Team);
PerformTimedRemove(-1); // remove all restricted weapons in-game
// log the command
if(f_Team == TEAM_ALL)
{
    if(f_Amount == 0)
    {
        LogAction(client, -1, "sm_restrict - Restricted the %s.", 
        g_ShortWeaponNames[f_Weapon]);
    }
    else
    {
        LogAction(client, -1, "sm_restrict - Restricted the %s to %d per team.", 
        g_ShortWeaponNames[f_Weapon], f_Amount);
    }
}
else
{
    if(f_Amount == 0)
    {
        LogAction(client, -1, "sm_restrict - Restricted the %s for the %s team.", 
        g_ShortWeaponNames[f_Weapon], f_Team == TEAM_T ? "Terrorist" : "Counter-Terrorist");
    }
    else
    {
        LogAction(client, -1, "sm_restrict - Restricted the %s to %d for the %s team.", 
        g_ShortWeaponNames[f_Weapon], f_Amount, f_Team == TEAM_T ? "Terrorist" : "Counter-Terrorist");
    }
}
Those are the lines generating the error. I've only managed to replicate this after putting my restrict commands in a .cfg file.

Now: I tracked this back by adding the following code.

Code:

// Lets parse our input and then restrict the weapons
f_Weapon = LookupWeaponNumber(f_WeaponString);
f_Amount = StringToInt(f_AmountString);
f_Team = LookupTeam(f_TeamString);
RestrictWeapon(client, f_Weapon, f_Amount, f_Team);
PerformTimedRemove(-1); // remove all restricted weapons in-game
 
/* NEW CODE */
if(f_Weapon == -1 || f_Amount == -1 || f_Team == -1)
{
    LogError("Invalid weapon number: WeaponString: %s, AmountString: %s, Team: %s", 
    f_WeaponString, f_AmountString, f_TeamString);
    return;
}
/* END NEW CODE */
// log the command
if(f_Team == TEAM_ALL)
{
    if(f_Amount == 0)
    {
        LogAction(client, -1, "sm_restrict - Restricted the %s.", 
        g_ShortWeaponNames[f_Weapon]);
    }
    else
    {
        LogAction(client, -1, "sm_restrict - Restricted the %s to %d per team.", 
        g_ShortWeaponNames[f_Weapon], f_Amount);
    }
}
else
{
    if(f_Amount == 0)
{
        LogAction(client, -1, "sm_restrict - Restricted the %s for the %s team.", 
        g_ShortWeaponNames[f_Weapon], f_Team == TEAM_T ? "Terrorist" : "Counter-Terrorist");
}
    else
{
        LogAction(client, -1, "sm_restrict - Restricted the %s to %d for the %s team.", 
        g_ShortWeaponNames[f_Weapon], f_Amount, f_Team == TEAM_T ? "Terrorist" : "Counter-Terrorist");
}
}
What I found is that when something like the following is executed:
Code:
sm_restrict awp
It was actually sending to the server
Code:
sm_restrict t awp
I modified the plugin I was using to handle my cfg files appropriately and got it to work. If I have to write a standalone restriction file which the server will handle parsing and executing to fix this, I'll do it.

However, if a few of you feel froggy enough, add those lines into your restrict.sp, recompile it, and let me know if that is indeed, where your getting the error.

Thanks,
-Liam

Last edited by Liam; 05-19-2008 at 00:21.
Liam is offline
PStar
Veteran Member
Join Date: Mar 2008
Old 05-19-2008 , 06:03   Re: Weapon Restrictions
Reply With Quote #53

Hy, i aded the lines (hopefully in the correct lines), but getting this errors whe compling.
Attached Thumbnails
Click image for larger version

Name:	shot.JPG
Views:	190
Size:	37.2 KB
ID:	26791  
PStar is offline
Liam
SourceMod Developer
Join Date: Jan 2008
Location: Atlanta, GA
Old 05-19-2008 , 11:26   Re: Weapon Restrictions
Reply With Quote #54

Fix the return on those lines to say return Plugin_Handled;

Don't worry about the loose indention.
Liam is offline
Ravager01
Member
Join Date: Jul 2006
Old 05-19-2008 , 18:34   Re: Weapon Restrictions
Reply With Quote #55

I think I may have found the problem.

In restrict.inc, in the new String:g_WeaponNames[][] section:
Code:
"weapon_flashbang", "weapon_hegrenade", "weapon_smokegrenade,",
Remove the unneeded comma in the enclosed weapon_smokegrenade tag and recompile the plugin. Smoke Grenade restriction should now work.
Ravager01 is offline
Liam
SourceMod Developer
Join Date: Jan 2008
Location: Atlanta, GA
Old 05-19-2008 , 23:48   Re: Weapon Restrictions
Reply With Quote #56

Quote:
Originally Posted by Ravager01 View Post
I think I may have found the problem.

In restrict.inc, in the new String:g_WeaponNames[][] section:
Code:
"weapon_flashbang", "weapon_hegrenade", "weapon_smokegrenade,",
Remove the unneeded comma in the enclosed weapon_smokegrenade tag and recompile the plugin. Smoke Grenade restriction should now work.
Good catch, but thats not the original problem. The original problem was a buffer overflow issue.

Will give it a try though.

Plugin has been updated.
Liam is offline
Ravager01
Member
Join Date: Jul 2006
Old 05-20-2008 , 00:38   Re: Weapon Restrictions
Reply With Quote #57

In that case, s/the/a/. (if that's how it's supposed to look) O_o
Ravager01 is offline
sessus
Senior Member
Join Date: May 2006
Old 05-22-2008 , 10:51   Re: Weapon Restrictions
Reply With Quote #58

the sm_knives option does not seem to work,
good plugin otherwise, well dome liam
sessus is offline
doa
Member
Join Date: Nov 2007
Old 05-29-2008 , 18:02   Re: Weapon Restrictions
Reply With Quote #59

I have tried several difeerent ways to restict awp to one per team with no success, I have tried:
sm_restrict awp 1
sm_restrict awp 1 ct/t
sm_restrict awp 1 all


I have no problem to restict weapons to 0.

Any clues?
__________________
-- Growing older is mandatory --
----- Growing up is optional -----
doa is offline
PStar
Veteran Member
Join Date: Mar 2008
Old 05-29-2008 , 18:42   Re: Weapon Restrictions
Reply With Quote #60

Quote:
Originally Posted by doa View Post
I have tried several difeerent ways to restict awp to one per team with no success, I have tried:
sm_restrict awp 1
sm_restrict awp 1 ct/t
sm_restrict awp 1 all


I have no problem to restict weapons to 0.

Any clues?
It should look like this:
Quote:
sm_restrict weapon_awp 1 CT
sm_restrict weapon_awp 1 T
sm_restrict weapon_scout 2 CT
sm_restrict weapon_scout 2 T
sm_restrict weapon_g3sg1 1 CT
sm_restrict weapon_sg550 1 T
PStar is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:29.


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