AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Need Code For CFG FILE (https://forums.alliedmods.net/showthread.php?t=338731)

Begineer Programmer 07-23-2022 22:49

Need Code For CFG FILE
 
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

damage220 07-23-2022 23:17

Re: Need Code For CFG FILE
 
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.

fysiks 07-24-2022 01:46

Re: Need Code For CFG FILE
 
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.

Begineer Programmer 07-24-2022 16:45

Re: Need Code For CFG FILE
 
Quote:

Originally Posted by fysiks (Post 2784563)
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 !!!

fysiks 07-24-2022 17:16

Re: Need Code For CFG FILE
 
Please re-read my post.

Begineer Programmer 07-24-2022 17:30

Re: Need Code For CFG FILE
 
Quote:

Originally Posted by fysiks (Post 2784622)
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 07-24-2022 17:31

Re: Need Code For CFG FILE
 
Quote:

Originally Posted by fysiks (Post 2784622)
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 !!!

wilian159 07-24-2022 17:36

Re: Need Code For CFG FILE
 
Quote:

Originally Posted by Begineer Programmer (Post 2784628)
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

Begineer Programmer 07-24-2022 17:42

Re: Need Code For CFG FILE
 
Quote:

Originally Posted by wilian159 (Post 2784629)

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

wilian159 07-24-2022 17:45

Re: Need Code For CFG FILE
 
Quote:

Originally Posted by Begineer Programmer (Post 2784630)
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


All times are GMT -4. The time now is 10:32.

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