Strcmp Help
#1

So my issue is I'm trying to compare the option the player types in, with the faction name in the database, now that works. However the issue is, if it has the "else return SendClientMessage" (highlighted in red) then it won't work as I will type for example:
/factioninfo az
and faction info will come up with
Faction Name: Az
Faction ID: 0

However if I then type
/factioninfo yo
It will come up with that faction doesn't exist, even though it does.
Код:
CMD:factioninfo(playerid, params[])
{
	new string[128], factionname[32];
	if(sscanf(params, "s[32]", factionname)) return SendClientMessage(playerid, cred, "USAGE: /factioninfo [factionname]");
	for(new i = 0; i <= Total_Factions_Created; i++)
	{
		if(!strcmp(factionname, fInfo[i][Name], true))
		{
			SendClientMessage(playerid, cwhite, "================Faction Info================");
			format(string, sizeof(string), "Faction Name: %s", fInfo[i][Name]);
			SendClientMessage(playerid, cwhite, string);
			format(string, sizeof(string), "Faction ID: %d", i);
			SendClientMessage(playerid, cwhite, string);
		}
		else return SendClientMessage(playerid, cred, "That faction doesn't exist!");
	}
	return 1;
}
However if I then remove the "else return SendclientMessage" it won't do this, but it wont come up with an error if the faction doesn't exist, it just doesn't display anything.
So if there is no else return SendClientMessage
It will show both faction Az and faction Yo if I type them after /factioninfo.
But when I add the else return SendClientMessage it only shows faction Az.
Reply


Messages In This Thread
Strcmp Help - by Joshayersm - 07.10.2014, 11:37
Re: Strcmp Help - by Vince - 07.10.2014, 12:37
Re: Strcmp Help - by Stanford - 07.10.2014, 15:03
Re: Strcmp Help - by Joshayersm - 07.10.2014, 20:56

Forum Jump:


Users browsing this thread: 4 Guest(s)