Raised This Month: $ Target: $400
 0% 

How to get weapon's ID


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wwzw
Member
Join Date: Feb 2009
Old 12-21-2011 , 05:48   How to get weapon's ID
Reply With Quote #1

I would like to set some specific models of weapons. Not everyone, not all weapons. Like this:
if (id == 6) {
give_item (id, "weapon_ak47")
// Then I need to set all of this weapon model: v_ak47.mdl, p_ak47.mdl, w_ak47.mdl
// What they saw, others see, after the fall of weapons
}

How to get this weapon's ID (not the 1 ~ 32), this ID is unique in the map, then how do I set the weapon model?
v_ak47.mdl and p_ak47.mdl. Is not a replacement weapon each time the player will need to set? When a player drop this weapon , how to set up a model of this weapon.
Not all of the ak47 can use this model.
Please help me. Thanks!

Last edited by wwzw; 12-21-2011 at 05:51.
wwzw is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 12-21-2011 , 06:45   Re: How to get weapon's ID
Reply With Quote #2

http://forums.alliedmods.net/showthread.php?t=40822
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
wwzw
Member
Join Date: Feb 2009
Old 12-21-2011 , 10:08   Re: How to get weapon's ID
Reply With Quote #3

I read that article, but I can not use.
"Public fw_SetModel (entity, model [])" is to replace all of the models, for example, is the AK47, I do not want replace all AK47 models, but rather the system automatically give the AK47.
wwzw is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 12-21-2011 , 10:20   Re: How to get weapon's ID
Reply With Quote #4

Answering how to get weapon id

Code:
new weaponname[ 36 ] get_weaponname( CSW_KNIFE, weaponname, 35 ) new weapon_id = find_ent_by_owner( -1, weaponname, id )

Last edited by Backstabnoob; 12-21-2011 at 10:21.
Backstabnoob is offline
wwzw
Member
Join Date: Feb 2009
Old 12-21-2011 , 20:33   Re: How to get weapon's ID
Reply With Quote #5

Thank you, exactly what I needed.
Next: How to set the weapon models by weapon_id ?

Last edited by wwzw; 12-21-2011 at 21:05.
wwzw is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 12-22-2011 , 07:53   Re: How to get weapon's ID
Reply With Quote #6

Do it like Cheap_Suit has shown in the thread Drekes posted.
At the top of FM_SetModel and CurWeapon hooks, check for the weapon the way I posted.

Code:
new weaponname[ 36 ] get_weaponname( CSW_KNIFE, weaponname, 35 ) new weapon_id = find_ent_by_owner( -1, weaponname, id ) if( weapon_id != your_desired_weapon_id )    return PLUGIN_CONTINUE // other code

Last edited by Backstabnoob; 12-22-2011 at 07:53.
Backstabnoob is offline
wwzw
Member
Join Date: Feb 2009
Old 12-22-2011 , 08:37   Re: How to get weapon's ID
Reply With Quote #7

But I still failed!
I can not get "your_desired_weapon_id"
Code:
register_forward(FM_SetModel,"W_Model_Hook",1)

public W_Model_Hook(ent,model[])
{
 if(!pev_valid(ent))
 {
  return FMRES_IGNORED
 }
 if(strlen(model) < 8 || model[7] != 'w' || model[8] != '_')
  return FMRES_IGNORED;
 client_print(0, print_chat, "TEST<%d>",ent)
 for (new i=0;i<load_new_weapon_num;++i) {
  if (ent == weapon_id [i]) {
    // set model
    return FMRES_SUPERCEDE;
   }
  }
 }
 return FMRES_IGNORED
}
The "ent" is not "find_ent_by_owner( -1, weaponname, id )"

When I drop the weapon, "ent" value is changing...
wwzw 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:10.


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