FCNPC.inc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. /* ---------------------------------
  2. FCNPC Plugin PAWN include
  3. - File: FCNPC.inc
  4. - Author: OrMisicL
  5. - Contributor: ziggi
  6. ---------------------------------*/
  7. #if defined _FCNPC_included
  8. #endinput
  9. #endif
  10. #define _FCNPC_included
  11. #pragma library FCNPC
  12. // Version
  13. #define FCNPC_INCLUDE_VERSION 180
  14. public FCNPC_IncludeVersion = FCNPC_INCLUDE_VERSION;
  15. #pragma unused FCNPC_IncludeVersion
  16. // Definitions
  17. #define FCNPC_MOVE_TYPE_AUTO (-1)
  18. #define FCNPC_MOVE_TYPE_WALK (0)
  19. #define FCNPC_MOVE_TYPE_RUN (1)
  20. #define FCNPC_MOVE_TYPE_SPRINT (2)
  21. #define FCNPC_MOVE_TYPE_DRIVE (3)
  22. #define FCNPC_MOVE_SPEED_AUTO (-1.0)
  23. #define FCNPC_MOVE_SPEED_WALK (0.1552086)
  24. #define FCNPC_MOVE_SPEED_RUN (0.56444)
  25. #define FCNPC_MOVE_SPEED_SPRINT (0.926784)
  26. #define FCNPC_MAX_NODES (64)
  27. #define FCNPC_INVALID_MOVEPATH_ID (-1)
  28. #define FCNPC_INVALID_RECORD_ID (-1)
  29. // Compatibility with older versions
  30. #if !defined MOVE_TYPE_AUTO
  31. #define MOVE_TYPE_AUTO FCNPC_MOVE_TYPE_AUTO
  32. #endif
  33. #if !defined MOVE_TYPE_WALK
  34. #define MOVE_TYPE_WALK FCNPC_MOVE_TYPE_WALK
  35. #endif
  36. #if !defined MOVE_TYPE_RUN
  37. #define MOVE_TYPE_RUN FCNPC_MOVE_TYPE_RUN
  38. #endif
  39. #if !defined MOVE_TYPE_SPRINT
  40. #define MOVE_TYPE_SPRINT FCNPC_MOVE_TYPE_SPRINT
  41. #endif
  42. #if !defined MOVE_TYPE_DRIVE
  43. #define MOVE_TYPE_DRIVE FCNPC_MOVE_TYPE_DRIVE
  44. #endif
  45. #if !defined MOVE_SPEED_AUTO
  46. #define MOVE_SPEED_AUTO FCNPC_MOVE_SPEED_AUTO
  47. #endif
  48. #if !defined MOVE_SPEED_WALK
  49. #define MOVE_SPEED_WALK FCNPC_MOVE_SPEED_WALK
  50. #endif
  51. #if !defined MOVE_SPEED_RUN
  52. #define MOVE_SPEED_RUN FCNPC_MOVE_SPEED_RUN
  53. #endif
  54. #if !defined MOVE_SPEED_SPRINT
  55. #define MOVE_SPEED_SPRINT FCNPC_MOVE_SPEED_SPRINT
  56. #endif
  57. #if !defined MAX_NODES
  58. #define MAX_NODES FCNPC_MAX_NODES
  59. #endif
  60. #if !defined INVALID_MOVEPATH_ID
  61. #define INVALID_MOVEPATH_ID FCNPC_INVALID_MOVEPATH_ID
  62. #endif
  63. #if !defined INVALID_RECORD_ID
  64. #define INVALID_RECORD_ID FCNPC_INVALID_RECORD_ID
  65. #endif
  66. // Callbacks
  67. forward FCNPC_OnCreate(npcid);
  68. forward FCNPC_OnDestroy(npcid);
  69. forward FCNPC_OnSpawn(npcid);
  70. forward FCNPC_OnRespawn(npcid);
  71. forward FCNPC_OnDeath(npcid, killerid, weaponid);
  72. forward FCNPC_OnVehicleEntryComplete(npcid, vehicleid, seat);
  73. forward FCNPC_OnVehicleExitComplete(npcid);
  74. forward FCNPC_OnReachDestination(npcid);
  75. forward FCNPC_OnFinishPlayback(npcid);
  76. forward FCNPC_OnTakeDamage(npcid, damagerid, weaponid, bodypart, Float:health_loss);
  77. forward FCNPC_OnGiveDamage(npcid, damagedid, weaponid, bodypart, Float:health_loss);
  78. forward FCNPC_OnVehicleTakeDamage(npcid, damagerid, vehicleid, weaponid, Float:x, Float:y, Float:z);
  79. forward FCNPC_OnWeaponShot(npcid, weaponid, hittype, hitid, Float:x, Float:y, Float:z);
  80. forward FCNPC_OnWeaponStateChange(npcid, weapon_state);
  81. forward FCNPC_OnFinishNodePoint(npcid, point);
  82. forward FCNPC_OnChangeNode(npcid, nodeid);
  83. forward FCNPC_OnFinishNode(npcid);
  84. forward FCNPC_OnStreamIn(npcid, forplayerid);
  85. forward FCNPC_OnStreamOut(npcid, forplayerid);
  86. forward FCNPC_OnUpdate(npcid);
  87. forward FCNPC_OnFinishMovePath(npcid, pathid);
  88. forward FCNPC_OnFinishMovePathPoint(npcid, pathid, pointid);
  89. forward FCNPC_OnChangeHeightPos(npcid, Float:new_z, Float:old_z); // disabled by default, see FCNPC_SetMinHeightPosCall
  90. // Natives
  91. native FCNPC_GetPluginVersion(version[], const size = sizeof(version));
  92. native FCNPC_SetUpdateRate(rate);
  93. native FCNPC_GetUpdateRate();
  94. native FCNPC_SetTickRate(rate);
  95. native FCNPC_GetTickRate();
  96. native FCNPC_InitMapAndreas(address);
  97. native FCNPC_ToggleCrashLogCreation(bool:toggle);
  98. native FCNPC_GetCrashLogCreation();
  99. native FCNPC_Create(name[]);
  100. native FCNPC_Destroy(npcid);
  101. native FCNPC_Spawn(npcid, skinid, Float:x, Float:y, Float:z);
  102. native FCNPC_Respawn(npcid);
  103. native FCNPC_IsSpawned(npcid);
  104. native FCNPC_Kill(npcid);
  105. native FCNPC_IsDead(npcid);
  106. native FCNPC_IsValid(npcid);
  107. native FCNPC_IsStreamedIn(npcid, forplayerid);
  108. native FCNPC_IsStreamedForAnyone(npcid);
  109. native FCNPC_GetValidArray(npcs[], const size = sizeof(npcs));
  110. native FCNPC_SetPosition(npcid, Float:x, Float:y, Float:z);
  111. native FCNPC_GivePosition(npcid, Float:x, Float:y, Float:z);
  112. native FCNPC_GetPosition(npcid, &Float:x, &Float:y, &Float:z);
  113. native FCNPC_SetAngle(npcid, Float:angle);
  114. native Float:FCNPC_GiveAngle(npcid, Float:angle);
  115. native FCNPC_SetAngleToPos(npcid, Float:x, Float:y);
  116. native FCNPC_SetAngleToPlayer(npcid, playerid);
  117. native Float:FCNPC_GetAngle(npcid);
  118. native FCNPC_SetQuaternion(npcid, Float:w, Float:x, Float:y, Float:z);
  119. native FCNPC_GiveQuaternion(npcid, Float:w, Float:x, Float:y, Float:z);
  120. native FCNPC_GetQuaternion(npcid, &Float:w, &Float:x, &Float:y, &Float:z);
  121. native FCNPC_SetVelocity(npcid, Float:x, Float:y, Float:z, bool:update_pos = false);
  122. native FCNPC_GiveVelocity(npcid, Float:x, Float:y, Float:z, bool:update_pos = false);
  123. native FCNPC_GetVelocity(npcid, &Float:x, &Float:y, &Float:z);
  124. native FCNPC_SetSpeed(npcid, Float:speed);
  125. native Float:FCNPC_GetSpeed(npcid);
  126. native FCNPC_SetInterior(npcid, interiorid);
  127. native FCNPC_GetInterior(npcid);
  128. native FCNPC_SetVirtualWorld(npcid, worldid);
  129. native FCNPC_GetVirtualWorld(npcid);
  130. native FCNPC_SetHealth(npcid, Float:health);
  131. native Float:FCNPC_GiveHealth(npcid, Float:health);
  132. native Float:FCNPC_GetHealth(npcid);
  133. native FCNPC_SetArmour(npcid, Float:armour);
  134. native Float:FCNPC_GiveArmour(npcid, Float:armour);
  135. native Float:FCNPC_GetArmour(npcid);
  136. native FCNPC_SetInvulnerable(npcid, bool:invulnerable = true);
  137. native FCNPC_IsInvulnerable(npcid);
  138. native FCNPC_SetSkin(npcid, skinid);
  139. native FCNPC_GetSkin(npcid);
  140. native FCNPC_SetWeapon(npcid, weaponid);
  141. native FCNPC_GetWeapon(npcid);
  142. native FCNPC_SetAmmo(npcid, ammo);
  143. native FCNPC_GiveAmmo(npcid, ammo);
  144. native FCNPC_GetAmmo(npcid);
  145. native FCNPC_SetAmmoInClip(npcid, ammo);
  146. native FCNPC_GiveAmmoInClip(npcid, ammo);
  147. native FCNPC_GetAmmoInClip(npcid);
  148. native FCNPC_SetWeaponSkillLevel(npcid, skill, level);
  149. native FCNPC_GiveWeaponSkillLevel(npcid, skill, level);
  150. native FCNPC_GetWeaponSkillLevel(npcid, skill);
  151. native FCNPC_SetWeaponState(npcid, weaponstate);
  152. native FCNPC_GetWeaponState(npcid);
  153. native FCNPC_SetWeaponReloadTime(npcid, weaponid, time);
  154. native FCNPC_GetWeaponReloadTime(npcid, weaponid);
  155. native FCNPC_GetWeaponActualReloadTime(npcid, weaponid);
  156. native FCNPC_SetWeaponShootTime(npcid, weaponid, time);
  157. native FCNPC_GetWeaponShootTime(npcid, weaponid);
  158. native FCNPC_SetWeaponClipSize(npcid, weaponid, size);
  159. native FCNPC_GetWeaponClipSize(npcid, weaponid);
  160. native FCNPC_GetWeaponActualClipSize(npcid, weaponid);
  161. native FCNPC_SetWeaponAccuracy(npcid, weaponid, Float:accuracy);
  162. native Float:FCNPC_GetWeaponAccuracy(npcid, weaponid);
  163. native FCNPC_SetWeaponInfo(npcid, weaponid, reload_time = -1, shoot_time = -1, clip_size = -1, Float:accuracy = 1.0);
  164. native FCNPC_GetWeaponInfo(npcid, weaponid, &reload_time = -1, &shoot_time = -1, &clip_size = -1, &Float:accuracy = 1.0);
  165. native FCNPC_SetWeaponDefaultInfo(weaponid, reload_time = -1, shoot_time = -1, clip_size = -1, Float:accuracy = 1.0);
  166. native FCNPC_GetWeaponDefaultInfo(weaponid, &reload_time = -1, &shoot_time = -1, &clip_size = -1, &Float:accuracy = 1.0);
  167. native FCNPC_SetKeys(npcid, ud_analog, lr_analog, keys);
  168. native FCNPC_GetKeys(npcid, &ud_analog, &lr_analog, &keys);
  169. native FCNPC_SetSpecialAction(npcid, actionid);
  170. native FCNPC_GetSpecialAction(npcid);
  171. native FCNPC_SetAnimation(npcid, animationid, Float:fDelta = 4.1, loop = 0, lockx = 1, locky = 1, freeze = 0, time = 1);
  172. native FCNPC_SetAnimationByName(npcid, name[], Float:fDelta = 4.1, loop = 0, lockx = 1, locky = 1, freeze = 0, time = 1);
  173. native FCNPC_ResetAnimation(npcid);
  174. native FCNPC_GetAnimation(npcid, &animationid = 0, &Float:fDelta = 4.1, &loop = 0, &lockx = 1, &locky = 1, &freeze = 0, &time = 1);
  175. native FCNPC_ApplyAnimation(npcid, animlib[], animname[], Float:fDelta = 4.1, loop = 0, lockx = 1, locky = 1, freeze = 0, time = 1);
  176. native FCNPC_ClearAnimations(npcid);
  177. native FCNPC_SetFightingStyle(npcid, style);
  178. native FCNPC_GetFightingStyle(npcid);
  179. native FCNPC_ToggleReloading(npcid, bool:toggle);
  180. native FCNPC_ToggleInfiniteAmmo(npcid, bool:toggle);
  181. native FCNPC_GoTo(npcid, Float:x, Float:y, Float:z, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, bool:UseMapAndreas = false, Float:radius = 0.0, bool:setangle = true, Float:dist_offset = 0.0, stopdelay = 250);
  182. native FCNPC_GoToPlayer(npcid, playerid, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, bool:UseMapAndreas = false, Float:radius = 0.0, bool:setangle = true, Float:dist_offset = 0.0, Float:dist_check = 1.5, stopdelay = 250);
  183. native FCNPC_Stop(npcid);
  184. native FCNPC_IsMoving(npcid);
  185. native FCNPC_IsMovingAtPlayer(npcid, playerid);
  186. native FCNPC_GetDestinationPoint(npcid, &Float:x, &Float:y, &Float:z);
  187. native FCNPC_AimAt(npcid, Float:x, Float:y, Float:z, bool:shoot = false, shoot_delay = -1, bool:setangle = true, Float:offset_from_x = 0.0, Float:offset_from_y = 0.0, Float:offset_from_z = 0.0);
  188. native FCNPC_AimAtPlayer(npcid, playerid, bool:shoot = false, shoot_delay = -1, bool:setangle = true, Float:offset_x = 0.0, Float:offset_y = 0.0, Float:offset_z = 0.0, Float:offset_from_x = 0.0, Float:offset_from_y = 0.0, Float:offset_from_z = 0.0);
  189. native FCNPC_StopAim(npcid);
  190. native FCNPC_MeleeAttack(npcid, delay = -1, bool:fightstyle = false);
  191. native FCNPC_StopAttack(npcid);
  192. native FCNPC_IsAttacking(npcid);
  193. native FCNPC_IsAiming(npcid);
  194. native FCNPC_IsAimingAtPlayer(npcid, playerid);
  195. native FCNPC_GetAimingPlayer(npcid);
  196. native FCNPC_IsShooting(npcid);
  197. native FCNPC_IsReloading(npcid);
  198. native FCNPC_TriggerWeaponShot(npcid, weaponid, hittype, hitid, Float:x, Float:y, Float:z, bool:ishit = true, Float:offset_from_x = 0.0, Float:offset_from_y = 0.0, Float:offset_from_z = 0.0);
  199. native FCNPC_EnterVehicle(npcid, vehicleid, seatid, type = FCNPC_MOVE_TYPE_WALK);
  200. native FCNPC_ExitVehicle(npcid);
  201. native FCNPC_PutInVehicle(npcid, vehicleid, seatid);
  202. native FCNPC_RemoveFromVehicle(npcid);
  203. native FCNPC_GetVehicleID(npcid);
  204. native FCNPC_GetVehicleSeat(npcid);
  205. native FCNPC_SetVehicleSiren(npcid, bool:status);
  206. native FCNPC_IsVehicleSiren(npcid);
  207. native FCNPC_SetVehicleHealth(npcid, Float:health);
  208. native Float:FCNPC_GetVehicleHealth(npcid);
  209. native FCNPC_SetVehicleHydraThrusters(npcid, direction);
  210. native FCNPC_GetVehicleHydraThrusters(npcid);
  211. native FCNPC_SetVehicleGearState(npcid, gear_state);
  212. native FCNPC_GetVehicleGearState(npcid);
  213. native FCNPC_SetSurfingOffsets(npcid, Float:x, Float:y, Float:z);
  214. native FCNPC_GiveSurfingOffsets(npcid, Float:x, Float:y, Float:z);
  215. native FCNPC_GetSurfingOffsets(npcid, &Float:x, &Float:y, &Float:z);
  216. native FCNPC_SetSurfingVehicle(npcid, vehicleid);
  217. native FCNPC_GetSurfingVehicle(npcid);
  218. native FCNPC_SetSurfingObject(npcid, objectid);
  219. native FCNPC_GetSurfingObject(npcid);
  220. native FCNPC_SetSurfingPlayerObject(npcid, objectid);
  221. native FCNPC_GetSurfingPlayerObject(npcid);
  222. native FCNPC_StopSurfing(npcid);
  223. native FCNPC_StartPlayingPlayback(npcid, file[] = "", recordid = FCNPC_INVALID_RECORD_ID, bool:auto_unload = false);
  224. native FCNPC_StopPlayingPlayback(npcid);
  225. native FCNPC_PausePlayingPlayback(npcid);
  226. native FCNPC_ResumePlayingPlayback(npcid);
  227. native FCNPC_LoadPlayingPlayback(file[]);
  228. native FCNPC_UnloadPlayingPlayback(recordid);
  229. native FCNPC_SetPlayingPlaybackPath(npcid, path[]);
  230. native FCNPC_GetPlayingPlaybackPath(npcid, path[], const size = sizeof(path));
  231. native FCNPC_OpenNode(nodeid);
  232. native FCNPC_CloseNode(nodeid);
  233. native FCNPC_IsNodeOpen(nodeid);
  234. native FCNPC_GetNodeType(nodeid);
  235. native FCNPC_SetNodePoint(nodeid, point);
  236. native FCNPC_GetNodePointPosition(nodeid, &Float:x, &Float:y, &Float:z);
  237. native FCNPC_GetNodePointCount(nodeid);
  238. native FCNPC_GetNodeInfo(nodeid, &vehnodes, &pednodes, &navinode);
  239. native FCNPC_PlayNode(npcid, nodeid, move_type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, bool:UseMapAndreas = false, Float:radius = 0.0, bool:setangle = true);
  240. native FCNPC_StopPlayingNode(npcid);
  241. native FCNPC_PausePlayingNode(npcid);
  242. native FCNPC_ResumePlayingNode(npcid);
  243. native FCNPC_IsPlayingNode(npcid);
  244. native FCNPC_IsPlayingNodePaused(npcid);
  245. native FCNPC_CreateMovePath();
  246. native FCNPC_DestroyMovePath(pathid);
  247. native FCNPC_IsValidMovePath(pathid);
  248. native FCNPC_AddPointToPath(pathid, Float:x, Float:y, Float:z);
  249. native FCNPC_AddPointsToPath(pathid, Float:points[][3], const size = sizeof(points));
  250. native FCNPC_AddPointsToPath2(pathid, Float:points_x[], Float:points_y[], Float:points_z[], const size = sizeof(points_x));
  251. native FCNPC_RemovePointFromPath(pathid, pointid);
  252. native FCNPC_IsValidMovePoint(pathid, pointid);
  253. native FCNPC_GetMovePoint(pathid, pointid, &Float:x, &Float:y, &Float:z);
  254. native FCNPC_GetNumberMovePoint(pathid);
  255. native FCNPC_GoByMovePath(npcid, pathid, type = FCNPC_MOVE_TYPE_AUTO, Float:speed = FCNPC_MOVE_SPEED_AUTO, bool:UseMapAndreas = false, Float:radius = 0.0, bool:setangle = true, Float:dist_offset = 0.0);
  256. native FCNPC_ToggleMapAndreasUsage(npcid, bool:enabled);
  257. native FCNPC_IsMapAndreasUsed(npcid);
  258. native FCNPC_SetMinHeightPosCall(npcid, Float:height);
  259. native Float:FCNPC_GetMinHeightPosCall(npcid);
  260. // ALS for some callbacks
  261. public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart)
  262. {
  263. #if defined FCNPC_OnPlayerGiveDamage
  264. return FCNPC_OnPlayerGiveDamage(playerid, damagedid, amount, weaponid, bodypart);
  265. #else
  266. return 1;
  267. #endif
  268. }
  269. #if defined _ALS_OnPlayerGiveDamage
  270. #undef OnPlayerGiveDamage
  271. #else
  272. #define _ALS_OnPlayerGiveDamage
  273. #endif
  274. #define OnPlayerGiveDamage FCNPC_OnPlayerGiveDamage
  275. #if defined FCNPC_OnPlayerGiveDamage
  276. forward FCNPC_OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart);
  277. #endif
  278. public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
  279. {
  280. #if defined FCNPC_OnPlayerTakeDamage
  281. return FCNPC_OnPlayerTakeDamage(playerid, issuerid, amount, weaponid, bodypart);
  282. #else
  283. return 1;
  284. #endif
  285. }
  286. #if defined _ALS_OnPlayerTakeDamage
  287. #undef OnPlayerTakeDamage
  288. #else
  289. #define _ALS_OnPlayerTakeDamage
  290. #endif
  291. #define OnPlayerTakeDamage FCNPC_OnPlayerTakeDamage
  292. #if defined FCNPC_OnPlayerTakeDamage
  293. forward FCNPC_OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart);
  294. #endif
  295. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  296. {
  297. #if defined FCNPC_OnPlayerWeaponShot
  298. return FCNPC_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, fX, fY, fZ);
  299. #else
  300. return 1;
  301. #endif
  302. }
  303. #if defined _ALS_OnPlayerWeaponShot
  304. #undef OnPlayerWeaponShot
  305. #else
  306. #define _ALS_OnPlayerWeaponShot
  307. #endif
  308. #define OnPlayerWeaponShot FCNPC_OnPlayerWeaponShot
  309. #if defined FCNPC_OnPlayerWeaponShot
  310. forward FCNPC_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
  311. #endif
  312. public OnPlayerStreamIn(playerid, forplayerid)
  313. {
  314. #if defined FCNPC_OnPlayerStreamIn
  315. return FCNPC_OnPlayerStreamIn(playerid, forplayerid);
  316. #else
  317. return 1;
  318. #endif
  319. }
  320. #if defined _ALS_OnPlayerStreamIn
  321. #undef OnPlayerStreamIn
  322. #else
  323. #define _ALS_OnPlayerStreamIn
  324. #endif
  325. #define OnPlayerStreamIn FCNPC_OnPlayerStreamIn
  326. #if defined FCNPC_OnPlayerStreamIn
  327. forward FCNPC_OnPlayerStreamIn(playerid, forplayerid);
  328. #endif
  329. public OnPlayerStreamOut(playerid, forplayerid)
  330. {
  331. #if defined FCNPC_OnPlayerStreamOut
  332. return FCNPC_OnPlayerStreamOut(playerid, forplayerid);
  333. #else
  334. return 1;
  335. #endif
  336. }
  337. #if defined _ALS_OnPlayerStreamOut
  338. #undef OnPlayerStreamOut
  339. #else
  340. #define _ALS_OnPlayerStreamOut
  341. #endif
  342. #define OnPlayerStreamOut FCNPC_OnPlayerStreamOut
  343. #if defined FCNPC_OnPlayerStreamOut
  344. forward FCNPC_OnPlayerStreamOut(playerid, forplayerid);
  345. #endif
  346. // Update checker
  347. #if !defined HTTP
  348. #tryinclude <a_http>
  349. #endif
  350. #if !defined HTTP
  351. #tryinclude "a_http"
  352. #endif
  353. #if defined HTTP && !defined FCNPC_DISABLE_VERSION_CHECK
  354. #if defined FILTERSCRIPT
  355. public OnFilterScriptInit()
  356. {
  357. FCNPC_SendVersionRequest();
  358. #if defined fcnpc0_OnFilterScriptInit
  359. return fcnpc0_OnFilterScriptInit();
  360. #else
  361. return 1;
  362. #endif
  363. }
  364. #if defined _ALS_OnFilterScriptInit
  365. #undef OnFilterScriptInit
  366. #else
  367. #define _ALS_OnFilterScriptInit
  368. #endif
  369. #define OnFilterScriptInit fcnpc0_OnFilterScriptInit
  370. #if defined fcnpc0_OnFilterScriptInit
  371. forward fcnpc0_OnFilterScriptInit();
  372. #endif
  373. #else
  374. public OnGameModeInit()
  375. {
  376. FCNPC_SendVersionRequest();
  377. #if defined fcnpc0_OnGameModeInit
  378. return fcnpc0_OnGameModeInit();
  379. #else
  380. return 1;
  381. #endif
  382. }
  383. #if defined _ALS_OnGameModeInit
  384. #undef OnGameModeInit
  385. #else
  386. #define _ALS_OnGameModeInit
  387. #endif
  388. #define OnGameModeInit fcnpc0_OnGameModeInit
  389. #if defined fcnpc0_OnGameModeInit
  390. forward fcnpc0_OnGameModeInit();
  391. #endif
  392. #endif
  393. static stock FCNPC_SendVersionRequest()
  394. {
  395. HTTP(0, HTTP_GET, "ziggi.org/github/lastrelease.php?owner=ziggi&repo=FCNPC&elem=tag_name", "", "FCNPC_OnRequestResponse");
  396. }
  397. forward FCNPC_OnRequestResponse(index, response_code, data[]);
  398. public FCNPC_OnRequestResponse(index, response_code, data[])
  399. {
  400. if (index == 0 && response_code == 200) {
  401. new length = strlen(data);
  402. if (length == 0 || length > 10) {
  403. return;
  404. }
  405. new version[16];
  406. strmid(version, data, 1, length);
  407. if (!('0' <= version[0] <= '9')) {
  408. return;
  409. }
  410. new plugin_version[16];
  411. FCNPC_GetPluginVersion(plugin_version);
  412. if (strcmp(version, plugin_version) != 0) {
  413. printf("\n** Please update your FCNPC plugin to %s from here: https://github.com/ziggi/FCNPC/releases.\n", version);
  414. }
  415. }
  416. }
  417. #endif
  418. #if defined foreach
  419. /*
  420. Iterator
  421. */
  422. new
  423. Iterator:FCNPC<MAX_PLAYERS>;
  424. /*
  425. Init
  426. */
  427. #if defined FILTERSCRIPT
  428. /*
  429. OnFilterScriptInit
  430. */
  431. public OnFilterScriptInit()
  432. {
  433. Iter_Clear(FCNPC);
  434. for (new i = 0; i != MAX_PLAYERS; ++i) {
  435. if (FCNPC_IsValid(i)) {
  436. Iter_Add(FCNPC, i);
  437. }
  438. }
  439. #if defined fcnpc1_OnFilterScriptInit
  440. return fcnpc1_OnFilterScriptInit();
  441. #else
  442. return 1;
  443. #endif
  444. }
  445. #if defined _ALS_OnFilterScriptInit
  446. #undef OnFilterScriptInit
  447. #else
  448. #define _ALS_OnFilterScriptInit
  449. #endif
  450. #define OnFilterScriptInit fcnpc1_OnFilterScriptInit
  451. #if defined fcnpc1_OnFilterScriptInit
  452. forward fcnpc1_OnFilterScriptInit();
  453. #endif
  454. #else
  455. /*
  456. OnGameModeInit
  457. */
  458. public OnGameModeInit()
  459. {
  460. Iter_Clear(FCNPC);
  461. for (new i = 0; i != MAX_PLAYERS; ++i) {
  462. if (FCNPC_IsValid(i)) {
  463. Iter_Add(FCNPC, i);
  464. }
  465. }
  466. #if defined fcnpc1_OnGameModeInit
  467. return fcnpc1_OnGameModeInit();
  468. #else
  469. return 1;
  470. #endif
  471. }
  472. #if defined _ALS_OnGameModeInit
  473. #undef OnGameModeInit
  474. #else
  475. #define _ALS_OnGameModeInit
  476. #endif
  477. #define OnGameModeInit fcnpc1_OnGameModeInit
  478. #if defined fcnpc1_OnGameModeInit
  479. forward fcnpc1_OnGameModeInit();
  480. #endif
  481. #endif
  482. /*
  483. FCNPC_OnCreate
  484. */
  485. public FCNPC_OnCreate(npcid)
  486. {
  487. Iter_Add(FCNPC, npcid);
  488. #if defined fcnpc1_FCNPC_OnCreate
  489. return fcnpc1_FCNPC_OnCreate(npcid);
  490. #else
  491. return 1;
  492. #endif
  493. }
  494. #if defined _ALS_FCNPC_OnCreate
  495. #undef FCNPC_OnCreate
  496. #else
  497. #define _ALS_FCNPC_OnCreate
  498. #endif
  499. #define FCNPC_OnCreate fcnpc1_FCNPC_OnCreate
  500. #if defined fcnpc1_FCNPC_OnCreate
  501. forward fcnpc1_FCNPC_OnCreate(npcid);
  502. #endif
  503. /*
  504. FCNPC_OnDestroy
  505. */
  506. public FCNPC_OnDestroy(npcid)
  507. {
  508. SetTimerEx("Iter_FCNPCOnDestroyInternal", 0, false, "i", npcid);
  509. #if defined fcnpc1_FCNPC_OnDestroy
  510. return fcnpc1_FCNPC_OnDestroy(npcid);
  511. #else
  512. return 1;
  513. #endif
  514. }
  515. #if defined _ALS_FCNPC_OnDestroy
  516. #undef FCNPC_OnDestroy
  517. #else
  518. #define _ALS_FCNPC_OnDestroy
  519. #endif
  520. #define FCNPC_OnDestroy fcnpc1_FCNPC_OnDestroy
  521. #if defined fcnpc1_FCNPC_OnDestroy
  522. forward fcnpc1_FCNPC_OnDestroy(npcid);
  523. #endif
  524. /*
  525. Iter_FCNPCOnDestroyInternal
  526. */
  527. forward Iter_FCNPCOnDestroyInternal(npcid);
  528. public Iter_FCNPCOnDestroyInternal(npcid)
  529. {
  530. Iter_Remove(FCNPC, npcid);
  531. }
  532. #endif