Guest User

Church System

a guest
May 17th, 2013
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.27 KB | None | 0 0
  1. #include <a_samp>
  2. #include <streamer>
  3.  
  4. forward OnPlayerEnterChurchMenu(playerid, churchid);
  5. forward OnPlayerExitChurchMenu(playerid, churchid);
  6. forward OnPlayerEnterChurch(playerid, churchid);
  7. forward OnPlayerEnterCEPoint(playerid, churchid);
  8. forward OnPlayerEnterChurchVehicle(playerid, vehicleid, ispassenger);
  9. forward OnPlayerExitChurchVehicle(playerid, vehicleid);
  10. forward OnPlayerEnterChurchMission(playerid);
  11. forward OnPlayerEnterChurchMissionEx(playerid);
  12.  
  13. #if !defined _ALS_
  14. forward public _ALS_();
  15. _ALS_()<_ALS_:unhooked>{}
  16. _ALS_()<_ALS_:hooked>{}
  17. _ALS_()<>{}
  18. #endif
  19.  
  20. #define MAX_EPOINT 50
  21. #define MAX_CHURCH 50
  22.  
  23. enum E_SAMP_CHURCH
  24. {
  25. Float:churchx,
  26. Float:churchy,
  27. Float:churchz,
  28. c_enterable,
  29. bool:church_created,
  30. cpid,
  31. vehicle
  32. };
  33. new chInfo[MAX_CHURCH][E_SAMP_CHURCH];
  34. new churchID = 0,
  35. exitpoint = 1,
  36. churchVehicle = 0,
  37. exitPoint[MAX_CHURCH],
  38. misC[MAX_PLAYERS] = -1
  39. ;
  40.  
  41. /*
  42. native CreateChurch(enterable = 0, interior = -1, world = -1, Float:cpsize = 2.0, Float:churchx, Float:churchy, Float:churchz, Float:churchdistance = 100.0);
  43. native SetChurchExit(churchid, interior = -1, world = -1, Float:cpsize = 2.0, Float:churchx, Float:churchy, Float:churchz, Float:churchdistance = 100.0);
  44. native SpawnChurchVehicle(vehicleid, Float:spawnx, Float:spawny, Float:spawnz, Float:spawnangle, color1, color2, spawndelay);
  45. native StartChurchMission(playerid, Float:mx, Float:my, Float:mz, Float:cpsize = 5.0);
  46. native NextChurchMission(playerid, Float:mx, Float:my, Float:mz, Float:cpsize = 5.0);
  47. native StopChurchMission(playerid);
  48. native SetChurchMission(playerid, mission);
  49. native GetChurchMission(playerid);
  50. native IsValidChurch(churchid);
  51. */
  52.  
  53. stock SetChurchMission(playerid, mission)
  54. {
  55. if(mission == -1)
  56. {
  57. DisablePlayerCheckpoint(playerid);
  58. }
  59. misC[playerid] = mission;
  60. return 1;
  61. }
  62.  
  63. stock GetChurchMission(playerid)
  64. {
  65. return misC[playerid];
  66. }
  67.  
  68. stock StartChurchMission(playerid, Float:x, Float:y, Float:z, Float:size = 5.0)
  69. {
  70. misC[playerid] = 0;
  71. SetPlayerCheckpoint(playerid, x, y, z, size);
  72. return 1;
  73. }
  74.  
  75. stock NextChurchMission(playerid, Float:x, Float:y, Float:z, Float:size = 5.0)
  76. {
  77. misC[playerid] += 1;
  78. DisablePlayerCheckpoint(playerid);
  79. SetPlayerCheckpoint(playerid, x, y, z, size);
  80. return 1;
  81. }
  82.  
  83. stock SpawnChurchVehicle(vehicleid, Float:x, Float:y, Float:z, Float:angle, col1, col2, spawndelay)
  84. {
  85. churchVehicle++;
  86. chInfo[churchVehicle][vehicle] = AddStaticVehicleEx(vehicleid, x, y, z, angle, col1, col2, spawndelay);
  87. return churchVehicle;
  88. }
  89.  
  90. stock SetChurchExit(&id, interior = -1, world = -1, Float:cpsize = 2.0, Float:x, Float:y, Float:z, Float:distance = 100.0)
  91. {
  92. exitpoint++;
  93. id = ( exitpoint );
  94. exitPoint[exitpoint] = CreateDynamicCP(x, y, z, cpsize, world, interior, -1, distance);
  95. return 1;
  96. }
  97.  
  98. stock CreateChurch(enterable = 0, interior = -1, world = -1, Float:cpsize = 2.0, Float:x, Float:y, Float:z, Float:distance = 100.0)
  99. {
  100. churchID++;
  101. if(churchID > MAX_CHURCH)
  102. {
  103. print("Error: church.inc can't create church anymore!");
  104. return 1;
  105. }
  106. if(enterable < 0 || enterable > 1)
  107. {
  108. print("Error: enterbale parameters can only handle 0 and 1!");
  109. return 1;
  110. }
  111. chInfo[churchID][church_created] = true;
  112. chInfo[churchID][c_enterable] = enterable;
  113. chInfo[churchID][churchx] = x;
  114. chInfo[churchID][churchy] = y;
  115. chInfo[churchID][churchz] = z;
  116. chInfo[churchID][cpid] = CreateDynamicCP(x, y, z, cpsize, world, interior, -1, distance);
  117. return churchID;
  118. }
  119.  
  120. stock IsValidChurch(churchid)
  121. {
  122. if(chInfo[churchid][church_created] == true)
  123. return true;
  124. else if(chInfo[churchid][church_created] == false)
  125. return false;
  126. return 0;
  127. }
  128.  
  129. public OnPlayerEnterDynamicCP(playerid, checkpointid)
  130. {
  131. state _ALS_:hooked;
  132. for(new i = 0; i < MAX_CHURCH; i++)
  133. {
  134. if(!IsValidChurch(i)) continue;
  135. if(checkpointid == chInfo[i][cpid])
  136. {
  137. if(chInfo[i][c_enterable] == 0)
  138. {
  139. CallLocalFunction("OnPlayerEnterChurchMenu", "ii", playerid, checkpointid);
  140. continue;
  141. }
  142. else if(chInfo[i][c_enterable] == 1)
  143. {
  144. CallLocalFunction("OnPlayerEnterChurch", "ii", playerid, checkpointid);
  145. continue;
  146. }
  147. }
  148. }
  149. for(new a = 0; a < MAX_EPOINT; a++)
  150. {
  151. if(checkpointid == exitPoint[a])
  152. {
  153. CallLocalFunction("OnPlayerEnterCEPoint", "ii", playerid, checkpointid);
  154. continue;
  155. }
  156. }
  157. return church_OnPlayerEnterDynamicCP(playerid, checkpointid);
  158. }
  159.  
  160. forward church_OnPlayerEnterDynamicCP(playerid, checkpointid);
  161.  
  162. #if defined _ALS_OnPlayerEnterDynamicCP
  163. #undef OnPlayerEnterDynamicCP
  164. #else
  165. #define _ALS_OnPlayerEnterDynamicCP
  166. #endif
  167.  
  168. public church_OnPlayerEnterDynamicCP(playerid, checkpointid) <_ALS_:unhooked> return 1;
  169. public church_OnPlayerEnterDynamicCP(playerid, checkpointid) <> return 1;
  170.  
  171. #define OnPlayerEnterDynamicCP(%0) church_OnPlayerEnterDynamicCP(%0)<_ALS_:hooked>
  172.  
  173. public OnPlayerLeaveDynamicCP(playerid, checkpointid)
  174. {
  175. state _ALS_:hooked;
  176. for(new i = 0; i < MAX_CHURCH; i++)
  177. {
  178. if(!IsValidChurch(i)) continue;
  179. if(checkpointid == chInfo[i][cpid])
  180. {
  181. if(chInfo[i][c_enterable] == 0)
  182. {
  183. CallLocalFunction("OnPlayerExitChurchMenu", "ii", playerid, checkpointid);
  184. continue;
  185. }
  186. }
  187. }
  188. return church_OnPlayerLeaveDynamicCP(playerid, checkpointid);
  189. }
  190.  
  191. forward church_OnPlayerLeaveDynamicCP(playerid, checkpointid);
  192.  
  193. #if defined _ALS_OnPlayerLeaveDynamicCP
  194. #undef OnPlayerLeaveDynamicCP
  195. #else
  196. #define _ALS_OnPlayerLeaveDynamicCP
  197. #endif
  198.  
  199. public church_OnPlayerLeaveDynamicCP(playerid, checkpointid) <_ALS_:unhooked> return 1;
  200. public church_OnPlayerLeaveDynamicCP(playerid, checkpointid) <> return 1;
  201.  
  202. #define OnPlayerLeaveDynamicCP(%0) church_OnPlayerLeaveDynamicCP(%0)<_ALS_:hooked>
  203.  
  204. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  205. {
  206. state _ALS_:hooked;
  207. for(new i = 0; i < MAX_CHURCH; i++)
  208. {
  209. if(!IsValidChurch(i)) continue;
  210. if(vehicleid == chInfo[i][vehicle])
  211. {
  212. CallLocalFunction("OnPlayerEnterChurchVehicle", "iii", playerid, vehicleid, ispassenger);
  213. continue;
  214. }
  215. }
  216. return church_OnPlayerEnterVehicle(playerid, vehicleid, ispassenger);
  217. }
  218.  
  219. forward church_OnPlayerEnterVehicle(playerid, vehicleid, ispassenger);
  220.  
  221. #if defined _ALS_OnPlayerEnterVehicle
  222. #undef OnPlayerEnterVehicle
  223. #else
  224. #define _ALS_OnPlayerEnterVehicle
  225. #endif
  226.  
  227. public church_OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) <_ALS_:unhooked> return 1;
  228. public church_OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) <> return 1;
  229.  
  230. #define OnPlayerEnterVehicle(%0) church_OnPlayerEnterVehicle(%0)<_ALS_:hooked>
  231.  
  232. public OnPlayerExitVehicle(playerid, vehicleid)
  233. {
  234. state _ALS_:hooked;
  235. for(new i = 0; i < MAX_CHURCH; i++)
  236. {
  237. if(!IsValidChurch(i)) continue;
  238. if(vehicleid == chInfo[i][vehicle])
  239. {
  240. CallLocalFunction("OnPlayerExitChurchVehicle", "ii", playerid, vehicleid);
  241. continue;
  242. }
  243. }
  244. return church_OnPlayerExitVehicle(playerid, vehicleid);
  245. }
  246.  
  247. forward church_OnPlayerExitVehicle(playerid, vehicleid);
  248.  
  249. #if defined _ALS_OnPlayerExitVehicle
  250. #undef OnPlayerExitVehicle
  251. #else
  252. #define _ALS_OnPlayerExitVehicle
  253. #endif
  254.  
  255. public church_OnPlayerExitVehicle(playerid, vehicleid) <_ALS_:unhooked> return 1;
  256. public church_OnPlayerExitVehicle(playerid, vehicleid) <> return 1;
  257.  
  258. #define OnPlayerExitVehicle(%0) church_OnPlayerExitVehicle(%0)<_ALS_:hooked>
  259.  
  260. public OnPlayerEnterCheckpoint(playerid)
  261. {
  262. state _ALS_:hooked;
  263. if(misC[playerid] == 0)
  264. {
  265. CallLocalFunction("OnPlayerEnterChurchMission", "i", playerid);
  266. }
  267. else if(misC[playerid] >= 1)
  268. {
  269. CallLocalFunction("OnPlayerEnterChurchMissionEx", "i", playerid);
  270. }
  271. return church_OnPlayerEnterCheckpoint(playerid);
  272. }
  273.  
  274. forward church_OnPlayerEnterCheckpoint(playerid);
  275.  
  276. #if defined _ALS_OnPlayerEnterCheckpoint
  277. #undef OnPlayerEnterCheckpoint
  278. #else
  279. #define _ALS_OnPlayerEnterCheckpoint
  280. #endif
  281.  
  282. public church_OnPlayerEnterCheckpoint(playerid) <_ALS_:unhooked> return 1;
  283. public church_OnPlayerEnterCheckpoint(playerid) <> return 1;
  284.  
  285. #define OnPlayerEnterCheckpoint(%0) church_OnPlayerEnterCheckpoint(%0)<_ALS_:hooked>
Advertisement
Add Comment
Please, Sign In to add comment