Raised This Month: $ Target: $400
 0% 

How do you read from a cfg file? [SOLVED]


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
mateo10
Veteran Member
Join Date: Jan 2006
Old 11-28-2006 , 09:40   How do you read from a cfg file? [SOLVED]
Reply With Quote #1

Hello I wonder what is wrong with this, and I wonder how do you read
from a cfg file? My version (read_from_file) has a few leaks (LOL).
What is the right way to do this?


Code:
#include <amxmodx> #include <fun> new cvar public plugin_init() {     register_plugin("Spelltime", "1.0", "MaTTe")     cvar = register_cvar("amx_spelltime", "1")     register_clcmd("say /spelltime", "cmd_spelltime")     register_clcmd("say_team /spelltime", "cmd_spelltime")     new basedir[64]     new cfgfile[64]     format(cfgfile, 63, "%s/addons/amxmodx/configs/spelltime/spelltime.cfg", basedir)     if(file_exists(cfgfile))     {         log_amx("[Spelltime] Loading cfgfile [spelltime.cfg]...")         server_cmd("exec %s", cfgfile)         log_amx("[Spelltime] Cfgfile loaded successfully.")     }else{         log_amx("[Spelltime] Cfgfile not found. [Pausing plugin]")         server_cmd("amxx pause spelltime")     }     return PLUGIN_CONTINUE } public cmd_spelltime(id) {     if(!get_pcvar_num(cvar))         return PLUGIN_HANDLED     new sound = read_from_file(cfgfile)     new sound2 = read_from_file(cfgfile)     new sound3 = read_from_file(cfgfile)     new sound4 = read_from_file(cfgfile)     new sound5 = read_from_file(cfgfile)     new rand = random_num(1, 5)     switch(rand)     {         case 1:         {             client_cmd(id, "play spelltime/%s.wav", sound)         }         case 2:         {             client_cmd(id, "play spelltime/%s.wav", sound2)         }         case 3:         {             client_cmd(id, "play spelltime/%s.wav", sound3)         }         case 4:         {             client_cmd(id, "play spelltime/%s.wav", sound4)         }         case 5:         {             client_cmd(id, "play spelltime/%s.wav", sound5)         }     }     new text[200]     read_args(text, 199)     if(rand==1)     {         if(containi(text, "i guess it is %s", sound)==1)         {             client_print(id, print_chat, "You guessed right! +5 health")             set_user_health(id, get_user_health(id)+5)         }else{             client_print(id, print_chat, "You guessed wrong! -5 health")             set_user_health(id, get_user_health(id)-5)         }     } else if(rand==2)     {         if(containi(text, "i guess it is %s", sound2)==1)         {             client_print(id, print_chat, "You guessed right! +5 health")             set_user_health(id, get_user_health(id)+5)         }else{             client_print(id, print_chat, "You guessed wrong! -5 health")             set_user_health(id, get_user_health(id)-5)         }     } else if(rand==3)     {         if(containi(text, "i guess it is %s", sound3)==1)         {             client_print(id, print_chat, "You guessed right! +5 health")             set_user_health(id, get_user_health(id)+5)         }else{             client_print(id, print_chat, "You guessed wrong! -5 health")             set_user_health(id, get_user_health(id)-5)         }     } else if(rand==4)     {         if(containi(text, "i guess it is %s", sound4)==1)         {             client_print(id, print_chat, "You guessed right! +5 health")             set_user_health(id, get_user_health(id)+5)         }else{             client_print(id, print_chat, "You guessed wrong! -5 health")             set_user_health(id, get_user_health(id)-5)         }     } else if(rand==5)     {         if(containi(text, "i guess it is %s", sound5)==1)         {             client_print(id, print_chat, "You guessed right! +5 health")             set_user_health(id, get_user_health(id)+5)         }else{             client_print(id, print_chat, "You guessed wrong! -5 health")             set_user_health(id, get_user_health(id)-5)         }     }     return PLUGIN_CONTINUE }

Last edited by mateo10; 12-01-2006 at 10:11.
mateo10 is offline
 



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 06:52.


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