Raised This Month: $32 Target: $400
 8% 

Array and file help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
soumyadip77
Senior Member
Join Date: Jul 2017
Location: INDIA,KOLKATA
Old 08-19-2018 , 12:00   Array and file help
Reply With Quote #1

Hello everyone. I want some help with array and file. I want to read steam id and name like this

PHP Code:
"STEAM:0_0483093" "player name"
"STEAM:0_04830593" "player name2"
"STEAM:0_04830793" "player name3"
"STEAM:0_04832093" "player name4"
"STEAM:0_04838093" "player name5" 
then if player from this steam id will join the server server will cheak that the id is registered if not ban if match then he will join server with given fiel name and he will not change his name when is is in the server
soumyadip77 is offline
Send a message via Skype™ to soumyadip77
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-19-2018 , 13:30   Re: Array and file help
Reply With Quote #2

Open the file, read line by line, use parse to break the string in 2 pieces, then push this data in a dynamic array.
__________________
HamletEagle is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-19-2018 , 13:33   Re: Array and file help
Reply With Quote #3

If you do not need the ability to view the data in notepad then using nvault will be easier.
__________________
Bugsy is offline
soumyadip77
Senior Member
Join Date: Jul 2017
Location: INDIA,KOLKATA
Old 08-19-2018 , 23:12   Re: Array and file help
Reply With Quote #4

Quote:
Originally Posted by HamletEagle View Post
Open the file, read line by line, use parse to break the string in 2 pieces, then push this data in a dynamic array.
got it i will make and i will post here if i will getting any prob ok i am too bad with file and array thing
soumyadip77 is offline
Send a message via Skype™ to soumyadip77
soumyadip77
Senior Member
Join Date: Jul 2017
Location: INDIA,KOLKATA
Old 08-19-2018 , 23:13   Re: Array and file help
Reply With Quote #5

Quote:
Originally Posted by Bugsy View Post
If you do not need the ability to view the data in notepad then using nvault will be easier.
in vault player must be need to connect then i will set them else it is not possible :/
soumyadip77 is offline
Send a message via Skype™ to soumyadip77
soumyadip77
Senior Member
Join Date: Jul 2017
Location: INDIA,KOLKATA
Old 08-20-2018 , 00:40   Re: Array and file help
Reply With Quote #6

me tried with normal array but not working me tried many times can you say where is the prob??
PHP Code:
/* Sublime AMXX Editor v2.2 */

#include <amxmodx>
#include <amxmisc>
// #include <cstrike>
// #include <engine>
// #include <fakemeta>
// #include <hamsandwich>
// #include <fun>
// #include <xs>
// #include <sqlx>

#define PLUGIN  "New Plug-In"
#define VERSION "1.0"
#define AUTHOR  "Author"

#define FILENAME "steamid.ini"
#define MAX_STORE 20

new read_ini_dataMAX_STORE ][ ][ MAX_PLAYERS ];
new 
increment;
new 
namesMAX_PLAYERS ][ MAX_PLAYERS ];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);

    
load_config();
}

load_config()
{
    
// Build customization file path
    
new path64 ];
    
get_configsdir(pathcharsmax(path));
    
format(pathcharsmax(path), "%s/%s"pathFILENAME);

    
// File not present
    
if (!file_exists(path))
    {
        new 
error[100];
        
formatex(errorcharsmax(error), "%s Not FOUND"path);
        
set_fail_state(error);
        return 
0;
    }

    
// Set up some vars to hold parsing info
    
new linedata[1024];
    new 
g_steamidMAX_PLAYERS ], g_nameMAX_PLAYERS ];
    
// Open customization file for reading
    
new file fopen(path"rt");

    while (
file && !feof(file) )
    {
        
// Read one line at a time
        
fgets(filelinedatacharsmax(linedata));

        
// Blank line or comment
        
if (!linedata[0] || linedata[0] == ';' || linedata[0] == '#') continue;

        
//Lets store
        
parse(linedatag_steamidcharsmax(g_steamid), g_namecharsmax(g_name));

        
trim(g_steamid);
        
trim(g_name);

        
formatread_ini_dataincrement ][0], 31"%s"g_steamid );
        
formatread_ini_dataincrement ][1], 31"%s"g_name );

        
increment++;
    }

    return 
0;
}

public 
client_putinserver(id)
{
    new 
g_authidMAX_PLAYERS ];

    
get_user_authid(idg_authid32);

    
trim(g_authid);

    for( new 
0MAX_STORE i++)
    {
        if( 
equaliread_ini_data][ ] , g_authidid ]) )
        {
            
format(namesid ],31"%s"read_ini_data][ ]);

            
set_user_info(id"name"namesid ]);

            
console_print(id"%s"namesid ]);

        }
        else
        {
            
server_cmd("amx_kick #%i GG"g_authidid ])

            break;
        }
    }

    return 
0;
}
/*
public client_infochanged(id)
{
    client_print_color(id, 0, "^4You Cant Change Your Name At ^3Tourney Time.");

    return 3;
}
*/ 
soumyadip77 is offline
Send a message via Skype™ to soumyadip77
Old 08-20-2018, 13:20
soumyadip77
This message has been deleted by HamletEagle. Reason: Stop bumping, it's not allowed.
Old 08-20-2018, 13:29
soumyadip77
This message has been deleted by HamletEagle. Reason: Stop bumping, it's not allowed.
Old 08-21-2018, 11:57
soumyadip77
This message has been deleted by HamletEagle. Reason: Stop bumping, it's not allowed.
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 23:10.


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