AlliedModders

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

neverminde 04-02-2011 16:41

ham weaponbox
 
Code:

public plugin_init() {   
...
      RegisterHam(Ham_Touch, "weaponbox", "fwdTouch")   
...
}

public fwdTouch(ent, id) {   
      if (is_user_alive(id))   
      return HAM_SUPERCEDE   

      return HAM_IGNORED   
}

What do this part of script?
I think it doesnot allow players to pick up weapon.

if so, then i want to add bool element. true -> ignor weapon ; false -> pickup weapon. i was tring, but unsuccessfuly.
How to code it?

Arkshine 04-02-2011 16:56

Re: ham weaponbox
 
Yes, it blocks the pick up of [only] weaponbox entities. (so weapons dropped).

Show what you have tried to do.

neverminde 04-03-2011 07:27

Re: ham weaponbox
 
Code:

#include <amxmodx>   
#include <hamsandwich>   
#include <fakemeta_util>   
#include <fun>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new g_ignor_w = false 

public plugin_init() { 
      register_plugin(PLUGIN, VERSION, AUTHOR)
     
      register_event("HLTV", "eventRoundStart", "a", "1=0", "2=0")
 
      register_clcmd("say /free", "cmdFree") 

      RegisterHam(Ham_Touch, "weaponbox", "fwdTouch")   
}

public eventRoundStart()
{   
      g_ignor_w = false
}

public cmdFree()
{
      g_ignor_w = true
}

public fwdTouch(ent, id) {
   
    if( g_ignor_w )
    {
          if (is_user_alive(id))   
          return HAM_SUPERCEDE   
   
          return HAM_IGNORED     
    }
    //warning here :(
}

also 2 warnings
it should ignore weapon when somebody say /free
But it makes it all the time. I cant pick up guns.

Nyuszy 04-03-2011 07:44

Re: ham weaponbox
 
PHP Code:

new bool:g_ignor_w 

PHP Code:

public cmdFree(id

PHP Code:

public fwdTouch(entid) {
    
    if( 
g_ignor_w )
    {
          if (
is_user_alive(id))   
               return 
HAM_SUPERCEDE       
    
}
    return 
HAM_IGNORED  



ConnorMcLeod 04-03-2011 09:06

Re: ham weaponbox
 
PHP Code:

#include <amxmodx>     
#include <hamsandwich>     

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new g_ignor_w[33// so each player can enable/disable

public plugin_init()
{   
    
register_plugin(PLUGINVERSIONAUTHOR
    
register_clcmd("say /free""cmdFree")   
    
RegisterHam(Ham_Touch"weaponbox""fwdTouch")     
    
RegisterHam(Ham_Touch"weapon_shield""fwdTouch")     
    
RegisterHam(Ham_Touch"armoury_entity""fwdTouch")     
}

public 
client_putinserverid )
{
    
g_ignor_w[id] = false // set to false when player enter the server
}

public 
cmdFree() 
{
    
// switch ability
    
g_ignor_w[id] = !g_ignor_w[id]
}

public 
fwdTouch(entid) {
    
    if( 
g_ignor_w[id] && is_user_alive(id) )
    {    
        return 
HAM_SUPERCEDE      
    
}
    
//NO MORE warning here :(
    
return HAM_IGNORED



neverminde 04-03-2011 09:30

Re: ham weaponbox
 
Works perfectly, thanks !


All times are GMT -4. The time now is 14:31.

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