Advertisement
S4T3K

Requêtes

Feb 28th, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.01 KB | None | 0 0
  1.  
  2. public SauvMaisons(playerid)
  3. {
  4.     new idx = 1;
  5.     while(idx < sizeof(InfoMaison))
  6.     {
  7.         new nom[MAX_PLAYER_NAME];
  8.         GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
  9.         format(query, 1024, "UPDATE `Maisons` WHERE `id`='%d' SET `xEntree`='%f'", idx, InfoMaison[idx][xEntree]);
  10.         mysql_query(query);
  11.         format(query, 1024, "UPDATE `Maisons` WHERE `id`='%d' SET `yEntree`='%f'", idx, InfoMaison[idx][yEntree]);
  12.         mysql_query(query);
  13.         format(query, 1024, "UPDATE `Maisons` WHERE `id`='%d' SET `zEntree`='%f'", idx, InfoMaison[idx][zEntree]);
  14.         mysql_query(query);
  15.         format(query, 1024, "UPDATE `Maisons` WHERE `id`='%d' SET `xSortie`='%f'", idx, InfoMaison[idx][xSortie]);
  16.         mysql_query(query);
  17.         format(query, 1024, "UPDATE `Maisons` WHERE `id`='%d' SET `ySortie`='%f'", idx, InfoMaison[idx][ySortie]);
  18.         mysql_query(query);
  19.         format(query, 1024, "UPDATE `Maisons` WHERE `id`='%d' SET `zSortie`='%f'", idx, InfoMaison[idx][zSortie]);
  20.         mysql_query(query);
  21.         format(query, 1024, "UPDATE `Maisons` WHERE `id`='%d' SET `location`='%d'", idx, InfoMaison[idx][mLocation]);
  22.         mysql_query(query);
  23.         format(query, 1024, "UPDATE `Maisons` WHERE `id`='%d' SET `prix_location`='%d'", idx, InfoMaison[idx][mPrixLocation]);
  24.         mysql_query(query);
  25.         format(query, 1024, "UPDATE `Maisons` WHERE `id`='%d' SET `nombre_locataires`='%d'", idx, InfoMaison[idx][mNombreLocataires]);
  26.         mysql_query(query);
  27.         format(query, 1024, "UPDATE `Maisons` WHERE `id`='%d' SET `coffre_pos`='%d'", idx, InfoMaison[idx][mCoffrePos]);
  28.         mysql_query(query);
  29.         format(query, 1024, "UPDATE `Maisons` WHERE `id`='%d' SET `sante_pos`='%d'", idx, InfoMaison[idx][mSantePos]);
  30.         mysql_query(query);
  31.         format(query, 1024, "UPDATE `Maisons` WHERE `id`='%d' SET `armure_pos`='%d'", idx, InfoMaison[idx][mArmurePos]);
  32.         mysql_query(query);
  33.         format(query, 1024, "UPDATE `Maisons` WHERE `id`='%d' SET `defaultd`='%s'", idx, InfoMaison[idx][mDefaultd]);
  34.         mysql_query(query);
  35.         format(query, 1024, "UPDATE `Maisons` WHERE `id`='%d' SET `prix`='%d'", idx, InfoMaison[idx][mPrix]);
  36.         mysql_query(query);
  37.         format(query, 1024, "UPDATE `Maisons` WHERE `id`='%d' SET `phrase`='%s'", idx, InfoMaison[idx][mPhrase]);
  38.         mysql_query(query);
  39.         format(query, 1024, "UPDATE `Maisons` WHERE `id`='%d' SET `portes`='%d'", idx, InfoMaison[idx][mPortes]);
  40.         mysql_query(query);
  41.         format(query, 1024, "UPDATE `Maisons` WHERE `id`='%d' SET `type`='%d'", idx, InfoMaison[idx][mType]);
  42.         mysql_query(query);
  43.  
  44.         // printf("Maison %d sauvegardée", idx);
  45.         idx++;
  46.     }
  47.  
  48.     if(idx == sizeof(InfoMaison))
  49.     {
  50.         print("Toutes les maisons ont été sauvegardées !");
  51.     }
  52.     return 1;
  53. }
  54.  
  55. public SauvCoffres()
  56. {
  57.     new idx = 1;
  58.     while(idx < sizeof(InfoCoffre))
  59.     {
  60.         format(query, 1024, "UPDATE `Coffres` WHERE `id`='%d' SET `ameliod`='%d'", idx, InfoCoffre[idx][cAmeliod]);
  61.         mysql_query(query);
  62.         format(query, 1024, "UPDATE `Coffres` WHERE `id`='%d' SET `ameliom`='%d'", idx, InfoCoffre[idx][cAmeliom]);
  63.         mysql_query(query);
  64.         format(query, 1024, "UPDATE `Coffres` WHERE `id`='%d' SET `amelioa`='%d'", idx, InfoCoffre[idx][cAmelioa]);
  65.         mysql_query(query);
  66.         format(query, 1024, "UPDATE `Coffres` WHERE `id`='%d' SET `amelioar`='%d'", idx, InfoCoffre[idx][cAmelioar]);
  67.         mysql_query(query);
  68.         format(query, 1024, "UPDATE `Coffres` WHERE `id`='%d' SET `pass`='%s'", idx, InfoCoffre[idx][cPass]);
  69.         mysql_query(query);
  70.         format(query, 1024, "UPDATE `Coffres` WHERE `id`='%d' SET `drogues`='%d'", idx, InfoCoffre[idx][cDrogues]);
  71.         mysql_query(query);
  72.         format(query, 1024, "UPDATE `Coffres` WHERE `id`='%d' SET `matos`='%d'", idx, InfoCoffre[idx][cMatos]);
  73.         mysql_query(query);
  74.         format(query, 1024, "UPDATE `Coffres` WHERE `id`='%d' SET `arme1`='%d'", idx, InfoCoffre[idx][cArme1]);
  75.         mysql_query(query);
  76.         format(query, 1024, "UPDATE `Coffres` WHERE `id`='%d' SET `arme1m`='%d'", idx, InfoCoffre[idx][cArme1m]);
  77.         mysql_query(query);
  78.         format(query, 1024, "UPDATE `Coffres` WHERE `id`='%d' SET `arme2`='%d'", idx, InfoCoffre[idx][cArme2]);
  79.         mysql_query(query);
  80.         format(query, 1024, "UPDATE `Coffres` WHERE `id`='%d' SET `arme2m`='%d'", idx, InfoCoffre[idx][cArme2m]);
  81.         mysql_query(query);
  82.         format(query, 1024, "UPDATE `Coffres` WHERE `id`='%d' SET `arme3`='%d'", idx, InfoCoffre[idx][cArme3]);
  83.         mysql_query(query);
  84.         format(query, 1024, "UPDATE `Coffres` WHERE `id`='%d' SET `arme3m`='%d'", idx, InfoCoffre[idx][cArme3m]);
  85.         mysql_query(query);
  86.         format(query, 1024, "UPDATE `Coffres` WHERE `id`='%d' SET `arme4`='%d'", idx, InfoCoffre[idx][cArme4]);
  87.         mysql_query(query);
  88.         format(query, 1024, "UPDATE `Coffres` WHERE `id`='%d' SET `arme4m`='%d'", idx, InfoCoffre[idx][cArme4m]);
  89.         mysql_query(query);
  90.         format(query, 1024, "UPDATE `Coffres` WHERE `id`='%d' SET `argent`='%d'", idx, InfoCoffre[idx][cArgent]);
  91.         mysql_query(query);
  92.         format(query, 1024, "UPDATE `Coffres` WHERE `id`='%d' SET `ouvert`='%d'", idx, InfoCoffre[idx][cOuvert]);
  93.         mysql_query(query);
  94.  
  95.         // printf("Coffre %d sauvegardé !", idx);
  96.  
  97.         idx++;
  98.     }
  99.     if(idx == sizeof(InfoCoffre))
  100.     {
  101.         print("Tous les coffres de maison ont été sauvegardés !");
  102.     }
  103.     return 1;
  104. }
  105.  
  106. public ChargerMaisons()
  107. {
  108.     new idx = 1;
  109.     while(idx < sizeof(InfoMaison))
  110.     {
  111.         new txe[50], tye[50], tze[50], txs[50], tys[50], tzs[50], tloc[50], tprix_loc[50], tnombre_loc[50];
  112.         new tcoffrep[50], tsantep[50], tarmurep[50], tprix[50], tportes[50], ttype[50];
  113.         new propname[MAX_PLAYER_NAME+1], phrase[1024], defaultd[256];
  114.  
  115.         #pragma unused txe, tyz, tze, txs, tys, tzs, tloc, tprix_loc, tnombre_loc
  116.         #pragma unused tcoffrep, tsantep, tarmurep, tprix, tportes, ttype
  117.  
  118.         mysql_query("SELECT * FROM `Maisons`");
  119.         mysql_store_result();
  120.         while(mysql_retrieve_row())
  121.         {
  122.  
  123.             InfoMaison[idx][mID] = idx;
  124.  
  125.             mysql_get_field("proprio", propname);
  126.             mysql_get_field("phrase", phrase);
  127.             mysql_get_field("defaultd", defaultd);
  128.  
  129.             mysql_get_field("xEntree", txe);
  130.             mysql_get_field("yEntree", tye);
  131.             mysql_get_field("zEntree", tze);
  132.  
  133.             mysql_get_field("xSortie", txs);
  134.             mysql_get_field("ySortie", tys);
  135.             mysql_get_field("zSortie", tzs);
  136.  
  137.             mysql_get_field("location", tloc);
  138.             mysql_get_field("prix_location", tprix_loc);
  139.             mysql_get_field("nombre_locataires", tnombre_loc);
  140.  
  141.             mysql_get_field("coffre_pos", tcoffrep);
  142.             mysql_get_field("sante_pos", tsantep);
  143.             mysql_get_field("armure_pos", tarmurep);
  144.  
  145.             mysql_get_field("prix", tprix);
  146.             mysql_get_field("portes", tportes);
  147.             mysql_get_field("type", ttype);
  148.  
  149.             InfoMaison[idx][mProprio] = propname;
  150.             InfoMaison[idx][xEntree] = floatstr(txe);
  151.             InfoMaison[idx][yEntree] = floatstr(tye);
  152.             InfoMaison[idx][zEntree] = floatstr(tze);
  153.  
  154.             InfoMaison[idx][xSortie] = floatstr(txs);
  155.             InfoMaison[idx][ySortie] = floatstr(tys);
  156.             InfoMaison[idx][zSortie] = floatstr(tzs);
  157.  
  158.             InfoMaison[idx][mLocation] = strval(tloc);
  159.             InfoMaison[idx][mPrixLocation] = strval(tprix_loc);
  160.             InfoMaison[idx][mNombreLocataires] = strval(tnombre_loc);
  161.  
  162.             InfoMaison[idx][mCoffrePos] = strval(tcoffrep);
  163.             InfoMaison[idx][mSantePos] = strval(tsantep);
  164.             InfoMaison[idx][mArmurePos] = strval(tarmurep);
  165.  
  166.             InfoMaison[idx][mPrix] = strval(tprix);
  167.             InfoMaison[idx][mPortes] = strval(tportes);
  168.             InfoMaison[idx][mType] = strval(ttype);
  169.  
  170.  
  171.             // Spawn
  172.  
  173.             InfoMaison[idx][mPickup] = CreateDynamicPickup(1273, 2, InfoMaison[idx][xEntree], InfoMaison[idx][yEntree], InfoMaison[idx][zEntree]);
  174.            
  175.             if(strcmp(propname, MAISON_DEFAULTP, false) == 0)
  176.             {
  177.                 format(InfoMaison[idx][mPhrase], 1024, "%s.\nA vendre\n%d$", defaultd, InfoMaison[idx][mPrix]);
  178.             }
  179.             else
  180.             {
  181.                 if(InfoMaison[idx][mLocation] != 1)
  182.                 {
  183.                     format(InfoMaison[idx][mPhrase], 1024, "%s.\nAppartient à %s.", defaultd, propname);
  184.                 }
  185.                 else
  186.                 {
  187.                     format(InfoMaison[idx][mPhrase], 1024, "%s.\nppartient à %s.\nLouable\nLoyer : %d$", defaultd, propname, InfoMaison[idx][mPrixLocation]);
  188.                 }
  189.             }
  190.             InfoMaison[idx][mDesc] = CreateDynamic3DTextLabel(InfoMaison[idx][mPhrase], 0x07BB00FF, InfoMaison[idx][xEntree], InfoMaison[idx][yEntree], InfoMaison[idx][zEntree]+2.0, 20.0);
  191.             printf("Maison %d chargée !", idx);
  192.             idx++;
  193.         }
  194.         mysql_free_result();
  195.     }
  196.     return 1;
  197. }
  198.  
  199. public ChargerCoffres()
  200. {
  201.     new idx = 1;
  202.     while(idx < sizeof(InfoCoffre))
  203.     {
  204.         mysql_query("SELECT * FROM `Coffres`");
  205.         mysql_store_result();
  206.         while(mysql_retrieve_row())
  207.         {
  208.             new ameliod[50], ameliom[50], amelioa[50], amelioar[50], pass[36], drogues[50], matos[50];
  209.             new arme1[50], arme1m[50], arme2[50], arme2m[50], arme3[50], arme3m[50], arme4[50], arme4m[50], argent[50], ouvert[50];
  210.  
  211.             InfoCoffre[idx][cID] = idx;
  212.  
  213.             mysql_get_field("ameliod", ameliod);
  214.             mysql_get_field("ameliom", ameliom);
  215.             mysql_get_field("amelioa", amelioa);
  216.             mysql_get_field("amelioar", amelioar);
  217.            
  218.             mysql_get_field("pass", pass);
  219.             mysql_get_field("drogues", drogues);
  220.             mysql_get_field("matos", matos);
  221.             mysql_get_field("argent", argent);
  222.             mysql_get_field("ouvert", ouvert);
  223.  
  224.             mysql_get_field("arme1", arme1);
  225.             mysql_get_field("arme1m", arme1m);
  226.             mysql_get_field("arme2", arme2);
  227.             mysql_get_field("arme2m", arme2m);
  228.             mysql_get_field("arme3", arme3);
  229.             mysql_get_field("arme3m", arme3m);
  230.             mysql_get_field("arme4", arme4);
  231.             mysql_get_field("arme4m", arme4m);
  232.  
  233.             InfoCoffre[idx][cAmeliod] = strval(ameliod);
  234.             Infocoffre[idx][cAmeliom] = strval(ameliom);
  235.             InfoCoffre[idx][cAmelioa] = strval(amelioa);
  236.             InfoCoffre[idx][cAmelioar] = strval(amelioar);
  237.  
  238.             InfoCoffre[idx][cPass] = pass;
  239.             InfoCoffre[idx][cDrogues] = strval(drogues);
  240.             InfoCoffre[idx][cMatos] = strval(matos);
  241.             InfoCoffre[idx][cArgent] = strval(argent);
  242.             InfoCoffre[idx][cOuvert] = strval(ouvert);
  243.  
  244.             InfoCoffre[idx][cArme1] = strval(arme1);
  245.             InfoCoffre[idx][cArme1m] = strval(arme1m);
  246.             InfoCoffre[idx][cArme2] = strval(arme2);
  247.             InfoCoffre[idx][cArme2m] = strval(arme2m);
  248.             InfoCoffre[idx][cArme3] = strval(arme3);
  249.             InfoCoffre[idx][cArme4] = strval(arme4);
  250.             InfoCoffre[idx][cArme3m] = strval(arme3m);
  251.             InfoCoffre[idx][cArme4m] = strval(arme4m);
  252.  
  253.             printf("Coffre %d chargé !", idx);
  254.             idx++;
  255.  
  256.         }
  257.         mysql_free_result();
  258.     }
  259. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement