AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Getting weapon of what user is holding (https://forums.alliedmods.net/showthread.php?t=54691)

wonsae 05-01-2007 19:17

Getting weapon of what user is holding
 
How would I get what weapon the user is holding and get the exact weapon name in TS? I looked at Ava's include file but I'm not sure on how to use it.

Styles 05-01-2007 19:35

Re: Getting weapon of what user is holding
 
ts_getuserwpn
http://www.amxmodx.org/funcwiki.php?go=func&id=644

wonsae 05-01-2007 19:44

Re: Getting weapon of what user is holding
 
That only gets the current weapon. I'm trying to get every weapon the user has.

Drak 05-01-2007 19:49

Re: Getting weapon of what user is holding
 
This doesn't work for TS?
http://www.amxmodx.org/funcwiki.php?...pons&go=search

wonsae 05-01-2007 20:23

Re: Getting weapon of what user is holding
 
Oh alright thanks, the example there taught me on how to use one of ava's functions xD. but I'm stuck again :S

PHP Code:

public DepositFireArm(id)
{
 if(!
is_user_alive(id)) return PLUGIN_HANDLED
 
 
new menu[256]
 
 new 
key = (1<<0|1<<1|1<<9)
 new 
len format(menu,sizeof(menu),"Deposit Firearm^n^n")
 
 new 
weapons[35], num 0
 
for(new i=1;i>ts_get_user_weapons(id,weapons,num);i++)
 {
  
len += format(menu[len],sizeof(menu)-len,"%i. %s^n",i,weapon_names[i])
 }
 
 
show_menu(id,key,menu,-1,"Deposit Firearm")
 return 
PLUGIN_HANDLED
}
public 
DepositFireArm_Action(id,key)
{
 switch(
key)
 {
  


// How do get on how many cases there are?? 


Drak 05-01-2007 22:16

Re: Getting weapon of what user is holding
 
It doesn't matter. Your "for" statement is wrong a tid bit. But when it's working correctly, it should display in the menu:
"i number. Weapons name"

Obviously, like you have. Well that will automatically read, and the case statement will work fine, it always has for me.
Just make the case(s) 0-9. But if you really need to get the total amount of weapons found, make a global variable to store it.

Oh and also, change your "for" statement to this:
Code:
new weapons[32],numWeapons get_user_weapons(id,weapons,numWeapons) for(new i=1; i < numWeapons ;i++)

stupok 05-01-2007 23:05

Re: Getting weapon of what user is holding
 
Here's a start:

Code:
//... new const weapon_names[38][] = {     "Null", //To occupy space #0     "Glock-18",     "TSW_UNK1",     "Mini-Uzi",     "Benelli M3",     "M4A1",     "MP5SD",     "MP5K",     "Akimbo Berettas",     "SOCOM-MK23",     "Akimbo MK23",     "USAS-12",     "Desert Eagle",     "AK47",     "Five-seveN",     "STEYR-AUG",     "Akimbo Uzi",     "STEYR-TMP",     "Barrett M82A1",     "MP7-PDW",     "SPAS-12",     "Golden Colts",     "Glock-20C",     "UMP",     "M61 Grenade",     "Combat Knife",     "Mossberg 500",     "M16A4",     "Ruger-MK1",     "C4",     "Akimbo 57",     "Raging Bull",     "M60E3",     "Sawed-off",     "Katana",     "Seal Knife",     "Kung Fu",     "Seal Knife" } public DepositFireArm(id) {     //...     new menu[256], weapons[35], num, len         ts_get_user_weapons(id, weapons, num)         for(new i = 0; i < num; i++)     {         len += format(menu[len], sizeof(menu)-len, "%i. %s^n", i+1, weapon_names[weapons[i]])     }     //... }


All times are GMT -4. The time now is 06:39.

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