Advertisement
Guest User

ARNPC 0.4.1

a guest
Dec 20th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.44 KB | None | 0 0
  1. /* ARNPC Advanced Recordfree NPC - Created by TheArcher
  2. - Thanks to Mauzen, Joe Staff & Y_Less
  3. */
  4.  
  5. #include <a_samp>
  6. #include <rnpc>
  7. #if !defined _INC_y_hooks
  8. #include <YSI\y_hooks>
  9. #endif
  10.  
  11. /* Fake natives
  12.  
  13. // core
  14. native CreateRNPC(npcname[])
  15. native DestroyRNPC(npcid)
  16. native IsPlayerRNPC(npcid)
  17. native GetRNPCID(npcid)
  18. native GetRNPCState(npcid)
  19. native GetRNPCName(npcid)
  20. native SetRNPCVirtualWorld(npcid, worldid)
  21. native GetRNPCVirtualWorld(npcid)
  22.  
  23. // vehicle controls
  24. native PutRNPCInVehicle(npcid, vehicleid, seatid) // not working with 0.2.1 plugin
  25. native RemoveRNPCFromVehicle(npcid) // not working with 0.2.1 plugin
  26. native SetRNPCVehicleSiren(npcid,vstate)
  27. native GetRNPCVehicleSiren(npcid)
  28.  
  29. // on foot controls
  30. native SetRNPCSkin(npcid, skin)
  31. native SetRNPCPos(npcid, Float:x, Float:y, Float:z)
  32. native GetRNPCPos(npcid, &Float:x, &Float:y, &Float:z)
  33. native MoveRNPC(npcid, Float:x, Float:y, Float:z, Float:speed) // taken from the original rnpc include
  34. native SetRNPCFacingAngle(npcid, Float:angle)
  35. native GetRNPCHealth(npcid)
  36. native SetRNPCArmour(npcid, armour) // remember the armour value must be an integer and not working with 0.3 plugin
  37. native GetRNPCArmour(npcid)
  38. native SetRNPCWeapon(npcid, weaponid)
  39. native GetRNPCWeapon(npcid)
  40. native SetRNPCSkillLevel(npcid, skill, level)
  41.  
  42. // npc actions
  43. native RNPCWalkTo(npcid,Float:X,Float:Y,Float:Z);
  44. native RNPCRunTo(npcid,Float:X,Float:Y,Float:Z);
  45. native RNPCSprintTo(npcid,Float:X,Float:Y,Float:Z);
  46. native RNPCAimAt(npcid,Float:X,Float:Y);
  47. native RNPCShotAt(npcid,Float:X,Float:Y);
  48. native RNPCStopUseWeapon(npcid);
  49. native RNPCDriveTo(npcid,Float:X,Float:Y,Float:Z,Float:speed);
  50. native RNPCFollowPlayer(npcid, targetid, movemode = RNPC_SPEED_SPRINT)
  51.  
  52. // .rec part
  53. native RNPC_StartPlayback(npcid, rec[])
  54. native RNPC_StopPlayback(npcid)
  55. native RNPC_StartBuildPlayback(npcid, slot=0, vehicleid=0)
  56.  
  57. */
  58.  
  59. #if defined MAX_RNPC
  60. #endinput
  61. #else
  62. #define MAX_RNPC (500) // Be sure that the value is the same as "maxnpc" from server.cfg file
  63. #endif
  64.  
  65. #define RNPC_STATE_ONFOOT 1
  66. #define RNPC_STATE_DRIVER 2
  67. #define RNPC_STATE_PASSANGER 3 // bugged from the plugin
  68.  
  69. #define RNPC_FOLLOWING_TIME (300) // rememeber its ms
  70.  
  71. #define RNPC_SIREN_STATE_ON (1)
  72. #define RNPC_SIREN_STATE_OFF (0)
  73.  
  74. forward OnRNPCCreated(npcid);
  75. forward OnRNPCDestroyed(npcid);
  76. forward OnRNPCSpawn(npcid);
  77. //forward OnRNPCPlaybackFinished(npcid); // it's usable but already called so DO NOT uncomment this
  78. forward OnRNPCDeath(npcid);
  79.  
  80. //new bool:RNPC_Connected[MAX_RNPC] = false;
  81.  
  82. // Here's is sightly Mauzen's include modified, credits goes to him :)
  83. enum RNPC_enum {
  84. bool:RNPC_Connected = false,
  85. RNPC_ID,
  86. RNPC_CONNECTION,
  87. RNPC_NAME[24],
  88. RNPC_SKIN, // Since GetPlayerSkin is not detected on NPC I will do it using this variable and storing a value on it.
  89. RNPC_HEALTH,
  90. RNPC_ARMOUR,
  91. Float:RNPC_ANGLE,
  92. RNPC_WEAPONID,
  93. RNPC_SIREN_STATE
  94. };
  95.  
  96. // Initial data
  97. new rnpc_Data[MAX_RNPC][RNPC_enum];
  98.  
  99. stock CreateRNPC(name[])
  100. {
  101. new slot = -1;
  102. for (new i = 0; i < MAX_RNPC; i++) {
  103. if (!IsPlayerConnected(i) && rnpc_Data[i][RNPC_Connected] == false) {
  104. slot = i;
  105. break;
  106. }
  107. }
  108. rnpc_Data[slot][RNPC_CONNECTION] = ConnectNPC(name, "RNPC");
  109. format(rnpc_Data[slot][RNPC_NAME], 24, "%s", name);
  110. rnpc_Data[slot][RNPC_Connected] = true;
  111. rnpc_Data[slot][RNPC_ID] = slot;
  112. SetTimerEx("Fix_RNPCConnect", 1000, false, "i", slot); //
  113. return slot;
  114. }
  115.  
  116. forward Fix_RNPCConnect(slot);
  117. public Fix_RNPCConnect(slot) {
  118. CallLocalFunction("OnRNPCCreated", "i", slot); // Fixes the issue when the script detects the NPC connected before it does
  119. }
  120.  
  121. stock DestroyRNPC(npcid)
  122. {
  123. if(IsPlayerRNPC(npcid)) {
  124. RNPC_CreateBuild(npcid, PLAYER_RECORDING_TYPE_ONFOOT);
  125. RNPC_AddPause(450);
  126. RNPC_FinishBuild();
  127. RNPC_StartBuildPlayback(npcid);
  128. rnpc_Data[npcid][RNPC_HEALTH] = 0;
  129. rnpc_Data[npcid][RNPC_ARMOUR] = 0;
  130. rnpc_Data[npcid][RNPC_ANGLE] = 0.0;
  131. rnpc_Data[npcid][RNPC_WEAPONID] = 0;
  132. rnpc_Data[npcid][RNPC_SIREN_STATE] = 0;
  133. Kick(rnpc_Data[npcid][RNPC_CONNECTION]);
  134. }
  135. }
  136.  
  137.  
  138. stock GetRNPCID(npcid) return rnpc_Data[npcid][RNPC_ID];
  139.  
  140. stock GetRNPCState(npcid) {
  141. if(IsPlayerRNPC(npcid)) return GetPlayerState(npcid), \
  142. printf(" ARNPC Debug: npcid %d has the state %d", npcid, GetPlayerState(npcid));
  143. return -1;
  144. }
  145.  
  146. stock PutRNPCInVehicle(npcid, vehicleid, seatid)
  147. {
  148. if(IsPlayerRNPC(npcid))
  149. SetTimerEx("PutRNPCInVehicle_Fix", 500, 0, "iii", npcid, vehicleid, seatid);
  150. printf(" ARNPC Debug: npcid %d was put in vehicleid %d and seatid %d ", npcid, vehicleid, seatid);
  151. }
  152.  
  153. stock RemoveRNPCFromVehicle(npcid)
  154. {
  155. if(IsPlayerRNPC(npcid)) {
  156. if(IsPlayerInAnyVehicle(npcid)) {
  157. RemovePlayerFromVehicle(npcid);
  158. }
  159. }
  160. }
  161.  
  162. forward PutRNPCInVehicle_Fix(npcid, vehicleid, seatid);
  163. public PutRNPCInVehicle_Fix(npcid, vehicleid, seatid) { //Thanks to Mauzen once again :3
  164. // Make him enter the vehicle again, this fixed some problems for me
  165. // when the vehicle is far away and not streamed in for the npc
  166. PutPlayerInVehicle(npcid, vehicleid, seatid);
  167. RNPC_CreateBuild(npcid, PLAYER_RECORDING_TYPE_DRIVER);
  168. RNPC_AddPause(250);
  169. RNPC_FinishBuild();
  170. RNPC_StartBuildPlayback(npcid);
  171. }
  172.  
  173. stock SetRNPCPos(npcid, Float:x, Float:y, Float:z)
  174. {
  175. if(IsPlayerRNPC(npcid))
  176. SetPlayerPos(npcid, x,y,z);
  177. }
  178.  
  179. stock GetRNPCPos(npcid, &Float:x, &Float:y, &Float:z)
  180. {
  181. if(IsPlayerRNPC(npcid)) GetPlayerPos(npcid, x,y,z);
  182. printf(" ARNPC Debug: npcid %d has the pos %f %f %f", npcid, x,y,z);
  183. }
  184.  
  185. stock SetRNPCSkin(npcid, skin)
  186. {
  187. if(IsPlayerRNPC(npcid))
  188. {
  189. if(IsValidRNPCSkin(skin))
  190. {
  191. new temp_weapon = GetRNPCWeapon(npcid);
  192. if(IsPlayerInAnyVehicle(npcid)) {
  193. RNPC_CreateBuild(npcid, PLAYER_RECORDING_TYPE_DRIVER);
  194. SetPlayerSkin(npcid, skin);
  195. if(temp_weapon != 0) RNPC_SetWeaponID(temp_weapon);
  196. RNPC_FinishBuild();
  197. } else {
  198. RNPC_CreateBuild(npcid, PLAYER_RECORDING_TYPE_ONFOOT);
  199. SetPlayerSkin(npcid, skin);
  200. if(temp_weapon != 0) RNPC_SetWeaponID(temp_weapon);
  201. RNPC_FinishBuild();
  202. }
  203. RNPC_StartBuildPlayback(npcid);
  204. rnpc_Data[npcid][RNPC_SKIN] = skin;
  205. }
  206. }
  207. }
  208.  
  209. stock GetRNPCSkin(npcid) return rnpc_Data[npcid][RNPC_SKIN];
  210.  
  211. stock SetRNPCFacingAngle(npcid,Float:angle)
  212. {
  213. if(IsPlayerRNPC(npcid))
  214. {
  215. if(IsPlayerInAnyVehicle(npcid)) return false; // prevent unusable angle facing in vehicles
  216. RNPC_CreateBuild(npcid, PLAYER_RECORDING_TYPE_ONFOOT);
  217. RNPC_SetAngleQuats(0.0, angle, 0.0);
  218. RNPC_FinishBuild();
  219. RNPC_StartBuildPlayback(npcid);
  220. rnpc_Data[npcid][RNPC_ANGLE] = angle;
  221. printf(" ARNPC Debug: NPCID %d has set the angle %f ", npcid, angle);
  222. }
  223. return true;
  224. }
  225.  
  226. stock Float:GetNPCFacingAngle(npcid) // not working well yet
  227. {
  228. if(rnpc_Data[npcid][RNPC_Connected] == true)
  229. return rnpc_Data[npcid][RNPC_ANGLE];
  230. //printf(" ARNPC Debug: NPCID %d has set the angle %f ", npcid, GetNPCFacingAngle(npcid));
  231. return 0.0;
  232. }
  233.  
  234.  
  235. // Took from a pastebin link (Idk who's original author :/ )
  236. stock IsValidRNPCSkin(skinid)
  237. {
  238. #define MAX_BAD_SKINS 22
  239. new badSkins[MAX_BAD_SKINS] =
  240. {
  241. 3, 4, 5, 6, 8, 42, 65, 74, 86,
  242. 119, 149, 208, 265, 266, 267,
  243. 268, 269, 270, 271, 272, 273, 289
  244. };
  245. if (skinid < 0 || skinid > 299) return false;
  246. for (new i = 0; i < MAX_BAD_SKINS; i++)
  247. {
  248. if (skinid == badSkins[i]) return false;
  249. }
  250. #undef MAX_BAD_SKINS
  251. return 1;
  252. }
  253.  
  254. stock GetRNPCName(npcid) // Thanks to Lorenc_
  255. {
  256. static p_Name[24] = "Invalid_NPC_ID";
  257. format(p_Name, 24, "%s", rnpc_Data[npcid][RNPC_NAME]);
  258. return p_Name;
  259. }
  260.  
  261. stock SetRNPCVirtualWorld(npcid, worldid) if(IsPlayerRNPC(npcid)) SetPlayerVirtualWorld(npcid, worldid);
  262. stock GetRNPCVirtualWorld(npcid) {
  263. if(IsPlayerRNPC(npcid)) return GetPlayerVirtualWorld(npcid);
  264. return -1;
  265. }
  266.  
  267. /*stock GetRNPCSurfingVehicle(npcid) // I just tried something but lol not working.
  268. {
  269. if(IsPlayerRNPC(npcid)) return GetPlayerSurfingVehicleID(npcid);
  270. return INVALID_PLAYER_ID;
  271. }*/
  272.  
  273.  
  274. stock SetRNPCArmour(npcid, armour) // Float is not support yet by rnpc plugin native yet
  275. {
  276. if(IsPlayerRNPC(npcid))
  277. {
  278. RNPC_StopPlayback(npcid);
  279. new State = GetRNPCState(npcid);
  280. if(State == RNPC_STATE_ONFOOT)
  281. {
  282. RNPC_CreateBuild(npcid, PLAYER_RECORDING_TYPE_ONFOOT);
  283. RNPC_SetArmour(armour);
  284. RNPC_FinishBuild();
  285. }
  286. else
  287. if(State == RNPC_STATE_DRIVER || RNPC_STATE_PASSANGER)
  288. {
  289. RNPC_CreateBuild(npcid, PLAYER_RECORDING_TYPE_DRIVER);
  290. RNPC_SetArmour(armour);
  291. RNPC_FinishBuild();
  292. }
  293. rnpc_Data[npcid][RNPC_ARMOUR] = armour;
  294. RNPC_StartBuildPlayback(npcid);
  295. }
  296. }
  297.  
  298. stock GetRNPCArmour(npcid) return rnpc_Data[npcid][RNPC_ARMOUR];
  299.  
  300. stock SetRNPCWeapon(npcid, weaponid)
  301. {
  302. if(IsPlayerRNPC(npcid))
  303. {
  304. RNPC_CreateBuild(npcid, PLAYER_RECORDING_TYPE_ONFOOT);
  305. RNPC_SetWeaponID(weaponid);
  306. RNPC_FinishBuild();
  307. RNPC_StartBuildPlayback(npcid);
  308. rnpc_Data[npcid][RNPC_WEAPONID] = weaponid;
  309. }
  310. }
  311.  
  312. stock GetRNPCWeapon(npcid) return rnpc_Data[npcid][RNPC_WEAPONID];
  313.  
  314. stock RNPCWalkTo(npcid,Float:X,Float:Y,Float:Z)
  315. {
  316. if(IsPlayerRNPC(npcid))
  317. {
  318. new Float:SPos[3];
  319. GetPlayerPos(npcid, SPos[0], SPos[1], SPos[2]);
  320. RNPC_CreateBuild(npcid, PLAYER_RECORDING_TYPE_ONFOOT);
  321. if(GetRNPCWeapon(npcid) != 0) RNPC_SetWeaponID(GetRNPCWeapon(npcid));
  322. RNPC_AddMovement(SPos[0], SPos[1], SPos[2], X, Y, Z, RNPC_SPEED_WALK);
  323. RNPC_FinishBuild();
  324. RNPC_StartBuildPlayback(npcid);
  325. }
  326. }
  327.  
  328. stock RNPCRunTo(npcid,Float:X,Float:Y,Float:Z)
  329. {
  330. if(IsPlayerRNPC(npcid))
  331. {
  332. new Float:SPos[3];
  333. GetPlayerPos(npcid, SPos[0], SPos[1], SPos[2]);
  334. RNPC_CreateBuild(npcid, PLAYER_RECORDING_TYPE_ONFOOT);
  335. if(GetRNPCWeapon(npcid) != 0) RNPC_SetWeaponID(GetRNPCWeapon(npcid));
  336. RNPC_AddMovement(SPos[0], SPos[1], SPos[2], X, Y, Z, RNPC_SPEED_RUN);
  337. RNPC_FinishBuild();
  338. RNPC_StartBuildPlayback(npcid);
  339. }
  340. }
  341.  
  342. stock RNPCSprintTo(npcid,Float:X,Float:Y,Float:Z)
  343. {
  344. if(IsPlayerRNPC(npcid))
  345. {
  346. new Float:SPos[3];
  347. GetPlayerPos(npcid, SPos[0], SPos[1], SPos[2]);
  348. RNPC_CreateBuild(npcid, PLAYER_RECORDING_TYPE_ONFOOT);
  349. if(GetRNPCWeapon(npcid) != 0) RNPC_SetWeaponID(GetRNPCWeapon(npcid));
  350. RNPC_AddMovement(SPos[0], SPos[1], SPos[2], X, Y, Z, RNPC_SPEED_SPRINT);
  351. RNPC_FinishBuild();
  352. RNPC_StartBuildPlayback(npcid);
  353. }
  354. }
  355.  
  356. stock RNPCFollowPlayer(npcid, targetid, Float:movemode = RNPC_SPEED_SPRINT)
  357. {
  358. if(IsPlayerRNPC(npcid)) SetTimerEx("FollowPlayer", RNPC_FOLLOWING_TIME, true, "iif", npcid, targetid, movemode);
  359. }
  360.  
  361. forward FollowPlayer(npcid, targetid, Float:movemode);
  362. public FollowPlayer(npcid, targetid, Float:movemode)
  363. {
  364. static Float:x, Float:y, Float:z;
  365. GetPlayerPos(targetid, x, y, z);
  366. switch(movemode)
  367. {
  368. case RNPC_SPEED_SPRINT: MoveRNPC(npcid, x, y, z, RNPC_SPEED_SPRINT);
  369. case RNPC_SPEED_RUN: MoveRNPC(npcid, x, y, z, RNPC_SPEED_RUN);
  370. case RNPC_SPEED_WALK: MoveRNPC(npcid, x, y, z, RNPC_SPEED_WALK);
  371. }
  372. }
  373.  
  374. stock SetRNPCSkillLevel(npcid, skill, level)
  375. {
  376. if(IsPlayerRNPC(npcid))
  377. SetPlayerSkillLevel(npcid, skill, level);
  378. }
  379.  
  380. stock SetRNPCVehicleSiren(npcid,vstate)
  381. {
  382. if(IsPlayerRNPC(npcid))
  383. {
  384. RNPC_CreateBuild(npcid, PLAYER_RECORDING_TYPE_DRIVER);
  385. switch(vstate) {
  386. case RNPC_SIREN_STATE_OFF: RNPC_SetSirenState(RNPC_SIREN_STATE_OFF), rnpc_Data[npcid][RNPC_SIREN_STATE] = 0;
  387. case RNPC_SIREN_STATE_ON: RNPC_SetSirenState(RNPC_SIREN_STATE_ON), rnpc_Data[npcid][RNPC_SIREN_STATE] = 1;
  388. }
  389. RNPC_FinishBuild();
  390. RNPC_StartBuildPlayback(npcid);
  391. }
  392. }
  393.  
  394. stock GetRNPCVehicleSiren(npcid) return rnpc_Data[npcid][RNPC_SIREN_STATE];
  395.  
  396. stock RNPCShotAt(npcid, Float:x, Float:y)
  397. {
  398. if(IsPlayerRNPC(npcid))
  399. {
  400. if(GetRNPCWeapon(npcid) != 0) {
  401. new Float:ox, Float:oy, Float:oz;
  402. GetPlayerPos(npcid, ox, oy, oz);
  403. new Float:angle = atan2(ox - x, oy - y) + randomEx(175, 180);
  404. RNPC_CreateBuild(npcid, PLAYER_RECORDING_TYPE_ONFOOT);
  405. RNPC_SetWeaponID(GetRNPCWeapon(npcid));
  406. RNPC_SetAngleQuats(0.0, angle, 0.0);
  407. RNPC_SetKeys(KEY_FIRE);
  408. RNPC_FinishBuild();
  409. RNPC_StartBuildPlayback(npcid);
  410. }
  411. }
  412. }
  413.  
  414. stock RNPCAimAt(npcid, Float:x, Float:y)
  415. {
  416. if(IsPlayerRNPC(npcid))
  417. {
  418. if(GetRNPCWeapon(npcid) != 0) {
  419. new Float:ox, Float:oy, Float:oz;
  420. GetPlayerPos(npcid, ox, oy, oz);
  421. new Float:angle = atan2(ox - x, oy - y) + 177.0;
  422. RNPC_CreateBuild(npcid, PLAYER_RECORDING_TYPE_ONFOOT);
  423. RNPC_SetWeaponID(GetRNPCWeapon(npcid));
  424. RNPC_SetAngleQuats(0.0, angle, 0.0);
  425. RNPC_SetKeys(128);
  426. RNPC_FinishBuild();
  427. RNPC_StartBuildPlayback(npcid);
  428. }
  429. }
  430. }
  431.  
  432. stock RNPCStopUseWeapon(npcid)
  433. {
  434. if(IsPlayerRNPC(npcid))
  435. {
  436. RNPC_CreateBuild(npcid, PLAYER_RECORDING_TYPE_ONFOOT);
  437. RNPC_SetWeaponID(GetRNPCWeapon(npcid));
  438. RNPC_SetKeys(0);
  439. RNPC_FinishBuild();
  440. RNPC_StartBuildPlayback(npcid);
  441. }
  442. }
  443.  
  444. // extra functions
  445.  
  446. // Thanks Y_Less :)
  447. stock randomEx(min, max)
  448. {
  449. new rand = random(max-min)+min;
  450. return rand;
  451. }
  452.  
  453. //took SuperViper version
  454. stock Float: GetDistanceBetweenRNPC(p1, p2)
  455. {
  456. new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
  457. GetPlayerPos(p1,x1,y1,z1);
  458. GetPlayerPos(p2,x2,y2,z2);
  459. return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
  460. }
  461.  
  462. // sightly modify version of JernejL
  463. stock Float:DistanceCameraTargetToLocation(Float:CamX, Float:CamY, Float:CamZ, Float:ObjX, Float:ObjY, Float:ObjZ, Float:FrX, Float:FrY, Float:FrZ)
  464. {
  465.  
  466. new Float:TGTDistance;
  467.  
  468. // get distance from camera to target
  469. TGTDistance = sqrt((CamX - ObjX) * (CamX - ObjX) + (CamY - ObjY) * (CamY - ObjY) + (CamZ - ObjZ) * (CamZ - ObjZ));
  470.  
  471. new Float:tmpX, Float:tmpY, Float:tmpZ;
  472.  
  473. tmpX = FrX * TGTDistance + CamX;
  474. tmpY = FrY * TGTDistance + CamY;
  475. tmpZ = FrZ * TGTDistance + CamZ;
  476.  
  477. return sqrt((tmpX - ObjX) * (tmpX - ObjX) + (tmpY - ObjY) * (tmpY - ObjY) + (tmpZ - ObjZ) * (tmpZ - ObjZ));
  478. }
  479.  
  480. //Hooking part
  481.  
  482. forward OnPlayerConnect_Fix(playerid);
  483. public OnPlayerConnect_Fix(playerid)
  484. {
  485. RNPC_CreateBuild(playerid, PLAYER_RECORDING_TYPE_ONFOOT);
  486. RNPC_SetHealth(100);
  487. RNPC_SetArmour(100);
  488. RNPC_SetAngleQuats(0.0, 90.0, 0.0);
  489. RNPC_FinishBuild();
  490. RNPC_StartBuildPlayback(playerid);
  491. rnpc_Data[playerid][RNPC_HEALTH] = 100;
  492. rnpc_Data[playerid][RNPC_ARMOUR] = 100;
  493. rnpc_Data[playerid][RNPC_ANGLE] = 90.0;
  494. rnpc_Data[playerid][RNPC_WEAPONID] = 0;
  495. rnpc_Data[playerid][RNPC_SIREN_STATE] = 0;
  496. }
  497.  
  498. //Fix the bug if the NPC is going to disconnect somehow
  499. hook: public OnPlayerConnect(playerid)
  500. {
  501. if(IsPlayerRNPC(playerid)) {
  502. SetTimerEx("OnPlayerConnect_Fix", 500, 0, "i", playerid);
  503. printf(" OnPlayerConnect hook has called ");
  504. }
  505. return 1;
  506. }
  507.  
  508. hook: public OnPlayerDisconnect(playerid, reason)
  509. {
  510. if(IsPlayerRNPC(playerid))
  511. {
  512. rnpc_Data[playerid][RNPC_Connected] = false;
  513. rnpc_Data[playerid][RNPC_HEALTH] = 0;
  514. rnpc_Data[playerid][RNPC_ARMOUR] = 0;
  515. rnpc_Data[playerid][RNPC_ANGLE] = 0.0;
  516. rnpc_Data[playerid][RNPC_WEAPONID] = 0;
  517. CallLocalFunction("OnRNPCDestroyed", "i", playerid);
  518. }
  519. print(" ARNPC Debug: OnPlayerDisconnect hook called for NPC");
  520. }
  521.  
  522. hook: public OnPlayerSpawn(playerid)
  523. {
  524. if(IsPlayerRNPC(playerid)) {
  525. CallLocalFunction("OnRNPCSpawn", "i", playerid);
  526. print(" ARNPC Debug: OnPlayerSpawn hook called");
  527. }
  528. }
  529.  
  530. // Not fully tested yet.
  531. /*hook: public OnRconCommand(cmd[])
  532. {
  533. if(strfind(cmd,"gmx",true) != -1)
  534. {
  535. for(new i = 0; i < MAX_RNPC; i++)
  536. {
  537. if(!IsPlayerRNPC(i)) continue;
  538. DestroyRNPC(i);
  539. }
  540. }
  541. return 0;
  542. }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement