|
Author
|
Message
|
|
Member
|

07-10-2019
, 09:57
Re: Read from a file
|
#1
|
Quote:
Originally Posted by Relaxing
Give it a try,
Spoiler
Code:
#include <amxmodx>
#include <amxmisc>
new filename[128], i;
new steamids[16][26];
public plugin_init(){
get_configsdir(filename, charsmax(filename));
add(filename, charsmax(filename), "/steamid.ini");
ReadData();
}
public client_connect(id){
if (!is_valid_player(id)){
server_cmd("kick #%d ^"Private match^"", get_user_userid(id));
}
}
stock is_valid_player(id){
new bool: p_return = false;
new steamid[26];
get_user_authid(id, steamid, charsmax(steamid));
for (new j = 0; j < i; j++){
if (equal(steamid, steamids[j]) /*&& steamids[j][0] unnecessary*/ ){
p_return = true;
break;
}
}
return p_return;
}
ReadData(){
new Line[26];
new f = fopen(filename, "rt");
while (!feof(f)){
fgets(f, Line, charsmax(Line));
trim(Line);
remove_quotes(Line);
copy(steamids[i], charsmax(steamids[]), Line);
i++;
}
fclose(f);
}
|
created the .ini file with my steam id in it..still kicks me
|
|
|
|