Advertisement
WildWave

Untitled

Jun 30th, 2015
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.06 KB | None | 0 0
  1. // === < Includes > === //
  2. #include <a_samp>
  3. #include <DOF2>
  4. #include <streamer>
  5.  
  6. // === < Defines > === //
  7. #define MAX_GATES 100
  8. #define function%0(%1) forward%0(%1);public%0(%1)
  9. #define SCM SendClientMessage
  10. #define SCMToAll SendClientMessageToAll
  11. #define GatePath "Clans/Gates/%d.txt"
  12.  
  13. // === < Enums > === //
  14. enum gateInfo
  15. {
  16. gGate,
  17. gClanGate[90],
  18. gModel,
  19. Float:gCX,
  20. Float:gCY,
  21. Float:gCZ,
  22. Float:gCRX,
  23. Float:gCRY,
  24. Float:gCRZ,
  25. Float:gOX,
  26. Float:gOY,
  27. Float:gOZ,
  28. Float:gORX,
  29. Float:gORY,
  30. Float:gORZ,
  31. Float:gSpeed,
  32. gStatus
  33. };
  34.  
  35. // === < Vars > === //
  36. new gInfo[MAX_GATES][gateInfo];
  37. new gEdit[MAX_PLAYERS];
  38. new gEditID[MAX_PLAYERS];
  39. new Float:gPos[MAX_PLAYERS][3];
  40. new Float:gRot[MAX_PLAYERS][3];
  41.  
  42. public OnGameModeInit()
  43. {
  44. return 1;
  45. }
  46.  
  47. public OnGameModeExit()
  48. {
  49. DOF2_Exit();
  50. return 1;
  51. }
  52.  
  53. public OnPlayerCommandText(playerid, cmdtext[])
  54. {
  55. new tmp1[256], tmp2[256], idx;
  56. if(!strcmp(cmdtext, "/CreateGate", true) || !strcmp(cmdtext, "/cGate", true))
  57. {
  58. new object;
  59. if(!IsPlayerAdmin(playerid)) return 0;
  60. tmp1 = strtok(cmdtext, idx);
  61. if(!strlen(tmp1)) return SCM(playerid, -1, "[Usage]: /CreateGate(/cGate) <objectid>");
  62. for(new i = 0; i < MAX_GATES; i++)
  63. {
  64. if(!gInfo[i][gModel])
  65. {
  66. GetPlayerPos(playerid, gInfo[i][gCX], gInfo[i][gCY], gInfo[i][gCZ]);
  67. gInfo[i][gModel] = object;
  68. gInfo[i][gCX] = gInfo[i][gCX] + 2;
  69. gInfo[i][gCY] = gInfo[i][gCY] + 2;
  70. gInfo[i][gCRX] = 0;
  71. gInfo[i][gCRY] = 0;
  72. gInfo[i][gCRZ] = 0;
  73. GetPlayerPos(playerid, gInfo[i][gOX], gInfo[i][gOY], gInfo[i][gOZ]);
  74. gInfo[i][gOX] = gInfo[i][gOX] + 2;
  75. gInfo[i][gOY] = gInfo[i][gOY] + 2;
  76. gInfo[i][gORX] = 0;
  77. gInfo[i][gORY] = 0;
  78. gInfo[i][gORZ] = 0;
  79. gInfo[i][gSpeed] = 2;
  80. gInfo[i][gStatus] = 0;
  81. // Creating
  82. gInfo[i][gGate] = CreateDynamicObject(gInfo[i][gModel], gInfo[i][gCX], gInfo[i][gCY], gInfo[i][gCZ], gInfo[i][gCRX], gInfo[i][gCRY], gInfo[i][gCRZ]);
  83. i = MAX_GATES;
  84. }
  85. }
  86. return 1;
  87. }
  88.  
  89. if(!strcmp(cmdtext, "/EditGate", true) || !strcmp(cmdtext, "/eGate", true))
  90. {
  91. if(!IsPlayerAdmin(playerid)) return 0;
  92. tmp1 = strtok(cmdtext, idx);
  93. tmp2 = strtok(cmdtext, idx);
  94. if(!strlen(tmp1) || !strlen(tmp2))
  95. {
  96. SCM(playerid, -1, "[Usage]: /EditGate(/eGate) [option] [gateid]");
  97. SCM(playerid, -1, "Options: Close - Open - Speed");
  98. return 1;
  99. }
  100. for(new i = 0; i < MAX_GATES; i++)
  101. {
  102. new tmp3[256];
  103. if(!strcmp(tmp2, "Close", true))
  104. {
  105. tmp3 = strtok(cmdtext, idx);
  106. if(!strlen(tmp1)) return SendClientMessage(playerid, -1, "[Usage]: /EditGate position [gateid]");
  107. if(!gInfo[i][gModel]) return SendClientMessage(playerid, 0xFF0000AA, "[Error]: àééãé ùâåé");
  108. gEdit[playerid] = 1;
  109. gEditID[playerid] = i;
  110. GetDynamicObjectPos(gInfo[i][gGate], gPos[playerid][0], gPos[playerid][1], gPos[playerid][2]);
  111. GetDynamicObjectRot(gInfo[i][gGate], gRot[playerid][0], gRot[playerid][1], gRot[playerid][2]);
  112. EditDynamicObject(playerid, gInfo[i][gGate]);
  113. }
  114. if(!strcmp(tmp2, "Open", true))
  115. {
  116. tmp3 = strtok(cmdtext, idx);
  117. if(!strlen(tmp1)) return SendClientMessage(playerid, -1, "[Usage]: /EditGate position [gateid]");
  118. if(!gInfo[i][gModel]) return SendClientMessage(playerid, 0xFF0000AA, "[Error]: àééãé ùâåé");
  119. gEdit[playerid] = 2;
  120. gEditID[playerid] = i;
  121. GetDynamicObjectPos(gInfo[i][gGate], gPos[playerid][0], gPos[playerid][1], gPos[playerid][2]);
  122. GetDynamicObjectRot(gInfo[i][gGate], gRot[playerid][0], gRot[playerid][1], gRot[playerid][2]);
  123. EditDynamicObject(playerid, gInfo[i][gGate]);
  124. }
  125. if(!strcmp(tmp2, "Speed", true))
  126. {
  127. new Float:speed, tmp4[256];
  128. if(!strlen(tmp3) || !strlen(tmp4))
  129. {
  130. SendClientMessage(playerid, -1, "[Usage]: /editgate open [gateid] [speed]");
  131. }
  132. if(!gInfo[i][gModel]) return SendClientMessage(playerid, 0xFF0000AA, "[Error]: àééãé ùâåé");
  133. gInfo[i][gSpeed] = speed;
  134. }
  135. }
  136. return 1;
  137. }
  138.  
  139. /* if(!strcmp(cmdtext, "/Open", true))
  140. {
  141. new file[38];
  142. new ClanFile[256];
  143. format(file, sizeof(file), "Clans/HQ/%d.ini", DOF2_GetInt(ClanFile, "ID"));
  144. if(DOF2_GetInt(PFile(playerid),"InClan") == 0) return SendClientMessage(playerid,-1,"{FF0000}àéðê á÷ìàï");
  145. if(!fexist(file)) return SendClientMessage(playerid, -1, "{FF0000}àéï ì÷ìàï ùìê îô÷ãä");
  146.  
  147. for(new i = 0; i < MAX_GATES; i++)
  148. {
  149. if(gInfo[i][gModel] && IsPlayerInRangeOfPoint(playerid, 7, gInfo[i][gCX], gInfo[i][gCY], gInfo[i][gCZ]))
  150. {
  151. if(!gInfo[idx][gStatus])
  152. {
  153. gInfo[idx][gStatus] = 1;
  154. MoveDynamicObject(gInfo[i][gGate], gInfo[i][gOX], gInfo[i][gOY], gInfo[i][gOZ], gInfo[i][gSpeed]);
  155. SetDynamicObjectRot(gInfo[i][gGate], gInfo[i][gORX], gInfo[i][gORY], gInfo[i][gORZ]);
  156. }
  157. i = MAX_GATES;
  158. }
  159. }
  160. return 1;
  161. }
  162.  
  163. if(!strcmp(cmdtext, "/Close", true))
  164. {
  165. new file[38];
  166. new ClanFile[256];
  167. format(file, sizeof(file), "Clans/HQ/%d.ini", DOF2_GetInt(ClanFile, "ID"));
  168. if(DOF2_GetInt(PFile(playerid),"InClan") == 0) return SendClientMessage(playerid,-1,"{FF0000}àéðê á÷ìàï");
  169. if(!fexist(file)) return SendClientMessage(playerid, -1, "{FF0000}àéï ì÷ìàï ùìê îô÷ãä");
  170.  
  171. for(new i = 0; i < MAX_GATES; i++)
  172. {
  173. if(gInfo[i][gModel] && IsPlayerInRangeOfPoint(playerid, 7, gInfo[i][gCX], gInfo[i][gCY], gInfo[i][gCZ]))
  174. {
  175. if(!gInfo[idx][gStatus])
  176. {
  177. gInfo[idx][gStatus] = 0;
  178. MoveDynamicObject(gInfo[i][gGate], gInfo[i][gOX], gInfo[i][gOY], gInfo[i][gOZ], gInfo[i][gSpeed]);
  179. SetDynamicObjectRot(gInfo[i][gGate], gInfo[i][gORX], gInfo[i][gORY], gInfo[i][gORZ]);
  180. }
  181. i = MAX_GATES;
  182. }
  183. }
  184. return 1;
  185. } */
  186.  
  187. if(!strcmp(cmdtext, "/DeleteGate", true) || !strcmp(cmdtext, "/dGate", true))
  188. {
  189. new idx2;
  190. if(!IsPlayerAdmin(playerid)) return 0;
  191. tmp1 = strtok(cmdtext, idx);
  192. if(!strlen(tmp1)) return SCM(playerid, -1, "[Usage]: /DeleteGate(/dGate) <gateid>");
  193. if(!gInfo[idx2][gModel]) return SendClientMessage(playerid, 0xFF0000AA, "[Error]: àééãé ùâåé");
  194. for(new i = 0; i < MAX_GATES; i++)
  195. {
  196. gInfo[i][gModel] = 0;
  197. gInfo[i][gCX] = 0;
  198. gInfo[i][gCY] = 0;
  199. gInfo[i][gCZ] = 0;
  200. gInfo[i][gCRX] = 0;
  201. gInfo[i][gCRY] = 0;
  202. gInfo[i][gCRZ] = 0;
  203. gInfo[i][gOX] = 0;
  204. gInfo[i][gOY] = 0;
  205. gInfo[i][gOZ] = 0;
  206. gInfo[i][gORX] = 0;
  207. gInfo[i][gORY] = 0;
  208. gInfo[i][gORZ] = 0;
  209. gInfo[i][gSpeed] = 0;
  210. gInfo[i][gStatus] = 0;
  211. DestroyDynamicObject(gInfo[i][gGate]);
  212. }
  213. }
  214. return 1;
  215. }
  216.  
  217. //=================================== < Stocks > =============================//
  218. stock PFile(playerid)
  219. {
  220. new string[64];
  221. format(string,sizeof(string),UserPath,GetName[playerid]);
  222. return string;
  223. }
  224.  
  225. stock LoadGates()
  226. {
  227. new file[35],gateid;
  228. for(new i = 0; i < MAX_GATES; i++)
  229. {
  230. format(file, sizeof(file), "Clans/Gates/%d.ini", i);
  231. if(fexist(file))
  232. {
  233. format(gInfo[i][gClanGate], 90, "%s", DOF2_GetString(file, "ClanName"));
  234. gInfo[i][gModel] = DOF2_GetInt(SaveGates(), "Model");
  235. gInfo[i][gCX] = DOF2_GetFloat(SaveGates(), "X");
  236. gInfo[i][gCY] = DOF2_GetFloat(SaveGates(), "Y");
  237. gInfo[i][gCZ] = DOF2_GetFloat(SaveGates(), "Z");
  238. gInfo[i][gCRX] = DOF2_GetFloat(SaveGates(), "RX");
  239. gInfo[i][gCRY] = DOF2_GetFloat(SaveGates(), "RY");
  240. gInfo[i][gCRZ] = DOF2_GetFloat(SaveGates(), "RZ");
  241. gInfo[i][gOX] = DOF2_GetFloat(SaveGates(), "OX");
  242. gInfo[i][gOY] = DOF2_GetFloat(SaveGates(), "OY");
  243. gInfo[i][gOZ] = DOF2_GetFloat(SaveGates(), "OZ");
  244. gInfo[i][gORX] = DOF2_GetFloat(SaveGates(), "ORX");
  245. gInfo[i][gORY] = DOF2_GetFloat(SaveGates(), "ORY");
  246. gInfo[i][gORZ] = DOF2_GetFloat(SaveGates(), "ORZ");
  247. gInfo[i][gSpeed] = DOF2_GetFloat(SaveGates(), "Speed");
  248. gInfo[i][gStatus] = DOF2_GetInt(SaveGates(), "Status");
  249. gateid ++;
  250. }
  251. }
  252. printf("ClanFile > Gates: %d", gateid);
  253. return 1;
  254. }
  255.  
  256. stock strtok(const string[], &index)
  257. {
  258. new length = strlen(string);
  259. while ((index < length) && (string[index] <= ' '))
  260. {
  261. index++;
  262. }
  263.  
  264. new offset = index;
  265. new result[20];
  266. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  267. {
  268. result[index - offset] = string[index];
  269. index++;
  270. }
  271. result[index - offset] = EOS;
  272. return result;
  273. }
  274. //=================================== < Stocks > =============================//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement