Raised This Month: $ Target: $400
 0% 

Checking for a model


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EpicKiller
Senior Member
Join Date: Jun 2014
Location: Constanta, Romania
Old 09-02-2014 , 10:11   Checking for a model
Reply With Quote #1

Hi! How can I check if there is a custom model set on a weapon?
__________________
~ Swiftly and with style ~
EpicKiller is offline
Send a message via Yahoo to EpicKiller Send a message via Skype™ to EpicKiller
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 09-02-2014 , 10:23   Re: Checking for a model
Reply With Quote #2

PHP Code:
pev(idpev_viewmodel2szModelcharsmax(szModel))

if(!
equali(szModel"v_knife.mdl"))
{
    
//not the default model

__________________

Last edited by Flick3rR; 09-02-2014 at 10:49.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
EpicKiller
Senior Member
Join Date: Jun 2014
Location: Constanta, Romania
Old 09-02-2014 , 10:27   Re: Checking for a model
Reply With Quote #3

Quote:
Originally Posted by Flick3rR View Post
PHP Code:
pev(entpev_viewmodel2szModelcharsmax(szModel))

if(!
equali(szModel"v_knife.mdl"))
{
    
//not the default model

I see. Alright, thank you, Flicker!

EDIT: One more question, though. How could I do it for a world model?
__________________
~ Swiftly and with style ~

Last edited by EpicKiller; 09-02-2014 at 10:30.
EpicKiller is offline
Send a message via Yahoo to EpicKiller Send a message via Skype™ to EpicKiller
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 09-02-2014 , 10:32   Re: Checking for a model
Reply With Quote #4

Hook fwSetModel and check the model there. Search for similiar threads in that section and you'll get it.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
EpicKiller
Senior Member
Join Date: Jun 2014
Location: Constanta, Romania
Old 09-02-2014 , 10:41   Re: Checking for a model
Reply With Quote #5

This is the code I got. Two of the if statements in the WeapPickup functions should contain the check I need. How should I do it there?
Spoiler
__________________
~ Swiftly and with style ~

Last edited by EpicKiller; 09-02-2014 at 10:42.
EpicKiller is offline
Send a message via Yahoo to EpicKiller Send a message via Skype™ to EpicKiller
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 09-02-2014 , 10:52   Re: Checking for a model
Reply With Quote #6

Better use Ham_AddPlayerItem, it passes player's id nad weapon's entity id. You can do it pretty simple there.
Like:
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>

new const W_MODEL_G_AWP[] = "models/custom_awp/w_golden_awp.mdl";

public 
plugin_init() {
    
RegisterHam(Ham_AddPlayerItem"player""fwPlayerItem")
}

public 
fwPlayerItem(ident)
{
    if(!
pev_valid(ent))
        return
        
    new 
szModel[64]
    
pev(entpev_modelszModelcharsmax(szModel))
    
    if(
equali(szModelW_MODEL_G_AWP))
    {
        
//The weapon has custom golden model aaand therefore it's an AWP :D
    
}

__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
EpicKiller
Senior Member
Join Date: Jun 2014
Location: Constanta, Romania
Old 09-02-2014 , 10:59   Re: Checking for a model
Reply With Quote #7

Quote:
Originally Posted by Flick3rR View Post
Better use Ham_AddPlayerItem, it passes player's id nad weapon's entity id. You can do it pretty simple there.
Like:
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>

new const W_MODEL_G_AWP[] = "models/custom_awp/w_golden_awp.mdl";

public 
plugin_init() {
    
RegisterHam(Ham_AddPlayerItem"player""fwPlayerItem")
}

public 
fwPlayerItem(ident)
{
    if(!
pev_valid(ent))
        return
        
    new 
szModel[64]
    
pev(entpev_modelszModelcharsmax(szModel))
    
    if(
equali(szModelW_MODEL_G_AWP))
    {
        
//The weapon has custom golden model aaand therefore it's an AWP :D
    
}

Thank you so much!
__________________
~ Swiftly and with style ~
EpicKiller is offline
Send a message via Yahoo to EpicKiller Send a message via Skype™ to EpicKiller
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-02-2014 , 11:16   Re: Checking for a model
Reply With Quote #8

Quote:
//The weapon has custom golden model aaand therefore it's an AWP
You don't know if this is an awp. A custom weapon may have this model and it may not be an awp. You must retrive weaponid with cs_get_weapon_id and check if it's CSW_AWP.
__________________

Last edited by HamletEagle; 09-02-2014 at 11:18.
HamletEagle is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 09-02-2014 , 11:19   Re: Checking for a model
Reply With Quote #9

Quote:
Originally Posted by HamletEagle View Post
You don't know if this is an awp. A custom weapon may have this model and it may not be an awp. You must retrive weaponid with cs_get_weapon_id and check if it's CSW_AWP.
Probably it will be the best to check if pev_classname is not weapon_awp and return.
But why will he set the custom AWP model to a weapon, which is not an awp?
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-02-2014 , 11:37   Re: Checking for a model
Reply With Quote #10

I'm not speacking about him, I'm speacking in general. It was more to explain that if a weapon has a model, then this doesn't mean that the weapon is the same as the model.
__________________
HamletEagle 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 12:46.


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