Raised This Month: $ Target: $400
 0% 

Knives Only not drop bomb


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BoK | Krazy
Member
Join Date: Dec 2005
Location: Dayton, OH
Old 12-30-2005 , 15:36   Knives Only not drop bomb
Reply With Quote #1

I need help trying to recode this for my private use so that when knives only is on it does not drop the bomb. I have tried some stuff and had no luck. Usually i am pretty good with guess and checking.

Code:
/*********************************************************************
AMX Mod Script
Created by BillyTheKid
Test it first @ 69.31.7.140:27016
Knives Only
Version 0.7
Email = admin@madtechview

Commands -
amx_knivesonly <1|0> Default off

1 = on
0 = off

Client Command -
say /voteknivesonly
Starts a vote to turn knives Only On and off...


Description - This will force users to knife only
              If guns are drawn they will be dropped


BugFixes    - Added Admin Level Access to the amx_knivesonly Command
  		  and added vote Level Access for the /voteknivesonly

Added - 	  I added a command for voting instead of /voteknivesonly 
              an admin can do a amx_voteknivesonly

Thanks to Zaltoa @ [email protected]
I used his code as a template to make this one 
*********************************************************************/

#include <amxmodx>
#include <amxmisc>


new knifeonly = 0
new choice[2]
new voteknifesonly[] = "\yKnives Only?\w^n^n1. On^n2. Off"

public plugin_init(){
register_plugin("Knives Only","0.1","BillyTheKid")
register_concmd("amx_knivesonly","cmdknifes_only",ADMIN_LEVEL_A,"- disable and enable knife war 1 = on 0 = off")
register_concmd("amx_voteknivesonly","cmdvoteknifes_only",ADMIN_LEVEL_A,"- Starts a vote for Knives Only")
register_concmd("say /voteknivesonly","cmdvote",ADMIN_LEVEL_A,"- Starts a vote for Knives Only")
register_menucmd(register_menuid("\yKnives Only?"),(1<<0)|(1<<1),"count_votes")
register_event("CurWeapon","knife","b")
}

public cmdknifes_only(id){
   new arg[2]
   read_argv(1,arg,1)

   new cAdmin[32], cAuthid[32] 
   get_user_name(id, cAdmin, 31) 
   get_user_authid(id, cAuthid, 31) 
   set_hudmessage(200, 100, 0, -1.0, 0.25, 0, 1.0, 5.0, 0.1, 0.2, 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.")
   log_amx("%s<%s> has turned Knives Only on", cAdmin, cAuthid)
   } else if(equal(arg,"0")){
   knifeonly = 0
   console_print(id,"Knives Only has been turned off.")
   show_hudmessage(0,"Knives Only has been turned off.")
   log_amx("%s<%s> has turned Knives Only off", cAdmin, cAuthid)
   } else {
   if (knifeonly==0){
   console_print(id,"Usage: amx_knivesonly 1 = 0n 0 = off Currently: OFF")
   }
   if (knifeonly==1){
   console_print(id,"Usage: amx_knivesonly 1 = 0n 0 = off Currently: ON")
   }
   }
   return PLUGIN_CONTINUE
   }

public knife(id){
        if(knifeonly==0){
            //nothing
        }
        if(knifeonly==1){
            new clip, ammo
            new usersweapon = get_user_weapon(id,clip,ammo)
            client_cmd(id, "drop")
            if(usersweapon==CSW_KNIFE) {
                //nothing
            } else {
                client_cmd(id,"weapon_knife")
            }
        }
        return PLUGIN_CONTINUE
}

public cmdvote(id){
    new Float:voting = get_cvar_float("amx_last_voting")
    new cAdmin[32], cAuthid[32] 
    get_user_name(id, cAdmin, 31) 
    get_user_authid(id, cAuthid, 31)
    if (voting > get_gametime()){
        client_print(id,print_chat,"*A vote has already been cast.*")
        return PLUGIN_HANDLED
    }
    if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) {
        client_print(id,print_chat,"*Please wait awhile before you can vote again.*")
        return PLUGIN_HANDLED
    }
    new menu_msg[256]
    format(menu_msg,255,voteknifesonly)
    new Float:votetime = get_cvar_float("amx_vote_time") + 10.0
    set_cvar_float("amx_last_voting",  get_gametime() + votetime )
    show_menu(0,(1<<0)|(1<<1),menu_msg,floatround(votetime))
    set_task(votetime,"check_the_votes")
    client_print(0,print_chat,"*Voting has started.*")
    log_amx("%s<%s> started a vote for Knives Only", cAdmin, cAuthid)
    choice[0]=choice[1]=0
    return PLUGIN_HANDLED     
}

public cmdvoteknifes_only(id){
    new cAdmin[32], cAuthid[32] 
    get_user_name(id, cAdmin, 31) 
    get_user_authid(id, cAuthid, 31)
    new Float:voting = get_cvar_float("amx_last_voting")
    if (voting > get_gametime()){
        client_print(id,print_chat,"*A vote has already been cast.*")
        return PLUGIN_HANDLED
    }
    if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime()) {
        client_print(id,print_chat,"*Please wait awhile before you can vote again.*")
        return PLUGIN_HANDLED
    }
    new menu_msg[256]
    format(menu_msg,255,voteknifesonly)
    new Float:votetime = get_cvar_float("amx_vote_time") + 10.0
    set_cvar_float("amx_last_voting",  get_gametime() + votetime )
    show_menu(0,(1<<0)|(1<<1),menu_msg,floatround(votetime))
    set_task(votetime,"check_the_votes")
    client_print(0,print_chat,"*Voting has started.*")
    log_amx("%s<%s> started a vote for Knives Only", cAdmin, cAuthid)
    choice[0]=choice[1]=0
    return PLUGIN_HANDLED     
}


