Only one out of two outcomes would occur
#5

The code is all fine except for the part in red, oh, and you don't need a second level if-else statement!
Код:
YCMD:gotodealership(playerid, params[], help)
{
	if (!IsPlayerAdmin(playerid)) return 0;

	new id;
	if (sscanf(params, "d", id)) return SendClientMessage(playerid, -1, "[ ! ] SYNTAX: /GotoDealerShip [DS-ID]");

	for (new i = 0 ; i < cache_get_row_count(dbHandle) ; i++)
	{
		if (id != DS[i][DsID]) 
		{
			SendClientMessage(playerid, 0xFF0000FF, "[ ! ] Invalid DEALERSHIP ID.");
		}
		else continue;
	}

	SetPlayerPos(playerid, DS[id][DsLocX], DS[id][DsLocY], DS[id][DsLocZ]);
	SendClientMessage(playerid, 0xFF0000FF, "[ ! ] Successfully teleported to a valid DEALERSHIP.");
	return 1;
}
What exactly are you trying to achieve with that loop? When and where is the query (assuming it's a MySQL query) formed and result fetched??
That part of code makes absolutely zero sense. You're checking if the number you entered (the "id" variable) doesn't equal one of those (I assume, again) dealership IDs in "DS" enum, how is it then supposed to be invalid?

Just do it like: You enter an ID, you loop through the "DS" enum and check if it's found. If it's not then it's invalid.
Reply


Messages In This Thread
Only one out of two outcomes would occur - by Ox1gEN - 12.12.2014, 16:50
Re: Only one out of two outcomes would occur - by Divergent - 12.12.2014, 16:56
Re: Only one out of two outcomes would occur - by Ox1gEN - 12.12.2014, 17:03
Re: Only one out of two outcomes would occur - by Divergent - 12.12.2014, 17:07
Re: Only one out of two outcomes would occur - by Virtual1ty - 12.12.2014, 17:08
Re: Only one out of two outcomes would occur - by Ox1gEN - 12.12.2014, 17:11
Re: Only one out of two outcomes would occur - by Divergent - 12.12.2014, 17:13
Re: Only one out of two outcomes would occur - by Ox1gEN - 12.12.2014, 17:16
Re: Only one out of two outcomes would occur - by PowerPC603 - 12.12.2014, 18:42
Re: Only one out of two outcomes would occur - by Ox1gEN - 13.12.2014, 06:18

Forum Jump:


Users browsing this thread: 2 Guest(s)