Hi, i have a small problem , so when i use /movecas ( to move a 3D text + Pickup ) , they have some ID of factions that it's sayd me "You have specified invalid faction ID." and don't work, check my code
PHP код:
CMD:movecas(playerid, params[])
{
static
id,
string[124],
Float:x,
Float:y,
Float:z,
query[124];
if (APlayerData[playerid][PlayerLevel] < 6) return 0;
if (sscanf(params, "u", id))
return SendClientMessage(playerid, 0xFF0000AA, "[FORMAT CORRECT] /movecas [ID]");
if ((id < -1 || id >= MAX_FACTIONS) || (id != -1 && !Factions[id][factionExiste]))
return SendClientMessage(playerid, 0xFF0000AA, "You have specified invalid faction ID.");
GetPlayerPos(playerid, x, y, z);
Factions[id][CasierPos][0] = x;
Factions[id][CasierPos][1] = y;
Factions[id][CasierPos][2] = z;
Factions[id][CasierInterior] = GetPlayerInterior(playerid);
Factions[id][CasierVW] = GetPlayerVirtualWorld(playerid);
mysql_format(g_iHandle, query, sizeof(query), "UPDATE `factions` SET `CasierX` = '%4.2f', `CasierY` = '%4.2f', `CasierZ` = '%4.2f' WHERE `ID` = '%d'", x, y, z, id);
mysql_tquery(g_iHandle, query);
Faction_Refresh(id);
format(string, sizeof(string), "\"%s\" has been replaced.", Factions[id][FactionName]);
SendClientMessage(playerid, 0xFF0000AA, string);
return 1;
}
If the "id" is 0, then it will return the error message. Also it might not be -1 but a value greater or equal to MAX_FACTIONS so you'd still get run time error 4. I can't think of any better way to do it currently so keep it double check.