AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   invalid expression :D (https://forums.alliedmods.net/showthread.php?t=14088)

n0obie4life 06-09-2005 02:46

invalid expression :D
 
Code:
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)     {     set_user_health(id, health - dmghp )     }     if ( health - dmghp <= 0 )     {     client_print(id,print_chat,"You have just died from the infectious air.")     client_print(id,print_chat,"Remember to buy an Oxygen Tank next round :D")         }     } }

this 2 lines

Code:
    if(!hasoxygentank[id]) & (airinfect == 1)     {

errors

Code:

/home/groups/amxmodx/tmp/nVge9qAd.sma(197) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp/nVge9qAd.sma(197 -- 198) : error 029: invalid expression, assumed zero

and will that part of the code work? its suppose to minus a defined amount hp on everyone unless he has an oxygen tank :D

v3x 06-09-2005 03:38

Code:
if((!hasoxygentank[id]) && (airinfect == 1)) {

n0obie4life 06-09-2005 07:18

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 }

and yes, can someone teach me how to modify

Code:
set_task(0.2,"infect",0,"",0,"b") // Infect them!

so that it listens to the cvar air_damagetime?

thanks, you'll be in my credit list for teh plugin :D

v3x 06-09-2005 07:24

Huh? What do you mean?

n0obie4life 06-09-2005 07:29

you see v3x....that plugin is suppose to deduct people's hp at a rate of <time defined> for <hp defined> .

it doesn't deduct :( ...

n0obie4life 06-10-2005 22:51

bump da bump :D

n0obie4life 06-15-2005 03:45

bump again..

v3x 06-15-2005 04:04

Change
Code:
new hasoxygentank[33]
to 32.

Also.. You've got your cvar spelled wrong:
Code:
register_cvar("air_damangehp","10")

To get your task to work w/ your cvar, do this:
Code:
set_task(float(get_cvar_num("air_damagetime")),"infect",0,"",0,"b") // Infect them!

BAILOPAN 06-15-2005 07:59

Quote:

Originally Posted by v3x
Change
Code:
new hasoxygentank[33]
to 32.

No, don't. I don't like seeing people propogate the "[32]" myth. If you have a 32 player server, you need to have 32 slots in the array. [32] only gives you 31, because there is no player "0".


Also, float(get_cvar_num("air_damagetime")) looks unnecessary when you can use get_cvar_float().

v3x 06-15-2005 08:21

Aww.. You owned me, Bail. :(


All times are GMT -4. The time now is 16:50.

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