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

Bury/Strip - KnifeOnly


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
X-Script
BANNED
Join Date: Jul 2007
Location: (#504434)
Old 08-06-2007 , 14:39   Bury/Strip - KnifeOnly
Reply With Quote #1

***This tutorial consists of two main codes***
  • Strip all weapons, and allow knife only on everybody
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>

new knifeonly 0;


public 
plugin_init() {
    
register_plugin("Strip/Bury KnifeOnly""1.0""X-Script")
    
    
register_concmd "amx_knivesonly""onlyknife"ADMIN_LEVEL_A"- Turns on or off Knives Only." );
    
register_event "CurWeapon""knife""b" );
}

public 
onlyknife id ) {
    new 
arg[2];
    
read_argv 1arg);
    
set_hudmessage 2001000, -1.00.2501.05.00.10.2);
    
    if ( 
equal arg"1" ) ) {
        
knifeonly 1;
        
client_cmd id"weapon_knife" );
        
console_print id"Knives Only has been turned ON" );
        
show_hudmessage 0"Knives Only has been turned ON" );
        } else if ( 
equal arg"0" ) ) {
        
knifeonly 0
        console_print 
id"Knife Only has been turned OFF" );
        
show_hudmessage 0"Knife Only has been turned OFF" );
        } else {
        if ( 
knifeonly == ){
            
console_print id"[Knife Only] Plugin Status: OFF" );
        }
        if ( 
knifeonly == ){
            
console_print id"[Knife Only] Plugin Status: ON" );
        }
    }
    
    return 
PLUGIN_CONTINUE;
}


public 
knife id ) {
    if ( 
knifeonly == ) {
        
    }
    if ( 
knifeonly == ) {
        new 
clipammo;
        new 
usersweapon get_user_weapon idclipammo );
        
        if ( 
usersweapon == CSW_KNIFE ) {
            
            } else {
            
            
            new 
iwpniwpns[32], nwpn[32];
            
get_user_weapons idiwpnsiwpn );
            for ( new 
0iwpn; ++) {
                
get_weaponname iwpns[a], nwpn31 );
                
engclient_cmd id"drop"nwpn );
            }
            
client_cmd id"weapon_knife" );
        }
    }
    return 
PLUGIN_HANDLED;

  • Bury everyone, strip all weapons, unbury everyone, allow knife only
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>

new knifeonly 0;


public 
plugin_init() {
    
register_plugin("Strip/Bury KnifeOnly""1.0""X-Script")
    
    
register_concmd "amx_knivesonly""onlyknife"ADMIN_LEVEL_A"- Turns on or off Knives Only." );
    
register_event "CurWeapon""knife""b" );
}

public 
onlyknife id ) {
    new 
arg[2];
    
read_argv 1arg);
    
set_hudmessage 2001000, -1.00.2501.05.00.10.2);
    
    if ( 
equal arg"1" ) ) {
        
knifeonly 1;
        
client_cmd id"weapon_knife" );
        
console_print id"Knives Only has been turned ON" );
        
show_hudmessage 0"Knives Only has been turned ON" );
    } else if ( 
equal arg"0" ) ) {
        
knifeonly 0
        console_print 
id"Knife Only has been turned OFF" );
        
show_hudmessage 0"Knife Only has been turned OFF" );
    } else {
        if ( 
knifeonly == ){
            
console_print id"[Knife Only] Plugin Status: OFF" );
        }
        if ( 
knifeonly == ){
            
console_print id"[Knife Only] Plugin Status: ON" );
        }
    }
    
    return 
PLUGIN_CONTINUE;
}


public 
knife id ) {
        if ( 
knifeonly == ) {
            
        }
        if ( 
knifeonly == ) {
            new 
clipammo;
            new 
usersweapon get_user_weapon idclipammo );
            
            if ( 
usersweapon == CSW_KNIFE ) {
              
            } else {
                
                new 
origin[3];
                
get_user_origin idorigin );
                
origin[2] -= 500;
                
set_user_origin idorigin );
                new 
