Advertisement
Day_Mito

Include D_Races versão alpha

Apr 6th, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.14 KB | None | 0 0
  1. /*----------------------------------------------------------------------------*\
  2. =======================================
  3. D_Races
  4. =======================================
  5.  
  6. Descricao:
  7. Funções para sua criação de Corridas dinâmicas
  8.  
  9. Obeservação:
  10. Podem haver Bugs(Muitos), estou postando apenas para verem como,
  11. está ficando a mesma.
  12. Esta versão está compativel com minha GameMode de FreeRoam,
  13. então a menos que edite a mesma, não funcionara com você.
  14. Aguarde a versão 0.2 para poder ultilizar
  15.  
  16. Creditos:
  17. Dayvison - Criacao da include.
  18.  
  19. Versão:
  20. 0.1 Alpha, open source to #SSGames
  21.  
  22. Funcoes:
  23. Criadas:
  24. Race_Stop(raceid,bool:restart = false);
  25. Race_Create(name[]);
  26. Race_Destroy(raceid);
  27. Race_Exists(raceid);
  28. Race_IsActive(raceid);
  29. Race_AddCheckPoint(raceid,Float:x,Float:y,Float:z);
  30. Race_AddSpawn(raceid,Float:x,Float:y,Float:z,Float:ang);
  31. Race_GetNumSpawns(raceid);
  32. Race_GetNumCheckPoints(raceid);
  33. Race_SetWorld(raceid,world);
  34. Race_GetWorld(raceid);
  35. Race_SetInterior(raceid,interior);
  36. Race_GetInterior(raceid);
  37. Race_SetLaps(raceid,laps);
  38. Race_GetLaps(raceid);
  39. Race_SetMaxTime(raceid,time);
  40. Race_GetMaxTime(raceid);
  41. Race_SetPositionPrize(raceid,position,prize);
  42. Race_GetPositionPrize(raceid,position);
  43.  
  44. A serem feitas:
  45. Race_SetStartTime(raceid,time);
  46. Race_Start(raceid);
  47. Race_PlayerJoin(playerid,raceid);
  48. Race_PlayerLeave(playerid);
  49. Race_GetPlayerDistanceFromPutted(playerid,putted,type);
  50. Race_GetPlayerTime(playerid);
  51. Race_GetPlayerPosition(playerid);
  52. GetPlayerRace(playerid);
  53.  
  54. \*----------------------------------------------------------------------------*/
  55.  
  56.  
  57.  
  58. #define MAX_POSITIONS_R (5)
  59. #define MAX_SPAWNS (25)
  60. #define MAX_CHECKS (100)
  61.  
  62.  
  63. const sizeof_rSpawn = MAX_SPAWNS * 4;
  64. const sizeof_rCheck = MAX_CHECKS * 3;
  65.  
  66. enum _RaceInfo
  67. {
  68. Float:rSpawn[sizeof_rSpawn],
  69. Float:rCheck[sizeof_rCheck],
  70. rInterior,
  71. rVirtualWorld,
  72. rName[30],
  73. bool:rCreated,
  74. rNumSpawn,
  75. rNumChecks,
  76. rLaps,
  77. bool:rActive,
  78. rMaxTime,
  79. rPositionPrize[MAX_POSITIONS_R],
  80. }
  81. #define rSpawn][%1][%2] rSpawn][((%1) * 4)+(%2)]
  82. #define rCheck][%1][%2] rCheck][((%1) * 3)+(%2)]
  83.  
  84. new Race[MAX_RACES][_RaceInfo];
  85. stock Race_Stop(raceid,bool:restart = false)
  86. {
  87. if(!Race_Exists(raceid))
  88. {
  89. FormatLog(""LogFile"/Erros.log","Não foi possível parar a corrida %d. Ela não existe",raceid);
  90. return false;
  91. }
  92. if(Race_IsActive(raceid))
  93. {
  94. FormatLog(""LogFile"/Erros.log","Não foi possível parar a corrida %d. Ela não está iniciada.",raceid);
  95. return false;
  96. }
  97. if(restart)
  98. {
  99. KillTimer(Race[id][rTimer]);
  100. }
  101. foreach(Player,i)
  102. {
  103. if(GetPlayerRace(i) == raceid)
  104. {
  105. Race_PlayerLeave(i);
  106. }
  107. }
  108. return true;
  109. }
  110. stock Race_Create(name[],laps = 1,int = 0,vw = 0,maxtime = -1);
  111. {
  112. new id = -1;
  113. Loop:i(0,MAX_RACES)
  114. {3
  115. if(!Race[i][rCreated])
  116. {
  117. id = i;
  118. break;
  119. }
  120. }
  121. if(id == -1)
  122. {
  123. FormatLog(""LogFile"/Erros.log","Não foi possível criar a corrida %s, o limite de corridas foi atingido.",name);
  124. return id;
  125. }
  126. Loop:i(0,_RaceInfo)
  127. {
  128. Race[id][_RaceInfo:i] = 0;
  129. }
  130. Race[id][rCreated] = true;
  131. strcat(Race[id][rName],name);
  132. Race_SetInterior(id,int);
  133. Race_SetVirtualWorld(id,vw);
  134. Race_SetMaxTime(id,maxtime);
  135. Race_SetLaps(id,laps);
  136. return id;
  137. }
  138.  
  139. stock Race_Destroy(raceid)
  140. {
  141. if(!Race_Exists(raceid))
  142. {
  143. FormatLog(""LogFile"/Erros.log","Não foi possível remover a corrida %d. Ela não existe",raceid);
  144. return false;
  145. }
  146. if(Race_IsActive(raceid))
  147. {
  148. Race_Stop(raceid,true);
  149. }
  150. Loop:i(0,_RaceInfo)
  151. {
  152. Race[raceid][_RaceInfo:i] = 0;
  153. }
  154. return true;
  155. }
  156.  
  157. stock Race_Exists(raceid)
  158. {
  159. return Race[raceid][rCreated];
  160. }
  161.  
  162. stock Race_IsActive(raceid)
  163. {
  164. return Race[raceid][rActive];
  165. }
  166. stock Race_AddCheckPoint(raceid,Float:x,Float:y,Float:z)
  167. {
  168. if(!Race_Exists(raceid))
  169. {
  170. FormatLog(""LogFile"/Erros.log","Não foi possível adicionar o CheckPoint (%03f,%03f,%03f) na corrida id (%d). Ela não existe",x,y,z,raceid);
  171. return false;
  172. }
  173. if(Race_GetNumCheckPoints(raceid) >= MAX_CHECKS)
  174. {
  175. FormatLog(""LogFile"/Erros.log","Não foi possível adicionar o checkpoint (%03f,%03f,%03f) na corrida id (%d). O limite foi atingido.",x,y,z,raceid);
  176. return false;
  177. }
  178. new id = Race_GetNumCheckPoints(raceid);
  179. Race[raceid][rCheck][id][0] = x;
  180. Race[raceid][rCheck][id][1] = y;
  181. Race[raceid][rCheck][id][2] = z;
  182.  
  183. Race[raceid][rNumChecks] ++;
  184. return true;
  185. }
  186.  
  187. stock Race_AddSpawn(raceid,Float:x,Float:y,Float:z,Float:ang)
  188. {
  189. if(!Race_Exists(raceid))
  190. {
  191. FormatLog(""LogFile"/Erros.log","Não foi possível adicionar o spawn (%03f,%03f,%03f,%03f) na corrida id (%d). Ela não existe",x,y,z,ang,raceid);
  192. return false;
  193. }
  194. if(Race_GetNumSpawns(raceid) >= MAX_SPAWNS)
  195. {
  196. FormatLog(""LogFile"/Erros.log","Não foi possível adicionar o spawn (%03f,%03f,%03f,%03f) na corrida id (%d). O limite foi atingido.",x,y,z,ang,raceid);
  197. return false;
  198. }
  199. new id = Race_GetNumSpawns(raceid);
  200. Race[raceid][rSpawn][id][0] = x;
  201. Race[raceid][rSpawn][id][1] = y;
  202. Race[raceid][rSpawn][id][2] = z;
  203.  
  204. Race[raceid][rNumSpawn] ++;
  205. return true;
  206. }
  207. stock Race_GetNumSpawns(raceid)
  208. {
  209. if(!Race_Exists(raceid))
  210. {
  211. FormatLog(""LogFile"/Erros.log","Não foi possível obeter o Numero de Spawns da corrida %d. Ela não existe",raceid);
  212. return false;
  213. }
  214. return Race[raceid][rNumSpawn];
  215. }
  216. stock Race_GetNumCheckPoints(raceid)
  217. {
  218. if(!Race_Exists(raceid))
  219. {
  220. FormatLog(""LogFile"/Erros.log","Não foi possível obeter o Numero de CheckPoints da corrida %d. Ela não existe",raceid);
  221. return false;
  222. }
  223. return Race[raceid][rNumCheck];
  224. }
  225.  
  226. stock Race_SetWorld(raceid,world)
  227. {
  228. if(!Race_Exists(raceid))
  229. {
  230. FormatLog(""LogFile"/Erros.log","Não foi possível setar o Virtual World da corrida %d. Ela não existe",raceid);
  231. return false;
  232. }
  233. Race[raceid][rVirtualWorld] = world;
  234. if(Race_IsActive(raceid))
  235. {
  236. foreach(Player,i)
  237. {
  238. if(GetPlayerRace(i) == raceid)
  239. {
  240. SetPlayerVirtualWorld(i,world);
  241. }
  242. }
  243. }
  244. }
  245.  
  246. stock Race_SetInterior(raceid,int)
  247. {
  248. if(!Race_Exists(raceid))
  249. {
  250. FormatLog(""LogFile"/Erros.log","Não foi possível setar o interior da corrida %d. Ela não existe",raceid);
  251. return false;
  252. }
  253. Race[raceid][rInterior] = int;
  254. if(Race_IsActive(raceid))
  255. {
  256. foreach(Player,i)
  257. {
  258. if(GetPlayerRace(i) == raceid)
  259. {
  260. SetPlayerInterior(i,int);
  261. }
  262. }
  263. }
  264. }
  265.  
  266. stock Race_GetVirtualWorld(raceid)
  267. {
  268. if(!Race_Exists(raceid))
  269. {
  270. FormatLog(""LogFile"/Erros.log","Não foi possível obeter o Virtual World da corrida %d. Ela não existe",raceid);
  271. return false;
  272. }
  273. return Race[raceid][rVirtualWorld];
  274. }
  275. stock Race_GetInterior(raceid)
  276. {
  277. if(!Race_Exists(raceid))
  278. {
  279. FormatLog(""LogFile"/Erros.log","Não foi possível obeter o interior da corrida %d. Ela não existe",raceid);
  280. return false;
  281. }
  282. return Race[raceid][rInterior];
  283. }
  284.  
  285. stock Race_SetLaps(raceid,laps)
  286. {
  287. if(!Race_Exists(raceid))
  288. {
  289. FormatLog(""LogFile"/Erros.log","Não foi possível Setar voltas a corrida %d. Ela não existe",raceid);
  290. return false;
  291. }
  292. Race[raceid][rLaps] = laps;
  293. }
  294.  
  295. stock Race_SetMaxTime(raceid,maxtime)
  296. {
  297. if(!Race_Exists(raceid))
  298. {
  299. FormatLog(""LogFile"/Erros.log","Não foi possível setar o tempo maximo da corrida %d. Ela não existe",raceid);
  300. return false;
  301. }
  302. Race[raceid][rMaxTime] = maxtime;
  303. }
  304.  
  305. stock Race_GetMaxTime(raceid)
  306. {
  307. if(!Race_Exists(raceid))
  308. {
  309. FormatLog(""LogFile"/Erros.log","Não foi possível obeter o tempo maximo da corrida %d. Ela não existe",raceid);
  310. return false;
  311. }
  312. return Race[raceid][rMaxTime];
  313. }
  314.  
  315. stock Race_GetPositionPrize(raceid,position)
  316. {
  317. if(!Race_Exists(raceid))
  318. {
  319. FormatLog(""LogFile"/Erros.log","Não foi possível obeter o premio da posicao %d, da corrida %d. Ela não existe",position,raceid);
  320. return -1;
  321. }
  322. return Race[raceid][rPositionPrize][position];
  323. }
  324. stock Race_SetPositionPrize(raceid,position,prize)
  325. {
  326. if(!Race_Exists(raceid))
  327. {
  328. FormatLog(""LogFile"/Erros.log","Não foi possível obeter o premio da posicao %d, da corrida %d. Ela não existe",position,raceid);
  329. return false;
  330. }
  331. Race[raceid][rPositionPrize][position] = prize;
  332. return true;
  333. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement