Guest User

Spawn

a guest
Aug 31st, 2011
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. enum Spawn
  2. {
  3. X,
  4. Y,
  5. Z,
  6. };
  7.  
  8. new SetSpawn[MAX_PLAYERS][Spawn];
  9.  
  10.  
  11. if (strcmp(cmdtext, "/setspawn", true)==0)
  12. {
  13. GetPlayerPos(playerid, PosX[playerid], PosY[playerid], PosZ[playerid]);
  14. GetPlayerFacingAngle(playerid, PosA[playerid]);
  15. SendClientMessage(playerid, COLOR_WHITE, "Positon set!");
  16. PosI[playerid] = (GetPlayerInterior(playerid));
  17. SpawnSpremanje(playerid);
  18. return 1;
  19. }
  20.  
  21. forward SpawnSpremanje(playerid);
  22. public SpawnSpremanje(playerid)
  23. {
  24. new name[MAX_PLAYER_NAME], string[128];
  25. GetPlayerName(playerid,name,sizeof(name));
  26. format(string, sizeof string,"/Pos/%s.ini",name);
  27. new File:Save = fopen(string, io_write);
  28. if (Save)
  29. {
  30. new file[128];
  31. format(file, sizeof file, "X: %d\n\r", PosX[playerid]);
  32. { fwrite(Save, file); }
  33. format(file, sizeof file, "Y: %d\n\r", PosY[playerid]);
  34. { fwrite(Save, file); }
  35. format(file, sizeof file, "Z: %d\n\r", PosZ[playerid]);
  36. { fwrite(Save, file); }
  37. }
  38. fclose(Save);
  39. return 1;
  40. }
  41.  
  42. forward UcitavanjeSpawn(playerid);
  43. public UcitavanjeSpawn(playerid)
  44. {
  45. new name[MAX_PLAYER_NAME], string[128];
  46. GetPlayerName(playerid,name,sizeof(name));
  47. format(string, sizeof string,"/Pos/%s.ini",name);
  48. new File:Pos = fopen(string, io_write);
  49. if (Pos)
  50. {
  51. new file[128];
  52. new pass[256];
  53. new passres[128], value[128];
  54. fread(account, pass, sizeof pass);
  55. passres = GetFileString(pass);
  56. if(strfind(passres, "X") != -1)
  57. {
  58. value = GetFileValue(pass);
  59. SetSpawn[playerid][X] = strval(value);
  60. }
  61. if(strfind(passres, "Y") != -1)
  62. {
  63. value = GetFileValue(pass);
  64. SetSpawn[playerid][Y] = strval(value);
  65. }
  66. if(strfind(passres, "Z") != -1)
  67. {
  68. value = GetFileValue(pass);
  69. SetSpawn[playerid][Z] = strval(value);
  70. }
  71. }
  72. fclose(Pos);
  73. SetPlayerPos(playerid,SetSpawn[playerid][X],SetSpawn[playerid][Y],SetSpawn[playerid][Z]);
  74. return 1;
  75. }
  76.  
  77. stock GetFileString(string[])
  78. {
  79. new result[128];
  80. result[0] = 0;
  81. if (strfind(string, ":", true) == -1) return result;
  82. new id = strfind(string, ":", true);
  83. strmid(result, string, 0, id, 128);
  84. return result;
  85. }
  86.  
  87. stock GetFileValue(string[])
  88. {
  89. new val[128];
  90. val[0] = 0;
  91. if (strfind(string , ":", true) == -1) return val;
  92. new id = strfind(string, ":", true);
  93. strmid(val, string, id+2, strlen(string), 128);
  94. return val;
  95. }
Advertisement
Add Comment
Please, Sign In to add comment