AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   [REQ] Read arguments from .ini file (https://forums.alliedmods.net/showthread.php?t=262259)

BaD CopY 05-01-2015 02:27

[REQ] Read arguments from .ini file
 
Hello everyone,

Can anyone make a litle tutorial or just example plugin who read arguments from ini file and from specific line of thet file. Example, I have .ini file and I want to plugin read line 8. On line 8 are two arguments: "BaD CopY" "1000" (First argument is betwen first and second quotes and second argument is betwen third and fourth quotes).

So, plugin must give golds. First argument is nick of player and second argument is number of player's golds. Plugin must set golds like second argument from .ini file to player (first argument)

Plugin will create file: golds.ini and in thet file is nick of all players who connected to the server and who have min. 1 kill (gold)

This is a part of gold system plugin
PHP Code:

new gGolds[32]

register_event"DeathMsg""Hook_Deathmessage""a" );

public 
Hook_Deathmessage()
{
    new 
killer read_data);
    new 
victim read_data);
    
    if( 
killer == victim )
    {
        return 
PLUGIN_HANDLED;
    }
    
    
gGoldskiller ] += 1
    
    
return PLUGIN_CONTINUE;


If you don't understend something, post questin in comment and send me PM...

fysiks 05-01-2015 18:53

Re: [REQ] Read arguments from .ini file
 
It's simple. Read the file like normal (using fopen, fgets, fclose). Simply use parse() on the data you get from fgets() to extract those two values. Do what ever you need to do to know if it's the line you want (referencing by line is a bad idea).


All times are GMT -4. The time now is 20:14.

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