Advertisement
Guest User

Untitled

a guest
Apr 24th, 2012
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. /////////////////////////////////////////
  2. // FS CREATION DISTRIBUTEUR DYNAMIQUE //
  3. ////////////////////////////////////////
  4. #include <a_samp>
  5. #define MAX_ATM 60
  6.  
  7. enum Distributeur
  8. {
  9. Float:dXSpawn,
  10. Float:dYSpawn,
  11. Float:dZSpawn,
  12. Float:dASpawn
  13. }
  14. new atm[MAX_ATM][Distributeur];
  15. public OnFilterScriptInit()
  16. {
  17. CreationAtm();
  18. return 1;
  19. }
  20.  
  21. public OnPlayerCommandText(playerid, cmdtext[])
  22. {
  23. if (strcmp("/creeratm",cmdtext, true, 10) == 0)
  24. {
  25. new Float:x, Float:y, Float:z,Float:a;
  26. new string[250];
  27. GetPlayerPos(playerid,x,y,z);
  28. GetPlayerFacingAngle(playerid,a);
  29. CreateObject(2942,x,y,z,0.5,0,0,0);
  30. atm[playerid][dXSpawn] = x;
  31. atm[playerid][dYSpawn] = y;
  32. atm[playerid][dZSpawn] = z;
  33. atm[playerid][dASpawn] = a;
  34. SetTimerEx("DispraitTextdraw", 5000, false, "i", playerid);
  35. new File:AtmFichier = fopen("atm.cfg",io_append);
  36. format(string, sizeof(string), "%f|%f|%f|%f\r\n",atm[playerid][dXSpawn],atm[playerid][dYSpawn],atm[playerid][dZSpawn],atm[playerid][dASpawn]);
  37. fwrite(AtmFichier, string);
  38. fclose(AtmFichier);
  39. return 1;
  40. }
  41. return 0;
  42. }
  43.  
  44. forward CreationAtm();
  45. public CreationAtm()
  46. {
  47. new arrCoords[32][64];
  48. new strFromFile2[250];
  49. new idx;
  50. new File:AtmFichier = fopen("atm.cfg",io_readwrite);
  51. while(fread(AtmFichier, strFromFile2))
  52. {
  53. split(strFromFile2, arrCoords, '|');
  54. atm[idx][dXSpawn] = floatstr(arrCoords[0]);
  55. atm[idx][dYSpawn] = floatstr(arrCoords[1]);
  56. atm[idx][dZSpawn] = floatstr(arrCoords[2]);
  57. atm[idx][dASpawn] = floatstr(arrCoords[3]);
  58. CreateObject(2942,atm[idx][dXSpawn],atm[idx][dYSpawn],atm[idx][dZSpawn]-0.5,0,0,0);
  59. }
  60. fclose(AtmFichier);
  61. return 1;
  62. }
  63. forward split(const strsrc[], strdest[][], delimiter);
  64. /////////////////////////////////////
  65. // Pas de moi cette fonction split //
  66. /////////////////////////////////////
  67. public split(const strsrc[], strdest[][], delimiter)
  68. {
  69. new i, li;
  70. new aNum;
  71. new len;
  72. while(i <= strlen(strsrc)){
  73. if(strsrc[i]==delimiter || i==strlen(strsrc)){
  74. len = strmid(strdest[aNum], strsrc, li, i, 128);
  75. strdest[aNum][len] = 0;
  76. li = i+1;
  77. aNum++;
  78. }
  79. i++;
  80. }
  81. return 1;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement