now everything compiles well, all the function works, but the infecting
Code:
/*
Dangerous Air
Version 0.1.1
n0obie4life
Description -
This plugin will make the air in your map dangerous ;).
Damages your players every <time you define> @ <amount of hp>.
Your players can buy a Oxygen Tank for a <price you define>.
Changelog -
07/06/05 - Started Work
08/06/05 - Fixed Bugs (Unreleased) (V 0.0.2)
08/06/05 - Removed "Oxygen Tank lasts for <time>" (V 0.1.0)
09/06/05 - Fixed Bugs (Unreleased) (V 0.1.1)
Credits -
AssKicR borrowed some code from his plugin (Admin Poison)
*/
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#define ADMIN_LEVEL_NEED ADMIN_LEVEL_A // Change the Admin Level A to whatever levels to define what level of admin you need to use the commands.
new airinfect = 0
new hasoxygentank[33]
public plugin_init() {
register_plugin("Dangerous Air","0.1.1","n0obie4life")
// Admin Commands
register_concmd("amx_air","dangerair",ADMIN_LEVEL_NEED,"- amx_air <1|0> Enables or Disables Dangerous Air")
register_concmd("amx_givetank","givetank",ADMIN_LEVEL_NEED," - amx_givetank <authid, nick, @team, * or #userid> Gives Oxygen Tank")
register_concmd("amx_removetank","removetank",ADMIN_LEVEL_NEED," - amx_removetank <authid, nick, @team, * or #userid> Removes Oxygen Tank")
// Client Commands
register_concmd("/buytank","buytank",0," - /buytank to buy Oxygen Tank in Infectious Air mode")
// Cvars
register_cvar("air_damagetime","5")
register_cvar("air_damangehp","10")
register_cvar("air_tankcost","12000")
//Events
register_event("ResetHUD","newround","b")
set_task(0.2,"infect",0,"",0,"b") // Infect them!
set_task(1.0,"cost_force",0,"",0,"b") // This is used to force the cost
}
public client_connect(id){
hasoxygentank[id]=false
}
public client_disconnect(id){
hasoxygentank[id]=false
}
public newround(id) {
hasoxygentank[id]=false
}
public dangerair(id,level,cid){
if (!cmd_access(id,level,cid,2)){
client_print(id,print_console,"You do not have the needed flags to use this command.")
return PLUGIN_HANDLED
}
new arg[2]
read_argv(1,arg,1)
if(equal(arg, "1")){
airinfect = 1
client_print(0,print_chat,"Infectious Air Enabled!")
client_print(0,print_chat,"Type /buytank to buy Oxygen Tank")
} else if(equal(arg, "0")){
airinfect = 0
client_print(0,print_chat,"Infectious Air Diabled!")
client_print(0,print_chat,"Everything should be back to normal :)")
}
return PLUGIN_HANDLED
}
public givetank(id,level,cid){
if (!cmd_access(id,level,cid,2)){
client_print(id,print_chat,"You do not have the needed flags to use this command.")
return PLUGIN_HANDLED
}
new target[32]
read_argv(1,target,31)
new admin[32]
get_user_name(id,admin,31)
if (target[0]=='@') {
new team[32], inum
get_players(team,inum,"e",target[1])
if (inum==0) {
console_print(id,"[AMXX] No clients found on such team.")
return PLUGIN_HANDLED
}
for (new i=0;i<inum;++i) {
hasoxygentank[team[i]]=true
client_print(0,print_chat,"ADMIN %s gave all %s an Oxygen Tank!",admin,target[1])
}
}
else if (target[0]=='*') {
new all[32], inum
get_players(all,inum)
for (new i=0;i<inum;++i) {
hasoxygentank[all[i]]=true
client_print(0,print_chat,"ADMIN %s gave everybody an Oxygen Tank!",admin)
}
}
else {
new player = cmd_target(id,target,0)
new playername[32]
get_user_name(player,playername,31)
if (!player) {
return PLUGIN_HANDLED
}
hasoxygentank[player]=true
client_print(0,print_chat,"ADMIN %s gave %s an Oxygen Tank!",admin,playername)
}
return PLUGIN_HANDLED
}
public removetank(id,level,cid){
if (!cmd_access(id,level,cid,2)){
client_print(id,print_chat,"You do not have the needed flags to use this command.")
return PLUGIN_HANDLED
}
new target[32]
read_argv(1,target,31)
new admin[32]
get_user_name(id,admin,31)
if (target[0]=='@') {
new team[32], inum
get_players(team,inum,"e",target[1])
if (inum==0) {
console_print(id,"[AMXX] No clients found on such team.")
return PLUGIN_HANDLED
}
for (new i=0;i<inum;i++) {
hasoxygentank[team[i]]=false
client_print(0,print_chat,"ADMIN %s has sabotaged all of the %s' Oxygen Tank.",admin,target[1])
}
}
else if (target[0]=='*') {
new all[32], inum
get_players(all,inum)
for (new i=0;i<inum;++i) {
hasoxygentank[all[i]]=false
client_print(0,print_chat,"ADMIN %s has sabotaged everyone's Oxygen Tank.",admin)
}
}
else {
new player = cmd_target(id,target,0)
new playername[32]
get_user_name(player,playername,31)
if (!player) {
return PLUGIN_HANDLED
}
hasoxygentank[player]=false
client_print(0,print_chat,"ADMIN %s has sabotaged %s's Oxygen Tank.",admin,playername)
}
return PLUGIN_HANDLED
}
public infect() {
new players[32], all_num
get_players(players,all_num, "a")
for (new id=1; id<=32; id++) {
new dmghp = get_cvar_num("air_damagehp")
new health = get_user_health(id)
if((!hasoxygentank[id]) && (airinfect == 1) && (is_user_alive(id)))
{
set_user_health(id, health - dmghp )
}
if ( health - dmghp <= 0 ) {
client_print(id,print_chat,"Buy an Oxygen Tank next round to prevent death from infection")
}
}
}
public cost_force(){
if (get_cvar_num("air_tankcost") < 1500) {
set_cvar_num("air_tankcost",1500)
}
if (get_cvar_num("air_tankcost") > 16000) {
set_cvar_num("air_tankcost",16000)
}
}
public buytank(id){
new name[32]
get_user_name(id,name,31)
new price = get_cvar_num("air_tankcost")
new usercash = cs_get_user_money(id)
if(airinfect == 0){
client_print(id,print_chat,"Air Infection is turned off.");
}
if (usercash < price){ // Lets check if the user has enough money
client_print(id,print_chat,"You have insufficient funds!")
client_print(id,print_chat,"You need $%i to buy an Oxygen Tank",price)
return PLUGIN_HANDLED
}
if (!is_user_alive(id)){
client_print(id,print_center,"You cannot buy while dead.")
return PLUGIN_HANDLED
}
if (hasoxygentank[id]){ // Lets check if user already has an Oxygen Tank
client_print(id,print_chat,"You already have an Oxygen Tank!")
return PLUGIN_HANDLED
}
else if (usercash >= price) { // So the user bought the Oxygen Tank
hasoxygentank[id]=true
cs_set_user_money(id,usercash - price,1)
client_print(id,print_chat,"You bought your Oxygen Tank!")
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}