public count_votes(id,key){
    if (get_cvar_float("amx_vote_answers") ) {
        new name[32]
        get_user_name(id,name,31)
        client_print(0,print_chat,"* %s voted %s", name, key ? "against Knives Only" : "for Knives Only" )
    }
    ++choice[key]
    return PLUGIN_HANDLED
}

public check_the_votes(id){
    if (choice[0] > choice[1]){
        server_cmd("amx_knivesonly 1")
        client_print(0,print_chat,"* Votes For Knives Only Succeded (yes ^"%d^") (no ^"%d^"). *",choice[0],choice[1])
    } else {
        server_cmd("amx_knivesonly 0")
        client_print(0,print_chat,"* Votes Against Knives Only Succeded (yes ^"%d^") (no ^"%d^"). *",choice[0],choice[1])
    }
    return PLUGIN_CONTINUE
}
I am guessing you have to change something in this area
Code:
public knife(id){
        if(knifeonly==0){
            //nothing
        }
        if(knifeonly==1){
            new clip, ammo
            new usersweapon = get_user_weapon(id,clip,ammo)
            client_cmd(id, "drop")
            if(usersweapon==CSW_KNIFE) {
                //nothing
            } else {
                client_cmd(id,"weapon_knife")
            }
        }
        return PLUGIN_CONTINUE
}
__________________
BoK | Krazy is offline
Send a message via AIM to BoK | Krazy
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 12-30-2005 , 15:55  
Reply With Quote #2

Code:
public knife(id){         if(knifeonly==0){             //nothing         }         if(knifeonly==1){             new clip, ammo             new usersweapon = get_user_weapon(id,clip,ammo)             client_cmd(id, "drop")             if(usersweapon==CSW_KNIFE || usersweapon == CSW_C4) {                 //nothing             } else {                 client_cmd(id,"weapon_knife")             }         }         return PLUGIN_CONTINUE }
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 12-30-2005 , 16:00  
Reply With Quote #3

Code:
register_event("CurWeapon","knife","b" "1=1") public knife(id) {     if(knifeonly)     {         new wpID = read_data(2)         if(wpID != CSW_KNIFE || wpID != CSW_C4)         {             engclient_cmd(id, "weapon_knife")         } }
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 12-30-2005 , 16:03  
Reply With Quote #4

I was going to optimize it a bit as well, but I decided not to change the original code for whatever reason.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
BoK | Krazy
Member
Join Date: Dec 2005
Location: Dayton, OH
Old 12-30-2005 , 16:26  
Reply With Quote #5

Quote:
Originally Posted by v3x
Code:
public knife(id){         if(knifeonly==0){             //nothing         }         if(knifeonly==1){             new clip, ammo             new usersweapon = get_user_weapon(id,clip,ammo)             client_cmd(id, "drop")             if(usersweapon==CSW_KNIFE || usersweapon == CSW_C4) {                 //nothing             } else {                 client_cmd(id,"weapon_knife")             }         }         return PLUGIN_CONTINUE }
That was the first thing I tried before I came here and it did not work. And I tried again and still no luck.


Quote:
Originally Posted by teame06
Code:
register_event("CurWeapon","knife","b" "1=1") public knife(id) {     if(knifeonly)     {         new wpID = read_data(2)         if(wpID != CSW_KNIFE || wpID != CSW_C4)         {             engclient_cmd(id, "weapon_knife")         } }
I tried this and I like how it does not drop the weapons and does not let you shoot guns or throw nades, but still does not let me take out bomb.

This is what i changed tell me if I did anything wrong.
Code:
public knife(id){
        if(knifeonly==0){
            //nothing
        }
        if(knifeonly==1){
            new clip, ammo
            new usersweapon = get_user_weapon(id,clip,ammo)
            client_cmd(id, "drop")
            if(usersweapon==CSW_KNIFE) {
                //nothing
            } else {
                client_cmd(id,"weapon_knife")
            }
        }
        return PLUGIN_CONTINUE
}
to
Code:
public knife(id)
{
	if(knifeonly)
	{
		new wpID = read_data(2)
		if(wpID != CSW_KNIFE || wpID != CSW_C4)
		{
			engclient_cmd(id, "weapon_knife")
                }
        }
        return PLUGIN_CONTINUE
}
and i changed
Code:
register_event("CurWeapon","knife","b")
to
Code:
register_event("CurWeapon","knife","b","1=1")
__________________
BoK | Krazy is offline
Send a message via AIM to BoK | Krazy
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 12-30-2005 , 16:30  
Reply With Quote #6

On teame06's code change || to && here:
Code:
if(wpID != CSW_KNIFE || wpID != CSW_C4)
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 12-30-2005 , 16:32  
Reply With Quote #7

Code:
public knife(id) {     if(knifeonly)     {         new wpID = read_data(2)         if(wpID == CSW_KNIFE || wpID == CSW_C4)             return PLUGIN_CONTINUE         else             engclient_cmd(id, "weapon_knife")     }     return PLUGIN_CONTINUE }

try that.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
BoK | Krazy
Member
Join Date: Dec 2005
Location: Dayton, OH
Old 12-30-2005 , 16:37  
Reply With Quote #8

Quote:
Originally Posted by v3x
On teame06's code change || to && here:
Code:
if(wpID != CSW_KNIFE || wpID != CSW_C4)
That worked! Thanks v3x and teame06!
__________________
BoK | Krazy is offline
Send a message via AIM to BoK | Krazy
meigyoku
BANNED
Join Date: Apr 2009
Old 05-10-2009 , 06:48   Re: Knives Only not drop bomb
Reply With Quote #9

Please complies it into plugin, thanks alot!
meigyoku is offline
Reply


Thread Tools
Display Modes

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 15:51.


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