Raised This Month: $ Target: $400
 0% 

detect weapon and run commands


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
razieljohn619
Senior Member
Join Date: May 2011
Location: Philippines
Old 06-19-2011 , 07:15   Re: detect weapon and run commands
Reply With Quote #1

should it look like this now??
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <engine>

#define PLUGIN "M249"
#define VERSION "1.0"
#define AUTHOR "razieljohn619"

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHam(Ham_Spawn"player""FwdPlayerSpawnPost"); 
   
        
}


public 
hasWeapon(idweapid){
    new 
weapons[32], wnum
    get_user_weapons
(idweaponswnum)
    for(new 
0wnumi++){
        if(
weapons[i] == weapid) return 1
    
}
    return 
0
    
}    

public 
FwdPlayerSpawnPostiPlayer )
{
    if( 
is_user_aliveiPlayer ) )
    {
        if( 
user_has_weaponiPlayerCSW_M249 ) )
        {
            
set_task(0.1"//player has")
        }
        else
        {
            
set_task(0.1"//player does not have")
        }
    }
        
}

public 
//player has(id)
{
    
//commands
    
}

public 
//player does not have(id)
{
    
//commands 

should it look like this now, because i'm having many errors on that part of
PHP Code:
RegisterHam(Ham_Spawn"player""FwdPlayerSpawnPost"); 
can you help me..pls..thanks

EDIT:
it now works because i included hamsandwich..thanks Exolent

i dont know if it's working or not..and how about detecting if player has shield and runs commands if has shield or not, just like here
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <engine>

#define PLUGIN "M249"
#define VERSION "1.0"
#define AUTHOR "razieljohn619"

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHam(Ham_Spawn"player""FwdPlayerSpawnPost"); 
   
        
}


public 
hasWeapon(idweapid){
    new 
weapons[32], wnum
    get_user_weapons
(idweaponswnum)
    for(new 
0wnumi++){
        if(
weapons[i] == weapid) return 1
    
}
    return 
0
    
}    

public 
FwdPlayerSpawnPostiPlayer )
{
    if( 
is_user_aliveiPlayer ) )
    {
        if( 
user_has_weaponiPlayerCSW_M249 ) )
        {
            
set_task(0.1"//player has")
        }
        else
        {
            
set_task(0.1"//player does not have")
        }
    }
        
}

public 
//player has(id)
{
    
//commands
    
}

public 
//player does not have(id)
{
    
//commands 

but only detect if has shield..thanks
__________________


Last edited by razieljohn619; 06-19-2011 at 07:34.
razieljohn619 is offline
Send a message via Yahoo to razieljohn619
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-19-2011 , 07:49   Re: detect weapon and run commands
Reply With Quote #2

Delete this:
PHP Code:
public hasWeapon(idweapid){
    new 
weapons[32], wnum
    get_user_weapons
(idweaponswnum)
    for(new 
0wnumi++){
        if(
weapons[i] == weapid) return 1
    
}
    return 
0
    

You are not even using it.
Even if you need a function like that, use user_has_weapon().
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 23:26.


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