AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] Get Players Current Weapon? (https://forums.alliedmods.net/showthread.php?t=214996)

Blizzard_87 05-02-2013 10:04

[SOLVED] Get Players Current Weapon?
 
ive tried

get_weaponname

get_user_weapon

user_has_weapon

etc etc...

how can i check players current weapon they are holding before executing a command ?

zi443r 05-02-2013 10:22

Re: Get Players Current Weapon?
 
maybe this will help you:
https://forums.alliedmods.net/showth...ht=weapon+icon

hornet 05-02-2013 10:37

Re: Get Players Current Weapon?
 
What's wrong with get_user_weapon() ?

ConnorMcLeod 05-02-2013 11:24

Re: Get Players Current Weapon?
 
nothing

Jhob94 05-02-2013 13:31

Re: Get Players Current Weapon?
 
Quote:

Originally Posted by hornet (Post 1944420)
What's wrong with get_user_weapon() ?

If iam not wrong get_user_weapon gets the weapon id. He needing to get the weapon name.

Leon M. 05-02-2013 15:46

Re: Get Players Current Weapon?
 
If so then he got already the answer.

Quote:

Originally Posted by Leon M. (Post 1935711)
Weaponname is missing, thought you know it.

PHP Code:

#include <amxmodx>
#include <amxmisc>

public plugin_init(){
    
register_concmd("amx_dropweapon""cmd_dropweapon"ADMIN_BAN"<name or #userid>")
}

public 
cmd_dropweapon(idlevelcid){
    if (!
cmd_access(idlevelcid1)) return PLUGIN_HANDLED

    
new szArg[32]
    
read_argv(1szArg31)

    new 
iPlayer cmd_target(idszArgCMDTARGET_OBEY_IMMUNITY CMDTARGET_NO_BOTS CMDTARGET_ALLOW_SELF)
    if (
iPlayerdrop_user_weapon(iPlayer)

    return 
PLUGIN_HANDLED
}

stock drop_user_weapon(id){
    new 
szWeaponName[32], iWeapon get_user_weapon(id)
    
get_weaponname(iWeaponszWeaponName31)
    
engclient_cmd(id"drop"szWeaponName)




Blizzard_87 05-02-2013 15:57

Re: Get Players Current Weapon?
 
Quote:

Originally Posted by hornet (Post 1944420)
What's wrong with get_user_weapon() ?

that's works fine untill i changed weapon. then it doesnt check the new weapon in holding.

SOLVED:

Code:
public Update_CurWeap( id ) {     new iWeapon = get_user_weapon(id);     get_weaponname(iWeapon, szWeapon, 31); }

Thanks zi443r that helped.

ConnorMcLeod 05-02-2013 16:07

Re: Get Players Current Weapon?
 
give example, detail more, explain how to reproduce.
get_user_weapon seems really fine for what you discribe.

Blizzard_87 05-02-2013 19:19

Re: Get Players Current Weapon?
 
Quote:

Originally Posted by ConnorMcLeod (Post 1944587)
give example, detail more, explain how to reproduce.
get_user_weapon seems really fine for what you discribe.

sorry i used it in this function in the end.

Code:
if( equal( type, "guns" ) )     {           new szWeaponName[ 32 ], iWeapon = get_user_weapon(id);         get_weaponname(iWeapon, szWeaponName, 31);                 ham_strip_weapon( id, szWeaponName );         ham_give_weapon( g_iDonationTarget, szWeaponName );         Color( 0, "%s !t%s!n Donated !g%s!n To !t%s!n", PREFIX, dName, szWeaponName, rName );         show_dhudmessage( g_iDonationTarget, "[ Donation Revieved ]^n^n Weapon: %s^n^nFrom %s", szWeaponName, dName );     }


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

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