Advertisement
Guest User

Untitled

a guest
Jan 6th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 KB | None | 0 0
  1.  
  2. public OnGameModeInit()
  3. {
  4. LoadHouses();
  5.  
  6. return 1;
  7. }
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15. /*---------------------------------------------------------------------------------*/
  16. forward LoadHouses();
  17. public LoadHouses()
  18. {
  19. printf("Chargement des maisons...");
  20. mysql_tquery(dbhandle, "SELECT * FROM `server_houses` ORDER BY Hid ASC", "DataLoadHouses", "");
  21. return 1;
  22. }
  23.  
  24.  
  25.  
  26.  
  27. /*---------------------------------------------------------------------------------*/
  28. forward DataLoadHouses();
  29. public DataLoadHouses()
  30. {
  31. new rows,
  32. fields,
  33. string[144];
  34.  
  35. cache_get_data(rows, fields);
  36. if(rows)
  37. {
  38. for(new iSlot, count_nb = cache_get_row_count(); iSlot < count_nb; iSlot++)
  39. {
  40. if(iSlot >= sizeof(HouseInfo))
  41. return 1;
  42.  
  43. HouseInfo[iSlot][h_ID] = cache_get_field_content_int(iSlot, "id");
  44.  
  45. new houset[64];
  46. cache_get_field_content(iSlot, "adresse", houset);
  47. format(HouseInfo[iSlot][h_Adresse], 64, "%s", houset);
  48.  
  49. HouseInfo[iSlot][h_PosX] = cache_get_field_content_float(iSlot, "posx");
  50. HouseInfo[iSlot][h_PosY] = cache_get_field_content_float(iSlot, "posy");
  51. HouseInfo[iSlot][h_PosZ] = cache_get_field_content_float(iSlot, "posz");
  52. HouseInfo[iSlot][h_PosA] = cache_get_field_content_float(iSlot, "posa");
  53.  
  54. HouseInfo[iSlot][h_OutInt] = cache_get_field_content_int(iSlot, "outint");
  55. HouseInfo[iSlot][h_OutWorld] = cache_get_field_content_int(iSlot, "outworld");
  56.  
  57. /*
  58. HouseInfo[iSlot][h_InX] = cache_get_field_content_float(iSlot, "InX");
  59. HouseInfo[iSlot][h_InY] = cache_get_field_content_float(iSlot, "InY");
  60. HouseInfo[iSlot][h_InZ] = cache_get_field_content_float(iSlot, "InZ");
  61. */
  62.  
  63. HouseInfo[iSlot][h_CP] = CreatePickup(1272, 1, HouseInfo[iSlot][h_PosX], HouseInfo[iSlot][h_PosY], HouseInfo[iSlot][h_PosZ], HouseInfo[iSlot][h_OutWorld]);
  64.  
  65. HouseInfo[iSlot][h_Label] = CreateDynamic3DTextLabel(HouseInfo[iSlot][h_Adresse], -1, HouseInfo[iSlot][h_PosX], HouseInfo[iSlot][h_PosY], HouseInfo[iSlot][h_PosZ]+1.0, 2.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, HouseInfo[iSlot][h_OutWorld]);
  66. UpdateHouseLabel(iSlot);
  67.  
  68. }
  69. }
  70. return 1;
  71. }
  72.  
  73.  
  74.  
  75. /*---------------------------------------------------------------------------------*/
  76. stock UpdateHouseLabel(houseid)
  77. {
  78. new string[256];
  79.  
  80. format(string, sizeof(string), "{FFFFFF}%s", HouseInfo[houseid][h_Adresse]);
  81.  
  82. UpdateDynamic3DTextLabelText(HouseInfo[houseid][h_Label], -1, string);
  83. return 1;
  84. }
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91. /*---------------------------------------------------------------------------------*/
  92. forward ADDHOUSE(playerid, i, nom[]);
  93. public ADDHOUSE(playerid, i, nom[])
  94. {
  95. new string[144];
  96. HouseInfo[i][h_ID] = cache_insert_id();
  97.  
  98. strmid(HouseInfo[i][h_Adresse], nom, 0, strlen(nom), 64);
  99.  
  100.  
  101. CreatePickup(1272, 1, HouseInfo[i][h_PosX], HouseInfo[i][h_PosY], HouseInfo[i][h_PosZ], -1);
  102.  
  103.  
  104. format(string, sizeof(string), "[ADMIN] Vous avez crée une nouvelle maison avec l'adresse \"%s\" (ID SQL %d).", HouseInfo[i][h_Adresse], HouseInfo[i][h_ID]);
  105. SendClientMessage(playerid, COLOR_ADMIN, string);
  106.  
  107. return 1;
  108. }
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119. /*---------------------------------------------------------------------------------*/
  120. CMD:creermaison(playerid, params[])
  121. {
  122.  
  123.  
  124. new nom[128], query[700], Float:x, Float:y, Float:z, Float:a;
  125.  
  126. GetPlayerFacingAngle(playerid, a);
  127. GetPlayerPos(playerid, x, y, z);
  128.  
  129. if(sscanf(params, "s[144]", nom))
  130. {
  131. return SendClientMessage(playerid, COLOR_SAMP, "Usage: /creermaison [adresse]");
  132. }
  133.  
  134.  
  135. for(new i = 0; i < sizeof(HouseInfo); i++)
  136. {
  137. if(HouseInfo[i][h_ID] == 0)
  138. {
  139. mysql_format(dbhandle, query,sizeof(query),"INSERT INTO `server_houses` (adresse, posx, posy, posz, posa) VALUES ('%e', '%0.4f', '%0.4f', '%0.4f', '%0.4f')", nom, x, y, z, a);
  140. mysql_tquery(dbhandle, query, "ADDHOUSE", "iis", playerid, i, nom);
  141. return 1;
  142. }
  143. }
  144.  
  145.  
  146. return 1;
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement