Raised This Month: $ Target: $400
 0% 

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-24-2022 , 17:31   Re: Need Code For CFG FILE
Reply With Quote #1

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 #2

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 #3

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 #4

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
Begineer Programmer
Member
Join Date: Nov 2021
Old 07-24-2022 , 17:48   Re: Need Code For CFG FILE
Reply With Quote #5

Quote:
Originally Posted by wilian159 View Post
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
How ?
can you please get values of mp_maxrounds of nextmap ?
Begineer Programmer is offline
Begineer Programmer
Member
Join Date: Nov 2021
Old 07-24-2022 , 17:52   Re: Need Code For CFG FILE
Reply With Quote #6

Quote:
Originally Posted by wilian159 View Post
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
Here is code of the plugin
get mp_maxrounds of nextmap
[AMXX] Rounds | Score | Map: Current Map / Nextmap [Get value mp_maxrounds of nextmap] | Players

PHP Code:
#include <amxmodx> 
#include <cstrike> 
new runde 0
new prefix[32] = "AMXX"
new TerrScoreCTScore
public plugin_init()  

    
register_plugin"Info Top""1.4""->UrOS<-")    
    
register_event("HLTV""round_start""a""1=0""2=0")
    
register_event("TextMsg""round_restart""a""2=#Game_will_restart_in")
    
register_event("TeamScore""terr_score""a""1=TERRORIST")
    
register_event("TeamScore""ct_score""a""1=CT")

public 
round_restart()
{
    
runde 0
    TerrScore
=0
    CTScore
=0
}
public 
terr_score()
{
    
TerrScore read_data(2)
}
public 
ct_score()
{
    
CTScore read_data(2)
}
public 
round_start() 

    
    
    new 
mapname[32], nextmap[32], players[32], player ,maxrundimaxplayers 
    
    maxrundi
=get_cvar_num("mp_maxrounds")
    
maxplayers=get_maxplayers()
    
get_cvar_string("amx_nextmap",nextmap,31
    
get_mapname(mapname,31 
    
get_players(playersplayer)
    
    
ChatColor(0,"^4[%s]^3 Rounds:^4 %d^3/^4%d ^1|^3 Score:^3 Ts:^4%i^3 -^3 CTs:^4%i ^1|^3 Map:^4 %s^3/^4%s ^1|^3 Players:^4 %d^3/^4%d",prefixrunde,maxrundi,TerrScore,CTScore,mapnamenextmapplayer,maxplayers
    
runde++
}
stock ChatColor(const id, const input[], any:...) {
    static 
csaymsg;
    if (!
csaymsg) { csaymsg get_user_msgid("SayText"); }
    
    static 
countplayers[32], iplayer;
    
count 1;
    
0;
    static 
msg[191];
    
vformat(msg190input3);
    
    
replace_all(msg190"!g""^4");
    
replace_all(msg190"!y""^1");
    
replace_all(msg190"!n""^1");
    
replace_all(msg190"!t""^3");
    
    if (
id
    {
        
players[0] = id;
    }
    else 
    {
        
get_players(playerscount"ch");
    }
    
    for (
0counti++)
    {
        
player players[i];
        if (
is_user_connected(player))
        {
            
message_begin(MSG_ONE_UNRELIABLEcsaymsg_player);
            
write_byte(player);
            
write_string(msg);
            
message_end();
        }
    }

Begineer Programmer is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-24-2022 , 19:08   Re: Need Code For CFG FILE
Reply With Quote #7

Quote:
Originally Posted by Begineer Programmer View Post
get mp_maxrounds of nextmap
Getting it for the NEXT map makes your request make much more sense. Your original post did not say this.

Since this is the Scripting Help section, please attempt to do what you're wanting to do and then post your code. Basically, you open the file and loop through each line using the parse() function to get the cvar name and cvar value and check for "mp_maxrounds" and then grab the value.

I even have public plugins that do this part already (getting a key-value pair from each line of a file) that you can use as a reference. For example, this function does this. You would only have to change very little in this function. You'd just have to get the correct file name (the code of mine that you already posted shows this) and then check if the string (szModel i.e. your cvar name) is equal to "mp_maxrounds".
__________________

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

Quote:
Originally Posted by fysiks View Post
Getting it for the NEXT map makes your request make much more sense. Your original post did not say this.

Since this is the Scripting Help section, please attempt to do what you're wanting to do and then post your code. Basically, you open the file and loop through each line using the parse() function to get the cvar name and cvar value and check for "mp_maxrounds" and then grab the value.

I even have public plugins that do this part already (getting a key-value pair from each line of a file) that you can use as a reference. For example, this function does this. You would only have to change very little in this function. You'd just have to get the correct file name (the code of mine that you already posted shows this) and then check if the string (szModel i.e. your cvar name) is equal to "mp_maxrounds".
will try todo this !!! as i am beginner in programming too...
secondly where i call function ? in pluginit ? or round start function ?
need more reference on this file

Last edited by Begineer Programmer; 07-24-2022 at 19:22.
Begineer Programmer 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 10:32.


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