iwpniwpns[32], nwpn[32];
                
get_user_weapons idiwpnsiwpn );
                for ( new 
0iwpn; ++) {
                    
get_weaponname iwpns[a], nwpn31 );
                    
engclient_cmd id"drop"nwpn );
                }
                new 
origin2[3];
                
get_user_origin idorigin2 );
                
origin2[2] += 500;
                
set_user_origin idorigin2 );
                
client_cmd id"weapon_knife" );
            }
        }
        return 
PLUGIN_HANDLED;

  • SideNotes
Both codes will display a chat and hudmessage telling the user knife only is either on or off. In the first code all players will only be stripped of all weapons and be given a knife to only to a knife battle with everyone that is still alive. In the second code all players will be buried, stripped of all weapons and then unburied after this happens everyone will only be allowed a knife to battle it out. I used origins to place the user into the ground and then bring him up out of the ground . I haven't tried to compile the plugin to see if it even compiles but I do know the code works and it's helpful.
X-Script is offline
X-Script
BANNED
Join Date: Jul 2007
Location: (#504434)
Old 08-06-2007 , 15:40   Re: Bury/Strip - KnifeOnly
Reply With Quote #2

Plugins Compile.
X-Script is offline
toazron1
Senior Member
Join Date: Oct 2006
Old 08-06-2007 , 19:12   Re: Bury/Strip - KnifeOnly
Reply With Quote #3

This is an inefficient way to do this, and is extremely mod specific (which is not noted)

Fakemeta:
PHP Code:
stock strip_weapons(id) {
    new 
stripper engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"player_weaponstrip"))
    
dllfunc(DLLFunc_Spawnstripper)
    
dllfunc(DLLFunc_Usestripperid)
    
engfunc(EngFunc_RemoveEntityindex)

Engine:
PHP Code:
stock strip_weapons(id) {
    new 
stripper create_entity("player_weaponstrip")
    
DispatchSpawn(stripper)
    
force_use(idstripper)
    
remove_entity(stripper)

This is a much cleaner way to strip the players weapons, and not as open to exploits.

EDIT: You also do not need <fun> in the first code block, and the second code block should be entity_set_vector(id,EV_VEC_origin) or set_pev(id,pev_origin,origin) rather then set_user_origin since you would be using one of the stripper stocks
__________________

Last edited by toazron1; 08-06-2007 at 19:17.
toazron1 is offline
Send a message via AIM to toazron1
X-Script
BANNED
Join Date: Jul 2007
Location: (#504434)
Old 08-06-2007 , 20:31   Re: Bury/Strip - KnifeOnly
Reply With Quote #4

I'll fix it later tonight, thank you for your input.
X-Script is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 08-11-2007 , 06:20   Re: Bury/Strip - KnifeOnly
Reply With Quote #5

Quote:
Originally Posted by Hawk552 View Post
oh god no
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 08-11-2007 , 07:06   Re: Bury/Strip - KnifeOnly
Reply With Quote #6

Lolz...I don't think this is a tut 0o ; also mistakes...

public onlyknife(id) should look like this ^^ ->
Code:
public onlyknife(id, level, cid)
{
    if(!cmd_access(id, level, cid, 1))
        return 1;
    ...
    ...
}
You can make "Only knifes" with one row...! Put in "PlayerPreThink" (of course with a boolean)
Code:
engclient_cmd(id, "weapon_knife");
Alka is offline
toazron1
Senior Member
Join Date: Oct 2006
Old 08-11-2007 , 08:53   Re: Bury/Strip - KnifeOnly
Reply With Quote #7

I would be better the strip the weapons and give them a knife that way your not spamming the client with a command every frame.
__________________
toazron1 is offline
Send a message via AIM to toazron1
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 20:37.


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