Raised This Month: $ Target: $400
 0% 

make cvar wish changes something in your plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wouter
Senior Member
Join Date: Feb 2005
Location: Belgium
Old 03-04-2006 , 16:12   make cvar wish changes something in your plugin
Reply With Quote #1

Code:
/* Plugin generated by AMXX-Studio */         /*   Many help form Kraugh   Thx man   say \ammo                 // client cmd   say_team \ammo           // client cmd   amxx_ammoforhp  <1/0>   // enable / disable by admin   */       #include <amxmodx> #include <fun> #include <cstrike> #define PLUGIN "ammoforhp" #define VERSION "1.0" #define AUTHOR "wouter" public plugin_init()     {       register_plugin(PLUGIN, VERSION, AUTHOR)       register_clcmd("say /ammo", "cmd_ammo")       register_clcmd("say_team /ammo", "cmd_ammo")       register_cvar("amxx_ammoforhp", "1") }     public cmd_ammo(id) {           if ( ! get_cvar_num("amxx_ammoforhp") )           return PLUGIN_HANDLED         new AmmoCost = 10  // Change how much hp you loose for the ammo (hint: do not make it nagative - - becomes + :D)     new life = get_user_health(id)          if ( !is_user_alive(id) || life <= AmmoCost) {           client_print(id, print_chat, "[AmmoForHp] You are not alive or do not have enough HP!")           return PLUGIN_HANDLED       }         new clip, ammo, weapon = get_user_weapon(id,clip,ammo);               switch(weapon) {                 case CSW_P228: {             give_item(id,"ammo_357sig")         }         case CSW_SCOUT: {             give_item(id,"ammo_762nato")         }         case CSW_HEGRENADE: {             client_print(id, print_chat, "[AmmoForHp] There is no ammo for this item!")               return PLUGIN_HANDLED         }         case CSW_XM1014: {             give_item(id,"ammo_buckshot")                     }         case CSW_C4: {             client_print(id, print_chat, "[AmmoForHp] There is no ammo for this item!")               return PLUGIN_HANDLED         }         case CSW_MAC10: {             give_item(id,"ammo_45acp")         }         case CSW_AUG: {             give_item(id,"ammo_556nato")         }         case CSW_SMOKEGRENADE: {             client_print(id, print_chat, "[AmmoForHp] There is no ammo for this item!")               return PLUGIN_HANDLED         }         case CSW_ELITE: {             give_item(id,"ammo_9mm")         }         case CSW_FIVESEVEN: {             give_item(id,"ammo_57mm")         }         case CSW_UMP45: {             give_item(id,"ammo_45acp")         }         case CSW_SG550: {             give_item(id,"ammo_556nato")         }         case CSW_GALI: {             give_item(id,"ammo_308")   // do not give ammo => no errors         }         case CSW_FAMAS: {             give_item(id,"ammo_556nato")         }         case CSW_USP: {             give_item(id,"ammo_45acp")         }         case CSW_GLOCK18: {             give_item(id,"ammo_9mm")         }         case CSW_AWP: {             give_item(id,"ammo_338magnum")         }         case CSW_MP5NAVY: {             give_item(id,"ammo_9mm")         }         case CSW_M249: {             give_item(id,"ammo_556natobox")         }         case CSW_M3: {             give_item(id,"ammo_buckshot")                     }         case CSW_M4A1: {             give_item(id,"ammo_556nato")         }         case CSW_TMP: {             give_item(id,"ammo_9mm")         }         case CSW_G3SG1: {             give_item(id,"ammo_762nato")         }         case CSW_FLASHBANG: {             client_print(id, print_chat, "[AmmoForHp] There is no ammo for this item!")               return PLUGIN_HANDLED         }         case CSW_DEAGLE: {             give_item(id,"ammo_50ae")         }         case CSW_SG552: {             give_item(id,"ammo_556nato")         }         case CSW_AK47: {             give_item(id,"ammo_762nato")         }         case CSW_KNIFE: {             client_print(id, print_chat, "[AmmoForHp] There is no ammo for this item!")               return PLUGIN_HANDLED         }         case CSW_P90: {             give_item(id,"ammo_57mm")         }         default: return PLUGIN_CONTINUE     }         set_user_health(id, life - AmmoCost)     client_print(id, print_chat, "[AmmoForHp] You have exchanged health for ammo!")     return PLUGIN_HANDLED }
this is the plugin but i MUST ( ) make a cvar wish changes the
Code:
new AmmoCost = 10
but i dont know how to do that, i guess something with
Code:
register_cvar("amxx_ammoforhp_cost", "16000") read_argv(id, output[], len) get_cvar_num("amxx_ammoforhp_cost") set_cvar_num("amxx_ammoforhp_cost", value)
but put what were and how?
plz help me
wouter is offline
Jordan
Veteran Member
Join Date: Aug 2005
Old 03-04-2006 , 16:23  
Reply With Quote #2

Code:
    register_cvar("mp_ammocost", "10") //(later on in the code)     new AmmoCost = get_cvar_num("mp_ammocost")

Should work.
Jordan is offline
wouter
Senior Member
Join Date: Feb 2005
Location: Belgium
Old 03-04-2006 , 16:24  
Reply With Quote #3

ok i'll try it right now
wouter is offline
wouter
Senior Member
Join Date: Feb 2005
Location: Belgium
Old 03-04-2006 , 16:35  
Reply With Quote #4

uhu that works more then fine
no i only have one problem my ammo for the galil is wrong...
does someone know where i can get te right ammo name?
wouter is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 03-04-2006 , 16:48  
Reply With Quote #5

Quote:
Originally Posted by wouter
uhu that works more then fine
no i only have one problem my ammo for the galil is wrong...
does someone know where i can get te right ammo name?
ammo_556nato

I believe.
__________________
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
Jordan
Veteran Member
Join Date: Aug 2005
Old 03-04-2006 , 16:49  
Reply With Quote #6

It's the same as the m4 I think.

edit: freaking a v3x got it first.
Jordan is offline
wouter
Senior Member
Join Date: Feb 2005
Location: Belgium
Old 03-04-2006 , 16:53  
Reply With Quote #7

both right
thx guys
wouter is offline
Jordan
Veteran Member
Join Date: Aug 2005
Old 03-04-2006 , 16:54  
Reply With Quote #8

No problem.
Jordan is offline
Jordan
Veteran Member
Join Date: Aug 2005
Old 03-04-2006 , 17:29  
Reply With Quote #9

Edit: In 1.70, optimization would be like this:

Code:
#define PLUGIN "ammoforhp" #define VERSION "1.0" #define AUTHOR "wouter" //this is jsut to show where in the code you'd put this: new g_AmmoCost public plugin_init()     {       register_plugin(PLUGIN, VERSION, AUTHOR)       register_clcmd("say /ammo", "cmd_ammo")       register_clcmd("say_team /ammo", "cmd_ammo")       register_cvar("amxx_ammoforhp", "1")     g_AmmoCost = get_pcvar_num("mp_ammocost") }
Jordan is offline
wouter
Senior Member
Join Date: Feb 2005
Location: Belgium
Old 03-04-2006 , 17:40  
Reply With Quote #10

i'll do that in the morning
wouter 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 20:15.


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