Hello,
I tried to make a VIP Plugin with a vips.ini file for reading vips.
But when I introduce the data in file, it not shows me exactly what I wanna get from that array.
Code:
Code:
public CheckVIP
()
{
new path
[64];
get_localinfo("amxx_configsdir", path, charsmax
(path
));
format(path, charsmax
(path
),
"%s/vips.ini", path
);
new file =
fopen(path,
"r+");
if(!
file_exists(path
))
{
write_file(path,
";VIPs.ini file");
}
if(vips_number
)
{
ArrayClear
(vip_array
);
vips_number =
0;
}
new text
[121], p_name
[32], expir_date
[32], vip_infos
[vip_data
];
while(!
feof(file
))
{
fgets(file, text, charsmax
(text
));
trim(text
);
if(text
[0] ==
';' || !
strlen(text
))
{
continue;
}
if(parse(text, p_name, charsmax
(p_name
), expir_date, charsmax
(expir_date
)) !=
2)
{
log_to_file(LOGFILE,
"[AMXX] Can't (%s). Este scrisa gresit.", text
);
continue;
}
copy(vip_infos
[user_name
], charsmax
(vip_infos
), p_name
);
copy(vip_infos
[expire_date
], charsmax
(vip_infos
), expir_date
);
ArrayPushArray(vip_array, vip_infos);
vips_number++;
}
fclose(file
);
}
putinserver client phase:
Code:
public client_putinserver(id)
{
new p_name[32];
get_user_info(id, "name", p_name, charsmax(p_name));
is_user_vip[id] = false;
new vip_infos[vip_data], i;
for(i = 0; i < ArraySize(vip_array); i++)
{
ArrayGetArray(vip_array, i, vip_infos);
if(equal(vip_infos[user_name], p_name))
{
is_user_vip[id] = true;
set_task(10.0, "Task_ShowExpire")
}
break;
}
}
Show Expire Task:
Code:
public Task_ShowExpire(id)
{
new vip_infos[vip_data]
for(new i = 0; i < ArraySize(vip_array); i++)
{
ArrayGetArray(vip_array, i, vip_infos);
}
color_chat(id, "!y[!gV.I.P!y] Your !gVIP Status !yExpire on: !g%s", vip_infos[expire_date])
}
vips.ini file:
Code:
"Adi" "Permanent VIP"
"Test" "30.06.2020"
In the public
Task_ShowExpire it prints me the value from the last Array from the file. Example:
Adi is joining the server. Adi has VIP and server prints his vip's expire is on "30.06.2020" instead to print "Permanent VIP"
Test is joining the server. Test has not VIP, but he is written in the file.
__________________