Advertisement
Guest User

e_static

a guest
Jun 8th, 2013
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.77 KB | None | 0 0
  1. /*
  2. [Include] e_static | Check player state easily | v1
  3. By Excel
  4. Copyright (c) 2013
  5. */
  6.  
  7. #include <a_samp>
  8. #include <YSI\y_hooks>
  9.  
  10. #if defined _e_static_included
  11. #endinput
  12. #endif
  13. #define _e_static_included
  14.  
  15. /*
  16. native IsPlayerSpawned(playerid);
  17. native IsPlayerDead(playerid);
  18. native IsPlayerInClassSelection(playerid);
  19. native IsPlayerOnBike(playerid);
  20. native IsPlayerInCar(playerid);
  21. native IsPlayerInBoat(playerid);
  22. native IsPlayerInHelicopter(playerid);
  23. native IsPlayerInAircraft(playerid);
  24. native IsPlayerAfk(playerid);
  25. native IsPlayerInjured(playerid);
  26. native IsPlayerGod(playerid);
  27. native IsPlayerMale(playerid);
  28. native IsPlayerFemale(playerid);
  29. native IsPlayerInWater(playerid);
  30. native IsPlayerOnLand(playerid);
  31. */
  32.  
  33. #define \
  34. ENABLE \
  35. 1
  36.  
  37. #define \
  38. DISABLE \
  39. 0
  40.  
  41. #define \
  42. AFK_TIMER \
  43. 30000
  44.  
  45. enum
  46. p_data_vars
  47. {
  48. spawned,
  49. dead,
  50. class,
  51. afk,
  52. afktimer
  53.  
  54. }
  55. new
  56. player_info[ MAX_PLAYERS ][ p_data_vars ];
  57.  
  58. forward OnPlayerUpdateEx(playerid);
  59.  
  60. /*
  61. Function: IsPlayerSpawned(playerid);
  62. Usage: Checks wheater the player is spawned or not,
  63. If he is then it return a value 1 (Yes) or 0 (No)
  64. */
  65. stock IsPlayerSpawned(playerid)
  66. {
  67. if(player_info[ playerid ][ spawned ]==ENABLE) return true;
  68. else return false;
  69. }
  70.  
  71. /*
  72. Function: IsPlayerDead(playerid);
  73. Usage: Checks wheater the player is dead or not,
  74. If he is then it return a value 1 (Yes) or 0 (No)
  75. */
  76. stock IsPlayerDead(playerid)
  77. {
  78. if(player_info[ playerid ][ dead ]==ENABLE) return true;
  79. else return false;
  80. }
  81.  
  82. /*
  83. Function: IsPlayerInClassSelection(playerid);
  84. Usage: Checks wheater the player is selecting class or not,
  85. If he is then it return a value 1 (Yes) or 0 (No)
  86. */
  87. stock IsPlayerInClassSelection(playerid)
  88. {
  89. if(player_info[ playerid ][ class ]==ENABLE) return true;
  90. else return false;
  91. }
  92.  
  93. /*
  94. Function: IsPlayerOnBike(playerid);
  95. Usage: Checks wheater the player is on a bike or not,
  96. If he is then it return a value 1 (Yes) or 0 (No)
  97. */
  98. stock IsPlayerOnBike(playerid)
  99. {
  100. if(!IsPlayerInAnyVehicle(playerid)) return false;
  101. new
  102. Bikes[12]=
  103. { 581,509,481,421,462,510,463,522,461,448,586,468 },
  104. vehicleid=GetPlayerVehicleID(playerid);
  105. for(new i = 0; i < 12; i++)
  106. {
  107. if(GetVehicleModel(vehicleid) == Bikes[i])
  108. { return true; } else return false;
  109. }
  110. }
  111.  
  112. /*
  113. Function: IsPlayerInCar(playerid);
  114. Usage: Checks wheater the player is in a car or not,
  115. If he is then it return a value 1 (Yes) or 0 (No)
  116. */
  117. stock IsPlayerInCar(playerid)
  118. {
  119. if(!IsPlayerInAnyVehicle(playerid)) return false;
  120. new
  121. AllCars[93] = {
  122. 400,401,402,404,405,410,411,412,415,418,419,420,421,422,424,426,429,434,436,
  123. 438,439,442,445,451,458,466,467,470,474,475,477,478,480,480,480,480,489,490,
  124. 491,492,494,496,500,501,502,503,504,505,506,507,516,517,518,526,527,529,533,
  125. 534,535,536,540,541,542,543,545,546,547,549,550,551,555,558,559,560,561,562,
  126. 565,566,567,575,576,580,585,587,589,596,597,598,600,602,603,604,605 },
  127. vehicleid=GetPlayerVehicleID(playerid);
  128. for(new i = 0; i < 93; i++)
  129. {
  130. if(GetVehicleModel(vehicleid) == AllCars[i])
  131. { return true; } else return false;
  132. }
  133. }
  134.  
  135. /*
  136. Function: IsPlayerInBoat(playerid);
  137. Usage: Checks wheater the player is in a boat or not,
  138. If he is then it return a value 1 (Yes) or 0 (No)
  139. */
  140. stock IsPlayerInBoat(playerid)
  141. {
  142. if(!IsPlayerInAnyVehicle(playerid)) return false;
  143. new
  144. Boats[10] = {
  145. 472,473,595,493,430,453,484,446,452,454 },
  146. vehicleid=GetPlayerVehicleID(playerid);
  147. for(new i = 0; i < 10; i++)
  148. {
  149. if(GetVehicleModel(vehicleid) == Boats[i])
  150. { return true; } else return false;
  151. }
  152. }
  153.  
  154. /*
  155. Function: IsPlayerInHelicopter(playerid);
  156. Usage: Checks wheater the player is in a helicopter or not,
  157. If he is then it return a value 1 (Yes) or 0 (No)
  158. */
  159. stock IsPlayerInHelicopter(playerid)
  160. {
  161. if(!IsPlayerInAnyVehicle(playerid)) return false;
  162. new
  163. Helis[9] = {
  164. 548,425,488,487,417,563,497,447,469 },
  165. vehicleid=GetPlayerVehicleID(playerid);
  166. for(new i = 0; i < 9; i++)
  167. {
  168. if(GetVehicleModel(vehicleid) == Helis[i])
  169. { return true; } else return false;
  170. }
  171. }
  172.  
  173. /*
  174. Function: IsPlayerInAircraft(playerid);
  175. Usage: Checks wheater the player is in a helicopter or not,
  176. If he is then it return a value 1 (Yes) or 0 (No)
  177. */
  178. stock IsPlayerInAircraft(playerid)
  179. {
  180. if(!IsPlayerInAnyVehicle(playerid)) return false;
  181. new
  182. Aircrafts[20] = {
  183. 577,511,592,520,593,512,476,553,460,413,519,548,425,488,487,417,563,497,447,469 },
  184. vehicleid=GetPlayerVehicleID(playerid);
  185. for(new i = 0; i < 20; i++)
  186. {
  187. if(GetVehicleModel(vehicleid) == Aircrafts[i])
  188. { return true; } else return false;
  189. }
  190. }
  191.  
  192. /*
  193. Function: IsPlayerAfk(playerid);
  194. Usage: Checks wheater the player is afk mode or not,
  195. If he is then it return a value 1 (Yes) or 0 (No)
  196. */
  197. stock IsPlayerAfk(playerid)
  198. {
  199. if(player_info[ playerid ][ afk ]==ENABLE) return true;
  200. else return false;
  201. }
  202.  
  203. /*
  204. Function: IsPlayerInjured(playerid);
  205. Usage: Checks wheater the player is afk mode or not,
  206. If he is then it return a value 1 (Yes) or 0 (No)
  207. */
  208. stock IsPlayerInjured(playerid)
  209. {
  210. new
  211. Float:hp;
  212. if(hp<11)
  213. { return true; } else return false;
  214. }
  215.  
  216. /*
  217. Function: IsPlayerGod(playerid);
  218. Usage: Checks wheater the player is god mode or not,
  219. If he is then it return a value 1 (Yes) or 0 (No)
  220. */
  221. stock IsPlayerGod(playerid)
  222. {
  223. new
  224. Float:hp;
  225. if(hp>100)
  226. { return true; } else return false;
  227. }
  228.  
  229. /*
  230. Function: IsPlayerMale(playerid);
  231. Usage: Checks wheater the player is male or not,
  232. If he is then it return a value 1 (Yes) or 0 (No)
  233. */
  234. stock IsPlayerMale(playerid)
  235. {
  236. new
  237. Males[204] = {
  238. 0,1,2,7,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,32,33,34,35,36,37,43,44,45,46,47,48,
  239. 49,50,51,52,56,58,59,60,61,62,66,67,68,70,71,72,73,78,79,80,81,82,83,84,94,95,96,97,98,99,100,
  240. 101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,120,121,123,124,125,126,
  241. 127,128,132,133,134,135,136,137,142,143,144,146,147,153,154,155,156,158,159,160,161,162,163,164,
  242. 165,166,167,168,170,171,173,174,175,176,177,179,180,181,182,183,184,185,186,187,188,189,200,202,
  243. 203,204,206,209,210,217,220,222,221,223,227,228,229,230,234,235,256,239,240,241,242,247,248,249,
  244. 250,252,253,254,255,258,259,260,261,262,264,265,267,268,269,270,271,272,273,274,275,276,277,
  245. 278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,299 };
  246. for(new i = 0; i < 204; i++)
  247. {
  248. if(GetPlayerSkin(vehicleid) == Males[i])
  249. { return true; } else return false;
  250. }
  251.  
  252. }
  253.  
  254. /*
  255. Function: IsPlayerFemale(playerid);
  256. Usage: Checks wheater the player is female or not,
  257. If he is then it return a value 1 (Yes) or 0 (No)
  258. */
  259. stock IsPlayerFemale(playerid)
  260. {
  261. if(IsPlayerMale(playerid))
  262. { return false; } else return true;
  263.  
  264. }
  265.  
  266. /*
  267. Function: IsPlayerInWater(playerid);
  268. Usage: Checks wheater the player is in water or not,
  269. If he is then it return a value 1 (Yes) or 0 (No)
  270. */
  271. stock IsPlayerInWater(playerid)
  272. {
  273. new
  274. animlib[10],
  275. animname[10];
  276. GetAnimationName(GetPlayerAnimationIndex(playerid),
  277. animlib,
  278. sizeof(animlib),
  279. animname,
  280. sizeof(animname));
  281. return (!strcmp(animlib, "SWIM")) ? 1 : 0;
  282. }
  283.  
  284. /*
  285. Function: IsPlayerOnLand(playerid);
  286. Usage: Checks wheater the player is in land or not,
  287. If he is then it return a value 1 (Yes) or 0 (No)
  288. */
  289. stock IsPlayerOnLand(playerid)
  290. {
  291. if(IsPlayerInWater(playerid))
  292. { return false; } else return true;
  293. }
  294.  
  295. Hook:P_OnPlayerConnect(playerid)
  296. {
  297. SetTimerEx("OnPlayerUpdateEx",
  298. 1000,
  299. true,
  300. "i",
  301. playerid);
  302. return 1;
  303. }
  304.  
  305. Hook:P_OnPlayerRequestClass(playerid, classid)
  306. {
  307. player_info[ playerid ][ spawned ]=DISABLE;
  308. player_info[ playerid ][ dead ]=DISABLE;
  309. player_info[ playerid ][ class ]=ENABLE;
  310. return 1;
  311. }
  312.  
  313. Hook:P_OnPlayerSpawn(playerid)
  314. {
  315. player_info[ playerid ][ afktimer ]=0;
  316. player_info[ playerid ][ spawned ]=ENABLE;
  317. player_info[ playerid ][ dead ]=DISABLE;
  318. player_info[ playerid ][ class ]=DISABLE;
  319. return 1;
  320. }
  321.  
  322. Hook:P_OnPlayerDeath(playerid, killerid, reason)
  323. {
  324. player_info[ playerid ][ spawned ]=DISABLE;
  325. player_info[ playerid ][ dead ]=ENABLE;
  326. player_info[ playerid ][ class ]=DISABLE;
  327. return 1;
  328. }
  329.  
  330. Hook:P_OnPlayerUpdateEx(playerid)
  331. {
  332. if(player_info[ playerid ][ afktimer ]<0) return false;
  333. player_info[ playerid ][ afktimer ]++;
  334. if(player_info[ playerid ][ afktimer ]>AFK_TIMER)
  335. { player_info[ playerid ][ afk ]=ENABLE,
  336. player_info[ playerid ][ afktimer ]=-1; }
  337. return 1;
  338. }
  339.  
  340. Hook:P_OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  341. {
  342. player_info[ playerid ][ afk ]=DISABLE,
  343. player_info[ playerid ][ afktimer ]=0;
  344. return 1;
  345. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement