AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Getting weapon classname. (https://forums.alliedmods.net/showthread.php?t=89442)

xbatista 04-06-2009 11:25

Getting weapon classname.
 
How to get classname something like this?
PHP Code:

if (class == "weapon_glock18"

P.S. Without "equali or equal" ???

PHP Code:

new class[32]
pev(entpev_classname, class, 31


Bugsy 04-06-2009 11:27

Re: Classname.
 
Quote:

Originally Posted by xbatista (Post 798860)
How to get classname something like this?
PHP Code:

if (class == "weapon_glock18"

P.S. Without "equali or equal" ???

PHP Code:

new class[32]
pev(entpev_classname, class, 31


Why are you trying to avoid equal\equali? You could compare individual characters of the string.

PHP Code:

if ( szClass[7] == 'g' 


hleV 04-06-2009 11:32

Re: Classname.
 
Class name will return "weaponbox". You should check the model.
Code:
new szMdl[32]; pev(iEnt, pev_model, szMdl, 31);   if (equal(szMdl, "models/w_glock18.mdl"))         // Your stuff

xbatista 04-06-2009 11:37

Re: Classname.
 
I need something like this:
PHP Code:

if ( class[LEVELS[PlayerLevel[id]]] == WEAPONCONST[PlayerLevel[id]] ) 
        return 
FMRES_IGNORED

if (class[index] == "weapon_name")

Dores 04-06-2009 11:55

Re: Classname.
 
Quote:

Originally Posted by hleV (Post 798866)
Class name will return "weaponbox". You should check the model.

If the weapon is being used, it will return the specific weapon's classname(weapon_*).

xbatista 04-06-2009 12:03

Re: Classname.
 
I don't need equal and w_ (models).
It is possible something like this?
if (class[index] == "weapon_name")
or
if (class == "weapon_name")

xPaw 04-06-2009 12:14

Re: Classname.
 
why you dont like equal?

just use this...
PHP Code:

if( equal( class[index], "weapon_name" ) ) 

if you are just confising with it, just ask...

xbatista 04-06-2009 12:22

Re: Classname.
 
Because it pick ups all weapons ,or not.
And example my level is 4.
PHP Code:

new const WEAPONCONST[MAXLEVEL][] = {"weapon_glock18""weapon_usp""weapon_p228""weapon_fiveseven""weapon_deagle""weapon_elite""weapon_tmp"
"weapon_mac10""weapon_ump45""weapon_mp5navy""weapon_p90""weapon_scout""weapon_awp""weapon_famas""weapon_galil""weapon_m3""weapon_xm1014"
"weapon_ak47""weapon_m4a1""weapon_aug""weapon_sg552""weapon_sg550""weapon_g3sg1""weapon_m249" 
}; // Give Weapons

/// In FWD_TOUCH
    
if (equali(class, WEAPONCONST[PlayerLevel[id]]))
    {
        return 
FMRES_SUPERCEDE;
    } 


Bugsy 04-06-2009 21:47

Re: Classname.
 
Quote:

Originally Posted by Dores (Post 798890)
Quote:

Originally Posted by hleV (Post 798866)
Class name will return "weaponbox". You should check the model.
Code:
new szMdl[32]; pev(iEnt, pev_model, szMdl, 31);   if (equal(szMdl, "models/w_glock18.mdl"))         // Your stuff

If the weapon is being used, it will return the specific weapon's classname(weapon_*).

hlev is correct, weaponbox is the classname so use the model name in your touch event. This should return the actual type of weapon; I edited the WEAPONCONST array for you.

PHP Code:

new const WEAPONCONST[MAXLEVEL][] = {"models/w_glock18.mdl""models/w_usp.mdl""models/w_p228""models/w_fiveseven.mdl""models/w_deagle""models/w_elite.mdl""models/w_tmp.mdl"
"models/w_mac10.mdl""models/w_ump45.mdl""models/w_mp5navy.mdl""models/w_p90.mdl""models/w_scout.mdl""models/w_awp.mdl""models/w_famas.mdl""models/w_galil.mdl""models/w_m3.mdl""models/w_xm1014.mdl"
"models/w_ak47.mdl""models/w_m4a1.mdl""models/w_aug.mdl""models/w_sg552.mdl""models/w_sg550.mdl""models/w_g3sg1.mdl""models/w_m249.mdl" 
}; // Give Weapons 

static szEntModel[32];
peviEnt pev_model szEntModel 31 );

if ( 
equaliszEntModel WEAPONCONST[PlayerLevel[id]] ) )
{
    return 
FMRES_SUPERCEDE;



YamiKaitou 04-07-2009 00:06

Re: Classname.
 
As per the Global Forum Rules, you need to have a descriptive topic title. If you wish for this topic to stay open, please correct the topic title before you post again.


All times are GMT -4. The time now is 02:25.

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