Raised This Month: $51 Target: $400
 12% 

Solved Need Code For CFG FILE


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Begineer Programmer
Member
Join Date: Nov 2021
Old 07-23-2022 , 22:49   Need Code For CFG FILE
Reply With Quote #1

I have Plugin and i want to pick mp_maxrounds from cfg file
addons/amxmodx/maps/%s.cfg
that %s is map name and i want to pick mp_maxrounds
can anyone make code on cfg file

Last edited by Begineer Programmer; 08-31-2022 at 05:57.
Begineer Programmer is offline
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 07-23-2022 , 23:17   Re: Need Code For CFG FILE
Reply With Quote #2

PHP Code:
new mp_maxrounds_pcvarmp_maxrounds;

public 
plugin_init()
{
    
/* ... */
    
mp_maxrounds_pcvar get_cvar_pointer("mp_maxrounds");
    
bind_pcvar_num(mp_maxrounds_pcvarmp_maxrounds);

Then you can address mp_maxrounds directly.
damage220 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-24-2022 , 01:46   Re: Need Code For CFG FILE
Reply With Quote #3

Map-specific config files are loaded automatically by AMX Mod X so there is no reason to do anything with those files directly. You simply need to read the cvar values like you would do for any cvar. damage220 gave you an example of one way to read the cvar value.
__________________
fysiks is offline
Begineer Programmer
Member
Join Date: Nov 2021
Old 07-24-2022 , 16:45   Re: Need Code For CFG FILE
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
Map-specific config files are loaded automatically by AMX Mod X so there is no reason to do anything with those files directly. You simply need to read the cvar values like you would do for any cvar. damage220 gave you an example of one way to read the cvar value.
Here is Code from your Github Admin.amxx that was admin per map config posted by CounterStrike1.6

PHP Code:
loadSettings()
{
    new 
configDir[64], filename[96]
    
get_configsdir(configDircharsmax(configDir))
    
format(filenamecharsmax(filename), "%s/users.ini"configDir)
    
loadUsersFile(filename)

    
// Load Map-Specific Admins
    
new szMapname[32], prefixBreak
    get_mapname
(szMapnamecharsmax(szMapname))

    
filename[0] = EOS
    format
(filenamecharsmax(filename), "%s/maps/users-%s.ini"configDirszMapname)
    
loadUsersFile(filename)

    if( ( 
prefixBreak strfind(szMapname"_") ) != -)
    {
        
szMapname[prefixBreak] = EOS
        filename
[0] = EOS
        format
(filenamecharsmax(filename), "%s/maps/users-%s.ini"configDirszMapname)
        
loadUsersFile(filename)
    }

Can you edit this and add cfg file in it ... it should read value from cfg file mp_maxrounds and print in to client !!!

Last edited by Begineer Programmer; 07-24-2022 at 16:47.
Begineer Programmer is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-24-2022 , 17:16   Re: Need Code For CFG FILE
Reply With Quote #5

Please re-read my post.
__________________

Last edited by fysiks; 07-24-2022 at 17:21.
fysiks is offline
Begineer Programmer
Member
Join Date: Nov 2021
Old 07-24-2022 , 17:30   Re: Need Code For CFG FILE
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
Please re-read my post.
bro i want to say get mp_maxrounds value from file if mp_maxrounds value is 5 then it should get value from file and print it 5 that simple question i am asking...

what if its cfg file of map ... it will get mp_maxrounds of map cfg that all !!!
Begineer Programmer is offline
Begineer Programmer
Member
Join Date: Nov 2021
Old 07-24-2022 , 17:31   Re: Need Code For CFG FILE
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
Please re-read my post.
as i am not perfect in file ik how to open and close file that all !!!
if file exist open file get mp_maxrounds value and print it on server !!!
Begineer Programmer is offline
wilian159
Member
Join Date: Dec 2013
Old 07-24-2022 , 17:36   Re: Need Code For CFG FILE
Reply With Quote #8

Quote:
Originally Posted by Begineer Programmer View Post
as i am not perfect in file ik how to open and close file that all !!!
if file exist open file get mp_maxrounds value and print it on server !!!
i think this can help you
https://wiki.alliedmods.net/Configur...ecific_Plugins
__________________
wilian159 is offline
Begineer Programmer
Member
Join Date: Nov 2021
Old 07-24-2022 , 17:42   Re: Need Code For CFG FILE
Reply With Quote #9

Quote:
Originally Posted by wilian159 View Post
Bro !!!

you also give different answer

what i am trying to do ?

i have plugin i want to show cvar values to users from that file

Assume if nextmap mp_maxrounds value should display to user

when we write nextmap on chat it show nextmap name and it should also show

Rounds of Nextmap will be: %d

mean load mp_maxrounds from file to show nextmap rounds to users
Begineer Programmer is offline
wilian159
Member
Join Date: Dec 2013
Old 07-24-2022 , 17:45   Re: Need Code For CFG FILE
Reply With Quote #10

Quote:
Originally Posted by Begineer Programmer View Post
Bro !!!

you also give different answer

what i am trying to do ?

i have plugin i want to show cvar values to users from that file

Assume if nextmap mp_maxrounds value should display to user

when we write nextmap on chat it show nextmap name and it should also show

Rounds of Nextmap will be: %d

mean load mp_maxrounds from file to show nextmap rounds to users
you don't need to load any files to get the value of 'mp_maxrounds' unless the value of the file is different from the current 'mp_maxrounds', and you want to get the value of the file.

oh yes you need a function
__________________
wilian159 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 03:44.


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