23.03.2016, 13:58
Hi guys,
Hum, the following cmd is supposed to open up a file, find a string and delete it's text(if the text even exists).
e.g, faction Ballas has been warned, it writes down a warning to their lowest warning available slot
let's say it's 1. So in the factionwarnings file, on Ballas1, it'll change the text from Ballas1="Powergaming" to Ballas="" but for some reason I can't get it working. If it works, then it sometimes remove a warning from a clear slot(without any warnings, the value is ""), or says that the slot is clear when it's not.
+ REPing
Basically, if you didnt understand so far - I want this command to check whether a line equals to "", if so it should return an error, if not it should set it to "".
Hum, the following cmd is supposed to open up a file, find a string and delete it's text(if the text even exists).
e.g, faction Ballas has been warned, it writes down a warning to their lowest warning available slot
let's say it's 1. So in the factionwarnings file, on Ballas1, it'll change the text from Ballas1="Powergaming" to Ballas="" but for some reason I can't get it working. If it works, then it sometimes remove a warning from a clear slot(without any warnings, the value is ""), or says that the slot is clear when it's not.
PHP код:
COMMAND:rfwarn(playerid, params[])
{
new ff[50];
if(PlayerInfo[playerid][power] < 11) return SendClientError(playerid, CANT_USE_CMD);
new iFaction, wid, iReason[ MAX_STRING ];
if( sscanf ( params, "dds", iFaction, wid, iReason)) return SCP(playerid, "[FactionID] [WarningID] [Reason]");
format(ff, sizeof(ff), "%sWarnings", teams[ GetTeam(iFaction) ][teamname]);
if(dini_Int(factionwarnings, ff) == 0) return SendClientError(playerid, "This faction has 0 warnings!");
format(iStr, sizeof(iStr), "%s%d", teams[ GetTeam(iFaction) ][teamname], wid);
if(!strcmp(dini_Get(factionwarnings, iStr), "")) return SendClientError(playerid, "This slot is empty!");
dini_Set(factionwarnings, iStr, "");
dini_IntSet(factionwarnings, ff, (dini_Int(factionwarnings, ff) -1));
format(iStr, sizeof(iStr), "#[Faction Warning] %s has removed a faction-warned from %s. Reason: %s [%d/5]", RPName(playerid), teams[ GetTeam(iFaction) ][teamname], iReason, dini_Int(factionwarnings, ff));
SendClientMessageToAdmins(iStr, COLOR_PLAYER_VLIGHTBLUE);
PlayerLoop(ii)
{
if(GetPlayerFaction(ii) == iFaction)
SendClientMessage(ii, COLOR_PLAYER_VLIGHTBLUE, iStr);
}
return SendClientInfo(playerid, "Done");
// return 1;
}
Basically, if you didnt understand so far - I want this command to check whether a line equals to "", if so it should return an error, if not it should set it to "".