Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* @ RNPC Extended Functions - (EF_RNPC).
- - Fake-natives.
- native RNPC_ConnectGroup(array[][], itter);
- native RNPC_Kick(npcid);
- native RNPC_IsDeath(npcid);
- native SetHealth_RNPC(npcid, Float:Health);
- native GetHealth_RNPC(npcid);
- native RNPC_StopMove(npcid);
- */
- #include <YSI\y_hooks>
- #if defined RNPC_FOLLOWING_TIME
- #error RNPC Fixes not will work with A_RNPC incorporated
- #endif
- #define MAX_RNPC 5
- enum RNPC_Enum
- {
- Float:HealthRNPC,
- bool:IsDeathRNPC,
- TimeRespawnRNPC,
- };
- new RNPC_Info[MAX_RNPC][RNPC_Enum];
- #define RNPC_IsDeath(%1) RNPC_Info[%1][IsDeathRNPC]
- #define SetHealth_RNPC(%1,%2) RNPC_Info[%1][HealthRNPC] = %2; if(%2 <= 0) RNPC_Info[%1][HealthRNPC] = 0.00000, CallLocalFunction("RNPC_OnDeath", "ddi", 0xFFFF, %1, 53)
- #define GetHealth_RNPC(%1) RNPC_Info[%1][HealthRNPC]
- #define RNPC_Sleep@() for(new i@ = 0; i@ <= 1500; i@++) { new File:INI = fopen("asd", io_write); fclose(INI); }
- public OnPlayerConnect(playerid)
- {
- if(IsPlayerRNPC(playerid)) return RespawnRNPC(playerid);
- return 1;
- }
- hook OnPlayerSpawn(playerid)
- {
- if(IsPlayerRNPC(playerid)) ApplyAnimation(playerid, "PED", "FLOOR_hit_f", 4.0, 0, 1, 1, 1, 1), ClearAnimations(playerid);
- else GivePlayerWeapon(playerid, 31, 50000);
- SetPlayerPos(playerid, random(10), random(10), 3.0);
- return 1;
- }
- hook OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart)
- {
- if(IsPlayerRNPC(damagedid))
- {
- if(RNPC_IsDeath(damagedid)) return ApplyAnimation(damagedid, "PED", "FLOOR_hit_f", 4.0, 0, 1, 1, 1, 1);
- if((GetHealth_RNPC(damagedid)-amount) > 0.00001)
- {
- SetHealth_RNPC(damagedid, GetHealth_RNPC(damagedid)-amount);
- CallLocalFunction("RNPC_OnGiveDamage", "ddfii", damagedid, playerid, amount, weaponid, bodypart);
- }
- else
- {
- SetHealth_RNPC(damagedid, 0.0);
- RNPC_Info[damagedid][IsDeathRNPC] = true;
- RNPC_Info[damagedid][TimeRespawnRNPC] = SetTimerEx("RespawnRNPC", 4000, false, "d", damagedid);
- RNPC_StopMove(damagedid);
- ApplyAnimation(damagedid, "PED", "FLOOR_hit_f", 4.0, 0, 1, 1, 1, 1);
- }
- }
- return 1;
- }
- forward RespawnRNPC(npcid);
- public RespawnRNPC(npcid)
- {
- SpawnPlayer(npcid);
- RNPC_Info[npcid][IsDeathRNPC] = false;
- SetHealth_RNPC(npcid, 100.0);
- return 1;
- }
- stock RNPC_ConnectGroup(array[][], itter)
- {
- for(new i = 0; i < itter; i++)
- {
- ConnectRNPC(array[i]);
- RNPC_Sleep@()
- }
- }
- stock RNPC_Kick(npcid)
- {
- if(IsPlayerRNPC(npcid)) SetTimerEx("RNPC_OnDisconnect", 500, false, "d", npcid);
- Kick(npcid);
- }
- stock RNPC_StopMove(npcid)
- {
- if(IsPlayerRNPC(npcid))
- {
- new Float:Pos[3];
- GetPlayerPos(npcid, Pos[0], Pos[1], Pos[2]);
- RNPC_CreateBuild(npcid, PLAYER_RECORDING_TYPE_ONFOOT);
- RNPC_AddMovement(Pos[0], Pos[1], Pos[2], Pos[0], Pos[1], Pos[2]);
- RNPC_FinishBuild();
- RNPC_StartBuildPlayback(npcid);
- }
- }
- #if defined _ALS_Kick
- #undef Kick
- #else
- #define _ALS_Kick
- #endif
- #define Kick RNPC_Kick
- forward RNPC_OnGiveDamage(npcid, playerid, Float:amount, weaponid, bodypart);
- forward RNPC_OnDeath(npcid, playerid, weaponid);
- forward RNPC_OnDisconnect(npcid);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement