JPeedro

Untitled

Nov 2nd, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. FCNPC_SetUpdateRate(100); // Muda a taxa de atualização da callback FCNPC_OnUpdate, recomendado 100ms
  2.  
  3. public FCNPC_OnUpdate(npcid)
  4. {
  5. foreach(new i : Player)
  6. {
  7. if(!IsPlayerNPC(i) && IsPlayerConnected(i))
  8. {
  9. static Float:zP[3], Float:pP[3];
  10. GetPlayerPos(npcid, zP[0], zP[1], zP[2]);
  11. GetPlayerPos(i, pP[0], pP[1], pP[2]);
  12. if(IsPlayerInRangeOfPoint(i, 20.0, zP[0], zP[1], zP[2]))
  13. {
  14. if(GetPlayerState(i) == PLAYER_STATE_ONFOOT)
  15. {
  16. FCNPC_GoToFixZ(npcid, pP[0], pP[1], pP[2], MOVE_TYPE_RUN, 0.5, true, 0.0, true, 0.1);
  17. if(GetDistanceBetweenPlayers(npcid, i) < 1.2)
  18. {
  19. FCNPC_Stop(npcid);
  20. FCNPC_MeleeAttack(npcid, -1, true);
  21. return 1;
  22. }
  23. else FCNPC_StopAttack(npcid);
  24. }
  25. }
  26. }
  27. }
  28. return 1;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment