Raised This Month: $12 Target: $400
 3% 

ham_give_weapon and ham_strip_weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-20-2011 , 18:19   Re: ham_give_weapon and ham_strip_weapon
Reply With Quote #51

Ham_AddPlayerItem would be best because you could stop player from receiving the c4 altogether rather than waiting for player to deploy it.

Also, your hook (3rd param) should be something like "FwdDeployC4" or something like that to avoid confusion.
If you were to go with the Ham_Item_Deploy method, you could just use ham_strip_weapon() with the owner of the deployed entity.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
FiFiX
Senior Member
Join Date: May 2008
Location: Poland
Old 06-20-2011 , 18:19   Re: ham_give_weapon and ham_strip_weapon
Reply With Quote #52

Quote:
Originally Posted by MeRcyLeZZ View Post
You can still use CurWeapon event, just set a task to call ham_strip_weapon, like
Code:
/* CurWeapon event */ set_task(0.1, "remove_c4", id)

Code:
public remove_c4(id) { if (!is_user_alive(id)) return; ham_strip_weapon(id, "weapon_c4") }

I know it's not pretty, but it shold get rid of "Run time error 3: stack error".
Oh and, tell me, the stack error occurs when event is executed and player is dead? Or when strip_weapon is executed and c4 is already removed?
FiFiX is offline
Send a message via Skype™ to FiFiX
FiFiX
Senior Member
Join Date: May 2008
Location: Poland
Old 06-20-2011 , 18:41   Re: ham_give_weapon and ham_strip_weapon
Reply With Quote #53

Oh, also I found that plugin with HamAddPlayerItem:
Code:
#include <amxmodx> #include <cstrike> #include <engine> 
#include <hamsandwich> 

#define PLUGIN "No C4" 
#define AUTHOR "ConnorMcLeod" 
#define VERSION "0.1.0"  

public plugin_init() {
     register_plugin(PLUGIN, VERSION, AUTHOR)

     RegisterHam(Ham_AddPlayerItem, "player", "Player_AddPlayerItem")
 }  

public Player_AddPlayerItem( id , iWeapon ) {

     if( cs_get_weapon_id( iWeapon ) == CSW_C4 )
     { 
         cs_set_user_plant(id, 0, 0)
         entity_set_int(id, EV_INT_body, 0) 
         SetHamReturnInteger( false )
         return HAM_SUPERCEDE
     }
     return HAM_IGNORED
 }
Is there possibility to remove nades in that function?

Last edited by FiFiX; 06-20-2011 at 18:43.
FiFiX is offline
Send a message via Skype™ to FiFiX
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-20-2011 , 18:47   Re: ham_give_weapon and ham_strip_weapon
Reply With Quote #54

You have to check if the weapon is a grenade.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
FiFiX
Senior Member
Join Date: May 2008
Location: Poland
Old 06-20-2011 , 18:50   Re: ham_give_weapon and ham_strip_weapon
Reply With Quote #55

Ye, ye, but how to remove them then?
FiFiX is offline
Send a message via Skype™ to FiFiX
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-20-2011 , 19:56   Re: ham_give_weapon and ham_strip_weapon
Reply With Quote #56

Use the ham_strip_weapon() like you were before?
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
FiFiX
Senior Member
Join Date: May 2008
Location: Poland
Old 06-21-2011 , 09:25   Re: ham_give_weapon and ham_strip_weapon
Reply With Quote #57

Anyway I did it that way:
Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <bajery>

#define PLUGIN "RR"
#define VERSION "1.0"
#define AUTHOR "FiFiX"

new const wpn_Names[][] = { "weapon_c4", "weapon_hegrenade", "weapon_smokegrenade", "weapon_flashbang" }


public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR);
    
    for (new i = 0; i < sizeof wpn_Names; i++)
        RegisterHam(Ham_Item_Deploy, wpn_Names[i], "current_wpn", 1);    
}

public current_wpn( iEnt )
{        
    new id = pev(iEnt, pev_owner);
    
    new weapon = get_user_weapon(id);
    
    switch(weapon)
    {
        case CSW_C4: ham_strip_weapon(id, "weapon_c4");
        case CSW_HEGRENADE: ham_strip_weapon(id, "weapon_hegrenade");
        case CSW_SMOKEGRENADE: ham_strip_weapon(id, "weapon_smokegrenade");
        case CSW_FLASHBANG: ham_strip_weapon(id, "weapon_flashbang");
    }
    return HAM_IGNORED;
}
And it doesn't work at all.
FiFiX is offline
Send a message via Skype™ to FiFiX
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-21-2011 , 12:47   Re: ham_give_weapon and ham_strip_weapon
Reply With Quote #58

Then use this one:

Code:
#include <amxmodx>
#include <cstrike>
#include <engine> 
#include <hamsandwich> 

#define PLUGIN "No C4" 
#define AUTHOR "ConnorMcLeod" 
#define VERSION "0.1.0"  

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)

    RegisterHam(Ham_AddPlayerItem, "player", "Player_AddPlayerItem")
}  

