15.07.2018, 07:33
You are a fkn legend! thank you so much! i'm have another little issue and i was wondering if you can also help me fix it,
Can you see anything wrong with that code? when i create one in game, it spams the chat 4 times saying the same thing, and on server restart they don't load in
Код:
GangTag_Load() { mysql_tquery(MainPipeline, "SELECT *FROM `gangtags` where 1", "GangTag_OnLoad", ""); } forward GangTag_OnLoad(); public GangTag_OnLoad() { new iRows; cache_get_row_count(iRows); if(!iRows) return print("[Gang Tags] There are no gang tags in the database."); new idx, szResult[MAX_GANGTAGS_LEN], value, Float:fValue; while(idx < iRows) { cache_get_value_name(idx, "text", szResult); GangTag_AdmProcess(idx, cache_get_value_name_float(idx, "x", fValue), cache_get_value_name_float(idx, "y", fValue), cache_get_value_name_float(idx, "z", fValue), cache_get_value_name_float(idx, "rx", fValue), cache_get_value_name_float(idx, "ry", fValue), cache_get_value_name_float(idx, "rz", fValue), szResult, cache_get_value_name_int(idx, "fontid", value), cache_get_value_name_int(idx, "color", value)); idx++; } printf("[Gang Tags] Loaded %d gang tags.", idx); return 1; }
Код:
GangTag_AdmSave(iPlayerID, i) { new Float:gt_finPos[6]; GetDynamicObjectPos(arrGangTags[i][gt_iObjectID], gt_finPos[0], gt_finPos[1], gt_finPos[2]); GetDynamicObjectRot(arrGangTags[i][gt_iObjectID], gt_finPos[3], gt_finPos[4], gt_finPos[5]); if(IsValidDynamic3DTextLabel(arrGangTags[i][gt_iTextID])) DestroyDynamic3DTextLabel(arrGangTags[i][gt_iTextID]); format(szMiscArray, sizeof(szMiscArray), "Gang Tag Point (ID %d)", i); arrGangTags[i][gt_iTextID] = CreateDynamic3DTextLabel(szMiscArray, COLOR_YELLOW, gt_finPos[0], gt_finPos[1], gt_finPos[2]+2.75, 4.0); mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "SELECT * FROM `gangtags` WHERE `id` = '%d'", i); mysql_tquery(MainPipeline, szMiscArray, "GangTag_OnSetText", "i", i); mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "UPDATE `gangtags` SET `x` = '%f', `y` = '%f', `z` = '%f', `rx` = '%f', `ry` = '%f', `rz` = '%f' WHERE `id` = '%d'", gt_finPos[0], gt_finPos[1], gt_finPos[2], gt_finPos[3], gt_finPos[4], gt_finPos[5], i); mysql_tquery(MainPipeline, szMiscArray, "GangTag_OnAdmSave", "ii", iPlayerID, i); } forward GangTag_OnSetText(i); public GangTag_OnSetText(i) { new iRows, szResult[MAX_GANGTAGS_LEN], iCount, color, fontid; cache_get_row_count(iRows); while(iCount < iRows) { cache_get_value_name(iCount, "text", szResult); cache_get_value_name_int(iCount, "color", color); cache_get_value_name_int(iCount, "fontid", fontid); SetDynamicObjectMaterialText(arrGangTags[i][gt_iObjectID], 0, szResult, OBJECT_MATERIAL_SIZE_512x512, szFonts[fontid], 1000 / strlen(szResult), 1, GangTag_IntColor(color), 0, 1); ++iCount; } return 1; } forward GangTag_OnAdmSave(iPlayerID, i); public GangTag_OnAdmSave(iPlayerID, i) { if(mysql_errno()) return SendClientMessage(iPlayerID, COLOR_GRAD1, "Something went wrong. Try again later."); format(szMiscArray, sizeof(szMiscArray), "You have successfully edited gang tag ID %d", i); SendClientMessage(iPlayerID, COLOR_YELLOW, szMiscArray); return 1; } GangTag_AdmProcess(i, Float:X, Float:Y, Float:Z, Float:RX, Float:RY, Float:RZ, text[], fontid, color) { Iter_Add(GangTags, i); if(IsValidDynamicObject(arrGangTags[i][gt_iObjectID])) DestroyDynamicObject(arrGangTags[i][gt_iObjectID]); arrGangTags[i][gt_iObjectID] = CreateDynamicObject(GANGTAGS_OBJECTID, X, Y, Z, RX, RY, RZ); if(IsValidDynamic3DTextLabel(arrGangTags[i][gt_iTextID])) DestroyDynamic3DTextLabel(arrGangTags[i][gt_iTextID]); format(szMiscArray, sizeof(szMiscArray), "Gang Tag Point (ID %d)", i); arrGangTags[i][gt_iTextID] = CreateDynamic3DTextLabel(szMiscArray, COLOR_YELLOW, X, Y, Z+2.75, 4.0); SetDynamicObjectMaterialText(arrGangTags[i][gt_iObjectID], 0, text, OBJECT_MATERIAL_SIZE_512x512, szFonts[fontid], 1000 / strlen(text), 1, GangTag_IntColor(color), 0, 1); } GangTag_Delete(iPlayerID, i) { if(!IsValidDynamicObject(arrGangTags[i][gt_iObjectID])) return SendClientMessage(iPlayerID, COLOR_GRAD1, "You specified an invalid gang tag ID."); mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "DELETE FROM `gangtags` WHERE `id` = '%d'", i); mysql_tquery(MainPipeline, szMiscArray, "GangTag_OnDelete", "ii", iPlayerID, i); return 1; }