AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to get weapon's ID (https://forums.alliedmods.net/showthread.php?t=174499)

wwzw 12-21-2011 05:48

How to get weapon's ID
 
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!

drekes 12-21-2011 06:45

Re: How to get weapon's ID
 
http://forums.alliedmods.net/showthread.php?t=40822

wwzw 12-21-2011 10:08

Re: How to get weapon's ID
 
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.

Backstabnoob 12-21-2011 10:20

Re: How to get weapon's ID
 
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 )

wwzw 12-21-2011 20:33

Re: How to get weapon's ID
 
Thank you, exactly what I needed.
Next: How to set the weapon models by weapon_id ?

Backstabnoob 12-22-2011 07:53

Re: How to get weapon's ID
 
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

wwzw 12-22-2011 08:37

Re: How to get weapon's ID
 
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...


All times are GMT -4. The time now is 12:10.

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