AlliedModders

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

Waleed 06-17-2012 01:55

Code Explanation
 
Can anybody please explain me the below code briefly,Connor McLeod gave me this code to disable picking up ground weapons,It works,All the weapons on ground were not visible to anybody.But wanted to disable picking up not making them invisible,Can you provide me other method for this or explain me below code please


PHP Code:

    new armoury 
    
while( (armoury find_ent_by_class(armoury"armoury_entity")) > 
    { 
        
remove_entity(armoury
    } 


public 
Event_HLTV_New_Round() 

    new 
players[32], num 
    get_players
(playersnum"h"
    for(--
numnum>=0num--) 
    { 
        
set_pdata_bool(players[num], m_bNotReceivingMoneyNextRoundFalse
    } 


Thanks.!

hornet 06-17-2012 04:05

Re: Code Explanation
 
It loops through all default map weapon entities and removes them on each round start.

Instead, to block picking them up:
Code:
//plugin_init() RegisterHam( Ham_Touch, "weaponbox", "ham_TouchWeapon" );    //all dropped weapons RegisterHam( Ham_Touch, "armoury_entity", "ham_TouchWeapon" );    //all default map weapons RegisterHam( Ham_Touch, "weapon_shield", "ham_TouchWeapon" );    //all shields // public ham_TouchWeapon( /* iEnt, id */ ) {     return HAM_SUPERCEDE; }

ConnorMcLeod 06-17-2012 04:23

Re: Code Explanation
 
It's more efficient to remove those weapons, why do you want to keep them on ?

Waleed 06-17-2012 04:26

Re: Code Explanation
 
I don't want to disable weapons for Other clients,Only for person who uses (/giveme) command
Your code was impossible for me to understand,But,Thanks anyway!

Waleed 06-17-2012 04:27

Re: Code Explanation
 
Can I user it that way?
I want to disable pickups only for those who uses "/giveme" command.

PHP Code:

public plugin_init()
{
        
register_clcmd("say /giveme""cmd_GiveWeapon")
        
RegisterHamHam_Touch"weaponbox""ham_TouchWeapon" )   //all dropped weapons
    
RegisterHamHam_Touch"armoury_entity""ham_TouchWeapon" )    //all default map weapons
    
RegisterHamHam_Touch"weapon_shield""ham_TouchWeapon" )    //all shields
    
}

public 
cmd_GiveWeapon(id)
{

public 
ham_TouchWeapon/* iEnt, id */ )
{
    return 
HAM_SUPERCEDE;
}



Waleed 06-17-2012 06:00

Public Tag Usage
 
Can I user it that way?
I want to disable pickups only for those who uses "/giveme" command.

PHP Code:

public plugin_init() 

    
register_clcmd("say /giveme""cmd_GiveWeapon"
    
RegisterHamHam_Touch"weaponbox""ham_TouchWeapon" )   //all dropped weapons 
    
RegisterHamHam_Touch"armoury_entity""ham_TouchWeapon" )    //all default map weapons 
    
RegisterHamHam_Touch"weapon_shield""ham_TouchWeapon" )    //all shields 
     


public 
cmd_GiveWeapon(id


public 
ham_TouchWeapon/* iEnt, id */ 

    return 
HAM_SUPERCEDE



If not then how to use it for specific player?

Waleed 06-17-2012 07:01

Re: Public Tag Usage
 
Please Reply,Everything is stuck just because of these constants and functions...

hornet 06-17-2012 07:26

Re: Public Tag Usage
 
Don't make extra threads, I'm already in the process of answering your other one ... Don't bump either - you waited 1 hour for a response ... Don't be impatient.

Backstabnoob 06-17-2012 07:29

Re: Public Tag Usage
 
Create a global variable and set it's value in cmd_GiveWeapon handler. Then check whether the user has allowed it or not in the ham hook.

hornet 06-17-2012 07:32

Re: Code Explanation
 
No, you can't put a function header inside another. You would do it like this:
Code:
#include <amxmodx> #include <hamsandwich> new bool: g_bCanPickup[ 33 ]; new g_iMaxPlayers; public plugin_init() {     RegisterHam( Ham_Touch, "weaponbox", "ham_TouchWeapon" );     RegisterHam( Ham_Touch, "armoury_entity", "ham_TouchWeapon" );     RegisterHam( Ham_Touch, "weapon_shield", "ham_TouchWeapon" );         register_event( "HLTV", "Event_RoundStart", "a", "1=0", "2=0" );         register_clcmd( "say /giveme", "cmd_GiveWeapon" );         g_iMaxPlayers = get_maxplayers(); } public Event_RoundStart() {     for( new i = 1 ; i <= g_iMaxPlayers ; i ++ )         g_bCanPickup[ i ] = true; } public ham_TouchWeapon( iEnt, id ) {     if( !g_bCanPickup[ id ] )         return HAM_SUPERCEDE;             return HAM_IGNORED; } public cmd_GiveWeapon( id ) {     g_bCanPickup[ id ] = false;         /* do stuff here */ }


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

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