12.12.2014, 17:11
Quote:
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) |
I was just checking if the ID is valid or not, not created or not created.
Thanks anyways
Quote:
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; } 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. |
Thanks for notifying me about that.
If it works I'll reply.
Reputation++ for both.