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

Solved Why would this not allow me to pickup revolver?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
condolent
AlliedModders Donor
Join Date: Jan 2016
Location: gc_sLocation;
Old 09-26-2017 , 12:43   Why would this not allow me to pickup revolver?
Reply With Quote #1

Why would this deny me from picking up a revolver?
I've been struggling with this for almost an hour now and I can't for the life of me figure out why it won't work.

Point is to ONLY allow picking up revolvers and using them.

PHP Code:
public Action WeaponCanUse(int clientint weapon) {
    
char sWeapon[128]; // Weapon that fires this
    
GetEdictClassname(weaponsWeaponsizeof(sWeapon));
    
    if(!
IsValidClient(client))
        return 
Plugin_Handled;
    if(!
StrEqual(sWeapon"weapon_revolver")) // Make sure only the revolver can be used
        
return Plugin_Handled;
    
    return 
Plugin_Continue;

__________________

Last edited by condolent; 09-26-2017 at 14:47.
condolent is offline
ESK0
BANNED
Join Date: May 2014
Location: Czech Republic
Old 09-26-2017 , 12:46   Re: Why would this not allow me to pickup revolver?
Reply With Quote #2

Quote:
Originally Posted by condolent View Post
Why would this deny me from picking up a revolver?
I've been struggling with this for almost an hour now and I can't for the life of me figure out why it won't work.

Point is to ONLY allow picking up revolvers and using them.

PHP Code:
public Action WeaponCanUse(int clientint weapon) {
    
char sWeapon[128]; // Weapon that fires this
    
GetEdictClassname(weaponsWeaponsizeof(sWeapon));
    
    if(!
IsValidClient(client))
        return 
Plugin_Handled;
    if(!
StrEqual(sWeapon"weapon_revolver")) // Make sure only the revolver can be used
        
return Plugin_Handled;
    
    return 
Plugin_Continue;

This will help you:

https://github.com/ESK0/Call-of-Duty...khooks.sp#L350
ESK0 is offline
condolent
AlliedModders Donor
Join Date: Jan 2016
Location: gc_sLocation;
Old 09-26-2017 , 13:17   Re: Why would this not allow me to pickup revolver?
Reply With Quote #3

I found out why it wasn't working. Apparently, it said the weapons classname was weapon_deagle. But it's an R8 Revolver. How can I fix this?
Found it by printing the sWeapon variable in chat when I tried picking it up
__________________

Last edited by condolent; 09-26-2017 at 13:18.
condolent is offline
ESK0
BANNED
Join Date: May 2014
Location: Czech Republic
Old 09-26-2017 , 13:24   Re: Why would this not allow me to pickup revolver?
Reply With Quote #4

Quote:
Originally Posted by condolent View Post
I found out why it wasn't working. Apparently, it said the weapons classname was weapon_deagle. But it's an R8 Revolver. How can I fix this?
Found it by printing the sWeapon variable in chat when I tried picking it up
Well its same as with P2000 and UPS-S.. You have to use ItemDefinitionIndex.

https://github.com/ESK0/Call-of-Duty...khooks.sp#L359
ESK0 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 09-26-2017 , 13:28   Re: Why would this not allow me to pickup revolver?
Reply With Quote #5

Quote:
Originally Posted by condolent View Post
I found out why it wasn't working. Apparently, it said the weapons classname was weapon_deagle. But it's an R8 Revolver. How can I fix this?
Found it by printing the sWeapon variable in chat when I tried picking it up
Yeah, thanks valve
https://github.com/MitchDizzle/Exten...l.sp#L652-L661
Mitchell is offline
condolent
AlliedModders Donor
Join Date: Jan 2016
Location: gc_sLocation;
Old 09-26-2017 , 14:44   Re: Why would this not allow me to pickup revolver?
Reply With Quote #6

Quote:
Originally Posted by Mitchell View Post
That right there just saved me hours of tearing my hair out. Valve being valve
__________________
condolent is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 09-26-2017 , 18:17   Re: Why would this not allow me to pickup revolver?
Reply With Quote #7

Replacement weapons are prefabs of their base class. Meaning they are the same internal class while data is overridden from the items script file.

Using classnames to validate a particular weapon is wrong.
__________________
Neuro Toxin 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 16:32.


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