Include exobjects - Lisafunktsioonid objektide jaoks.
#1
Include sisaldab endas kahte objektide haldamiseks seotud funktsiooni ning sai loodud 2013. aasta 11. detsembril ALS hookimise, include guardide jms testimiseks.

Funktsioonid:
    PAWN Programming
  1. CountObjects();
  2. DestroyAllObjects();



Näide kasutusest:
    PAWN Programming
  1. #include <a_samp>
  2. #include <exobjects>
  3.  
  4. main() {}
  5.  
  6. {
  7. for (new i; i < 5; i++)
  8. {
  9. CreateObject(1215, 0, 0, 0, 0, 0, 0);
  10. printf("%i", CountObjects());
  11. }
  12. DestroyAllObjects();
  13. printf("%i", CountObjects());
  14. return 1;
  15. }



Kood:
    PAWN Programming
  1. /*
  2.   exobjects - Extended object functions.
  3.   kvann 2013, no rights reserved at all.
  4. */
  5.  
  6. #include <a_samp>
  7.  
  8. #if defined _exobjects_included
  9. #endinput
  10. #endif
  11. #define _exobjects_included
  12.  
  13. /*
  14.   native CountObjects();
  15.   native DestroyAllObjects();
  16. */
  17.  
  18. new exobj_biggestid = -1;
  19. new exobj_count;
  20.  
  21. stock exobj_CreateObject(modelid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ, Float<img src="http://sa-mp.staatus.eu/images/smilies/biggrin.gif" alt="Big Grin" title="Big Grin" class="smilie smilie_4" />rawDistance = 0.0)
  22. {
  23. new id = CreateObject(modelid, X, Y, Z, rX, rY, rZ, DrawDistance);
  24. if (id > exobj_biggestid) exobj_biggestid = id;
  25. exobj_count++;
  26. return id;
  27. }
  28.  
  29. #if defined _ALS_CreateObject
  30. #undef CreateObject
  31. #else
  32. #define _ALS_CreateObject
  33. #endif
  34. #define CreateObject exobj_CreateObject
  35.  
  36. stock exobj_DestroyObject(objectid)
  37. {
  38. DestroyObject(objectid);
  39. exobj_count--;
  40. return 1;
  41. }
  42.  
  43. #if defined _ALS_DestroyObject
  44. #undef DestroyObject
  45. #else
  46. #define _ALS_DestroyObject
  47. #endif
  48. #define DestroyObject exobj_DestroyObject
  49.  
  50. stock DestroyAllObjects()
  51. {
  52. if (exobj_biggestid != -1) for (new i; i < exobj_biggestid; i++) if (IsValidObject(i)) DestroyObject(i);
  53. exobj_biggestid = -1;
  54. exobj_count = 0;
  55. return 1;
  56. }
  57.  
  58. stock CountObjects() return exobj_count;

Reply
#2
Täiendatud tekst: http://kvann.im-rp.eu/script.php?id=3
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)