AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Checking (https://forums.alliedmods.net/showthread.php?t=134485)

GXLZPGX 08-05-2010 10:57

Checking
 
How can I check if a user has a weapon other than a deagle?

I thought about..

PHP Code:

if( get_user_weapon(id) != CSW_DEAGLE )
{
     
//EXECUTE IF USER HAS A WEAPON OTHER THAN A DEAGLE



GXLZPGX 08-05-2010 11:12

Re: Checking
 
Quote:

Originally Posted by NiHiLaNTh (Post 1262328)
You mean if there any weapons in players inventory, except Deagle ?

Nah, what their holding.

drekes 08-05-2010 11:52

Re: Checking
 
Check it in curweapon, like you did above,
Or use Ham_Item_Deploy. Not sure which is the best.

GXLZPGX 08-05-2010 11:55

Re: Checking
 
Quote:

Originally Posted by drekes (Post 1262362)
Check it in curweapon, like you did above,
Or use Ham_Item_Deploy. Not sure which is the best.

Yes, I used curweapon.

drekes 08-05-2010 15:18

Re: Checking
 
tested and working:
PHP Code:

#include <amxmodx>

#pragma semicolon 1

public plugin_init()
    
register_event("CurWeapon""Event_CurWeapon""be");
    
public 
Event_CurWeapon(id)
{
    new 
IsActive read_data(1);
    new 
wpn read_data(2);
    
    if(
IsActive && wpn == CSW_DEAGLE)
        
client_print(idprint_chat"Holding deagle");


You can edit the stuff you want from here.

wrecked_ 08-05-2010 17:02

Re: Checking
 
Your first method would work just fine.

GXLZPGX 08-05-2010 19:08

Re: Checking
 
How would I use get_user_weapons to retrieve more than one weapon.

I want to use this:

PHP Code:

if( gToss == true && get_user_weapon(id) != CSW_DEAGLE )
{
    
strip_user_weapons(id)
    
give_itemid"weapon_deagle" )
    
cs_set_weapon_ammoid)
    
cs_set_user_bpammoidCSW_DEAGLE)



But I want it to execute those commands if they player has a weapon other than a Deagle AND a Knife, not just a deagle.

Kreation 08-05-2010 20:16

Re: Checking
 
Check for that in drekes example too?

ConnorMcLeod 08-05-2010 21:04

Re: Checking
 
#define CSW_DEAGLE 26

So :

PHP Code:

#include <amxmodx>
#include <cstrike>
#include <fun>

#define VERSION "0.0.1"

public plugin_init()
{
    
register_plugin("Check Deagle"VERSION"ConnorMcLeod")

    
register_event("CurWeapon""Event_CurWeapon_NotDeagle""be""1=1""2!26")
}

public 
Event_CurWeapon_NotDeagle(id)
{
    
// id is alive and is holding another weapon than deagle
    
strip_user_weapons(id)
    new 
iDeagle give_item(id"weapon_deagle")
    
cs_set_weapon_ammo(iDeagle0)
    
cs_set_user_bpammo(idCSW_DEAGLE0)



Seta00 08-05-2010 21:14

Re: Checking
 
user_has_weapon

dunno if it works


All times are GMT -4. The time now is 00:09.

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