Raised This Month: $ Target: $400
 0% 

Code Explanation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Waleed
Senior Member
Join Date: May 2012
Location: Pakistan
Old 06-17-2012 , 01:55   Code Explanation
Reply With Quote #1

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.!
__________________
Working On:
  1. Gameplay 1 - 0% [PAUSED]
Waleed is offline
Send a message via Skype™ to Waleed
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-17-2012 , 04:05   Re: Code Explanation
Reply With Quote #2

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; }
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Old 06-17-2012, 04:20
Waleed
This message has been deleted by Waleed. Reason: Wrong comment
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-17-2012 , 04:23   Re: Code Explanation
Reply With Quote #3

It's more efficient to remove those weapons, why do you want to keep them on ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Waleed
Senior Member
Join Date: May 2012
Location: Pakistan
Old 06-17-2012 , 04:26   Re: Code Explanation
Reply With Quote #4

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!
__________________
Working On:
  1. Gameplay 1 - 0% [PAUSED]
Waleed is offline
Send a message via Skype™ to Waleed
Waleed
Senior Member
Join Date: May 2012
Location: Pakistan
Old 06-17-2012 , 04:27   Re: Code Explanation
Reply With Quote #5

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;
}

__________________
Working On:
  1. Gameplay 1 - 0% [PAUSED]
Waleed is offline
Send a message via Skype™ to Waleed
Waleed
Senior Member
Join Date: May 2012
Location: Pakistan
Old 06-17-2012 , 06:00   Public Tag Usage
Reply With Quote #6

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?
__________________
Working On:
  1. Gameplay 1 - 0% [PAUSED]
Waleed is offline
Send a message via Skype™ to Waleed
Waleed
Senior Member
Join Date: May 2012
Location: Pakistan
Old 06-17-2012 , 07:01   Re: Public Tag Usage
Reply With Quote #7

Please Reply,Everything is stuck just because of these constants and functions...
__________________
Working On:
  1. Gameplay 1 - 0% [PAUSED]
Waleed is offline
Send a message via Skype™ to Waleed
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-17-2012 , 07:26   Re: Public Tag Usage
Reply With Quote #8

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.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 06-17-2012 at 07:33.
hornet is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-17-2012 , 07:29   Re: Public Tag Usage
Reply With Quote #9

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.
Backstabnoob is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-17-2012 , 07:32   Re: Code Explanation
Reply With Quote #10

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 */ }
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet 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 06:07.


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