Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.99 KB | None | 0 0
  1. #define MAX_NAME_GPS_POINT  50
  2. #define MAX_GPS_POINT       10
  3. #define GPS_INVALID_ID      -1
  4.  
  5. enum info
  6. {
  7.     gps_id,
  8.     Float: gps_pos_x,
  9.     Float: gps_pos_y,
  10.     Float: gps_pos_z
  11.     gps_name[MAX_NAME_GPS_POINT]
  12. }
  13. new gps_info[MAX_GPS_POINT][info];
  14.  
  15. public OnGameModeInit()
  16. {
  17.     // код
  18.     mysql_function_query(база данных, !"SELECT * FROM `gps_point`", true, !"LoadPoint", "");
  19. }
  20.  
  21.  
  22. forward LoadPoint();
  23. public LoadPoint()
  24. {
  25.     new rows = cache_get_row_count(база данных);
  26.     if(rows)
  27.     {
  28.         for(new i; i < rows; i ++)
  29.         {
  30.             gps_info[i][gps_id] = cache_get_field_content_int(0, !"GPS_ID");
  31.             cache_get_field_content(0, !"GPS_Name", gps_info[i][gps_name], база данных, MAX_NAME_GPS_POINT);
  32.             gps_info[i][gps_pos_x] = cache_get_field_content_float(0, !"GPS_X");
  33.             gps_info[i][gps_pos_x] = cache_get_field_content_float(0, !"GPS_Y");
  34.             gps_info[i][gps_pos_x] = cache_get_field_content_float(0, !"GPS_Z");
  35.         }
  36.     }
  37. }
  38.  
  39. stock ShowPlayerPointList(playerid, dialogid)
  40. {
  41.     new string[100];
  42.     for(new i; i < MAX_GPS_POINT)
  43.     {
  44.         if(gps_info[i] == GPS_INVALID_ID)
  45.             continue;
  46.  
  47.         format(string, sizeof string, "%s\n%s > ", gps_info[i][gps_name]);
  48.     }
  49.     ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, !"Список GPS", string, !"Перейти", !"Закрыть");
  50. }
  51.  
  52. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  53. {
  54.     case 1030:
  55.     {
  56.         if(!response)
  57.             return true;
  58.  
  59.         //new id = gps_info[listitem][gps_id];
  60.         new id = listitem;
  61.         new size = 10.0;
  62.  
  63.         SetPlayerCheckpoint(playerid, gps_info[id][gps_pos_x], gps_info[id][gps_pos_y], gps_info[id][gps_pos_z], size);
  64.     }
  65. }
  66.  
  67. stock SavePoint(id)
  68. {
  69.     new string[100];
  70.     format(string, sizeof string,
  71.  
  72.         "UPDATE `gps_point` SET\
  73.         `GPS_Name` = '%s', `GPS_X` = '%f', `GPS_Y` = '%f', `GPS_Z` = '%f' WHERE `GPS_ID` = '%d'",
  74.         gps_info[i][gps_name], gps_info[i][gps_pos_x], gps_info[i][gps_pos_y], gps_info[i][gps_pos_z], id);
  75.  
  76.     mysql_function_query(база данных, "", false, "", "");
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement