23.05.2020, 04:17
Quote:
This will work in MySQL plugin R41-4, also you need the library strlib for the function strcpy.
strlib.inc https://sampforum.blast.hk/showthread.php?tid=362764 So, in OnGameModeInit: Code:
mysql_tquery(MySQL, "SELECT * FROM labels", "LoadLabels"); Code:
forward LoadLabels(); public LoadLabels() { new rows; cache_get_row_count(rows); if (!rows) return print("None label loaded."); for (new row = 0; row != rows; ++row) { new color[64], text[200]; cache_get_value(row, "Color", color, 128); cache_get_value(row, "Text", text, 256); cache_get_value_float(row, "X", LInfo[row][POSX]); cache_get_value_float(row, "Y", LInfo[row][POSY]); cache_get_value_float(row, "Z", LInfo[row][POSZ]); cache_get_value_float(row, "LDistance", LInfo[row][LDistance]); cache_get_value_int(row, "World", LInfo[row][World]); strcpy(LInfo[row][Text], text); if(strcmp(color,"Red") == 0) { LInfo[row][Color] = llred; LabelID[row] = Create3DTextLabel(LInfo[row][Text],LInfo[row][Color],LInfo[row][POSX],LInfo[row][POSY],LInfo[row][POSZ],LInfo[row][LDistance],LInfo[row][World],DEFAULT_LABEL_VIEW_THREW_OBJECTS); } if(strcmp(color,"Green") == 0) { LInfo[row][Color] = llgreen; LabelID[row] = Create3DTextLabel(LInfo[row][Text],LInfo[row][Color],LInfo[row][POSX],LInfo[row][POSY],LInfo[row][POSZ],LInfo[row][LDistance],LInfo[row][World],DEFAULT_LABEL_VIEW_THREW_OBJECTS); } if(strcmp(color,"Yellow") == 0) { LInfo[row][Color] = llyellow; LabelID[row] = Create3DTextLabel(LInfo[row][Text],LInfo[row][Color],LInfo[row][POSX],LInfo[row][POSY],LInfo[row][POSZ],LInfo[row][LDistance],LInfo[row][World],DEFAULT_LABEL_VIEW_THREW_OBJECTS); } if(strcmp(color,"Blue") == 0) { LInfo[row][Color] = llblue; LabelID[row] = Create3DTextLabel(LInfo[row][Text],LInfo[row][Color],LInfo[row][POSX],LInfo[row][POSY],LInfo[row][POSZ],LInfo[row][LDistance],LInfo[row][World],DEFAULT_LABEL_VIEW_THREW_OBJECTS); } if(strcmp(color,"Pink") == 0) { LInfo[row][Color] = llpink; LabelID[row] = Create3DTextLabel(LInfo[row][Text],LInfo[row][Color],LInfo[row][POSX],LInfo[row][POSY],LInfo[row][POSZ],LInfo[row][LDistance],LInfo[row][World],DEFAULT_LABEL_VIEW_THREW_OBJECTS); } if(strcmp(color,"White") == 0) { LInfo[row][Color] = llwhite; LabelID[row] = Create3DTextLabel(LInfo[row][Text],LInfo[row][Color],LInfo[row][POSX],LInfo[row][POSY],LInfo[row][POSZ],LInfo[row][LDistance],LInfo[row][World],DEFAULT_LABEL_VIEW_THREW_OBJECTS); } Labelcount++; } printf("Labels loaded: %i/%i", rows, Labelcount); return 1; } |