Jump to content

[INC]NPC public


Quiter

Recommended Posts

NPC Inc

 

Tak vytvoril som jednoduchý ale účinný includ.

Includ zisťuje či hráč zaútočil na NPC.

Ďalej zisťuje či hráč miery na NPC alebo na hráča.

 

Inštalácia :

Do zložky Pawno/Include si vložte

 

#include

#define PRESKEY(%0) \

(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

forward U1234();

forward OnNPCTakeDamage(npcid,playerid,weaponid);

forward OnPlayerTargetNPC(playerid,npcid);

forward OnPlayerTargetPlayer(playerid,targetplayer);

forward OnNPCInit();

 

public OnNPCInit()

{

SetTimer("U1234",100,true);

}

public U1234()

{

for(new ID=0;ID

{

if(IsPlayerConnected(ID))

{

new NPC = GetPlayerTargetPlayer(ID);

if(NPC != INVALID_PLAYER_ID)

{

if(IsPlayerNPC(NPC))

{

OnPlayerTargetNPC(ID,NPC);

new newkeys,lr,ud,oldkeys;GetPlayerKeys(ID,newkeys,ud,lr);

if(PRESKEY(KEY_FIRE))

{

OnNPCTakeDamage(NPC,ID,GetPlayerWeapon(ID));

}

}else{

OnPlayerTargetPlayer(ID,NPC);

}

}

}

}

}

 

Otvorte si pozn. blok skopírujte doň a uložte ako NpcInc.inc

 

Hore do módu : #include // Odporúčam nad to nadefinovať MAX_PLAYERS !!

Do publicu OnGameModeInit() / OnFilterScriptInit() si vložte OnNPCInit();

A niekde do módu si pridajte toto :

 

public OnPlayerTargetPlayer(playerid,targetplayer)

{

// Ak hráč miery na hráča

return true;

}

public OnPlayerTargetNPC(playerid,npcid)

{

// Ak hráč miery na NPC

return true;

}

public OnNPCTakeDamage(npcid,playerid,weaponid)

{

// Ono to vlastne nespôsobi DMG ale zistí či vystrelil na NPC

// A hráč musí mieriť aby sa spustil tento public !!

// Ak by niekto chcel tak môžem dorobiť DMG ale musel by mi pomôcť ( musel by som zistiť DMG všetkých zbraní )

return true;

}

 

Dúfam že sa vám to bude hodiť

:v:

Link to comment
Share on other sites

  • 5 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...