public Player_AddPlayerItem( id , iWeapon ) {
    switch( cs_get_weapon_id( iWeapon ) ) {
        case CSW_C4: {
            cs_set_user_plant(id, 0, 0)
            entity_set_int(id, EV_INT_body, 0) 
            SetHamReturnInteger( false )
            return HAM_SUPERCEDE
        }
        case CSW_HEGRENADE, CSW_FLASHBANG, CSW_SMOKEGRENADE: {
            SetHamReturnInteger( false )
            return HAM_SUPERCEDE
        }
    }
     return HAM_IGNORED
 }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
FiFiX
Senior Member
Join Date: May 2008
Location: Poland
Old 06-21-2011 , 18:05   Re: ham_give_weapon and ham_strip_weapon
Reply With Quote #59

It works now. Thank You
FiFiX is offline
Send a message via Skype™ to FiFiX
FiFiX
Senior Member
Join Date: May 2008
Location: Poland
Old 06-22-2011 , 18:29   Re: ham_give_weapon and ham_strip_weapon
Reply With Quote #60

And it doesn't work perfect. Sometimes it crashes the server.. Thats from console:
Code:
L 06/22/2011 - 14:31:46: Team "CT" triggered "CTs_Win" (CT "1") (T "0")
L 06/22/2011 - 14:31:46: World triggered "Round_End"
L 06/22/2011 - 14:31:51: "Czisburger z serem<245><STEAM_0:1:25620904><TERRORIST>" triggered "Spawned_With_The_Bomb"
L 06/22/2011 - 14:31:51: "Czisburger z serem<245><STEAM_0:1:25620904><TERRORIST>" triggered "Spawned_With_The_Bomb"
L 06/22/2011 - 14:31:52: Server cvar "sv_alltalk" = "0"
L 06/22/2011 - 14:31:52: Server cvar "mp_friendlyfire" = "1"
L 06/22/2011 - 14:31:52: Server cvar "sv_restart" = "1"
L 06/22/2011 - 14:31:52: World triggered "Restart_Round_(1_second)"
L 06/22/2011 - 14:31:52: Team "CT" scored "1" with "6" players
L 06/22/2011 - 14:31:52: Team "TERRORIST" scored "0" with "6" players
L 06/22/2011 - 14:31:52: Server cvar "sv_restart" = "0"
L 06/22/2011 - 14:31:53: "Czisburger z serem<245><STEAM_0:1:25620904><TERRORIST>" triggered "Spawned_With_The_Bomb"
L 06/22/2011 - 14:31:59: World triggered "Round_Start"
email debug.log to [email protected]
Wed Jun 22 14:32:01 CEST 2011: Server restart in 10 seconds
And that's the whole plugin where I used the code:
Code:
#include <amxmodx>
#include <cstrike>
#include <engine>
#include <hamsandwich>

#define PLUGIN "RR"
#define VERSION "1.0"
#define AUTHOR "FiFiX"

#define TASK_TIMER 43000

new r_counter;

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR);
    
    RegisterHam(Ham_AddPlayerItem, "player", "Player_AddPlayerItem");
    
    register_event("TextMsg","first_round","a","2&#Game_C");
    register_event("HLTV", "ev_roundstart", "a", "1=0", "2=0");
    
}

public first_round()
{
    if(!r_counter)
    {
        set_cvar_num("sv_alltalk", 1);
        set_cvar_num("mp_friendlyfire", 0);
        pause("ac","M_Antirusher_2.6_alfa.amxx");
        r_counter = 1;
    }
}

public ev_roundstart()
{
    if(!r_counter) return;

    switch(r_counter)
    {
        case 1:set_task(2.0, "restart_map", TASK_TIMER);
        case 2:set_task(1.0, "restart", TASK_TIMER);
    }   
    r_counter++;
}

public restart()    
{
    r_counter = 0;
    unpause("ac","M_Antirusher_2.6_alfa.amxx");
    set_cvar_num("sv_alltalk", 0);
    set_cvar_num("mp_friendlyfire", 1);
    set_cvar_num("sv_restart", 1);
}

public Player_AddPlayerItem( id , iWeapon ) 
{
    if(!r_counter) 
        return HAM_IGNORED;
            
    switch( cs_get_weapon_id( iWeapon ) ) 
    {
        case CSW_C4: 
        {
            cs_set_user_plant(id, 0, 0)
            entity_set_int(id, EV_INT_body, 0) 
            SetHamReturnInteger( false )
            return HAM_SUPERCEDE
        }
        case CSW_HEGRENADE, CSW_FLASHBANG, CSW_SMOKEGRENADE: 
        {
            SetHamReturnInteger( false )
            return HAM_SUPERCEDE
        }
    }
    return HAM_IGNORED
 }
 
public restart_map()
{
    new jac1=random_num(0,255);
    new jac2=random_num(0,255);
    new jac3=random_num(0,255);  
    
    set_hudmessage(jac1, jac2, jac3, 0.65, 0.75, 2, 0.02, 1.0, 0.01, 0.1, 10); 
    show_hudmessage(0,"====================^n RUNDA ROZGRZEWKOWA ^n KampNO Classic[TP] ^n====================");

    if(r_counter) 
        set_task(1.0, "restart_map", TASK_TIMER);
        
    return PLUGIN_HANDLED;
}
bajery.inc is file with ham_strip_weapon.

And the crash is after restart round.
FiFiX is offline
Send a message via Skype™ to FiFiX
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 13:38.


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