Only one out of two outcomes would occur
#6

Quote:
Originally Posted by Divergent
Посмотреть сообщение
Yeah sorry about that, I misunderstood you a bit but part of my answer is still relevant (I think).

Add a "Created" variable to the enumerator (or however you're organizing the data for the dealerships) so that only dealerships which have been created (valid IDs) are able to be teleported to. So for example in the TP command you would add

Код:
if(DealershipInfo[id][Created] == true)
This would only allow the dealerships that you have created to be teleported to.
Oh, I understand thanks, but that is not quite what I was trying to do.
I was just checking if the ID is valid or not, not created or not created.
Thanks anyways






Quote:
Originally Posted by Virtual1ty
Посмотреть сообщение
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.
This was what I was looking for I believe, so I forgot to make a mysql query.
Thanks for notifying me about that.
If it works I'll reply.

Reputation++ for both.
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: 3 Guest(s)