Hello, I just want to ask, how do I make a /voucherlist command? I have dini saving systems (vouchers/%d.ini)
What I wanna try to make is when admin types /voucherlist, It will read the files "%d.ini" in vouchers folder. And will sendclientmessage something like:
Код:
CMD:redeem(playerid, params[])
{
new code;
new fstring[32], nstring[156];
if(sscanf(params, "d", code))
{
SendClientMessage(playerid, COLOR_WHITE, "[USAGE] /redeem [vouchercode]");
return 1;
}
format(fstring, sizeof(fstring), SERVER_VOUCHER_FILE, code);
if(dini_Exists(fstring))
{
PlayerInfo[playerid][pGold] += dini_Int(fstring, "Coin");
format(nstring, sizeof(nstring), "SUCCESS: You received Destination Coin %d.", dini_Int(fstring, "Coin"));
SendClientMessage(playerid, COLOR_YELLOW, nstring);
dini_Remove(fstring);
}
else
{
SendClientMessage(playerid, COLOR_RED, "||==========================||");
SendClientMessage(playerid, COLOR_GREY, "[ERROR] This voucher is invalid or already redeemed.");
SendClientMessage(playerid, COLOR_RED, "||==========================||");
}
return 1;
}
CMD:addvoucher(playerid, params[])
{
new code, gold;
new fstring[32], nstring[156];
if(sscanf(params, "dd", code, gold))
{
return SendClientMessage(playerid, COLOR_GREY, "[USAGE] /addvoucher [vouchercode] [coin]");
}
if(PlayerInfo[playerid][pAdmin] >= 6)
{
format(fstring, sizeof(fstring), SERVER_VOUCHER_FILE, code);
if(dini_Exists(fstring)) return SendClientMessage(playerid, COLOR_GREY, "[ERROR] That code already exist.");
dini_Create(fstring);
dini_IntSet(fstring, "Coin", gold);
format(nstring, sizeof(nstring), "SUCCESS: Voucher '%d' created.", code);
SendClientMessage(playerid, COLOR_WHITE, nstring);
}
return 1;
}