1
0

dmap.inc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * DMap 0.4
  3. * (c) Copyright 2008 by DracoBlue
  4. *
  5. * @author : DracoBlue (http://dracoblue.com)
  6. * @date : 26th Aug 2008
  7. * @update : 31st Jan 2009
  8. * @requires djson 1.5.2
  9. *
  10. * This file is provided as is (no warranties).
  11. *
  12. * Feel free to use it, a little message in
  13. * about box is honouring thing, isn't it?
  14. *
  15. */
  16. #include <djson>
  17. forward dmap_TIMER();
  18. new dmap_saved[MAX_PLAYERS];
  19. public dmap_TIMER() {
  20. new Float:tmp_float;
  21. new Float:tmp_floatx,Float:tmp_floaty;
  22. new tmp[255];
  23. new tmp2[255];
  24. djAutocommit(false);
  25. for (new i=0;i<MAX_PLAYERS;i++) {
  26. if (IsPlayerConnected(i)) {
  27. if (!dmap_saved[i]) {
  28. dmap_saved[i] = true;
  29. format(tmp,255,"items/p%d/id",i);
  30. djSetInt("dmap_feed.json",tmp,i);
  31. GetPlayerName(i,tmp2,255);
  32. format(tmp,255,"items/p%d/name",i);
  33. djSet("dmap_feed.json",tmp,tmp2);
  34. format(tmp,255,"items/p%d/icon",i);
  35. djSet("dmap_feed.json",tmp,"58");
  36. }
  37. GetPlayerHealth(i,tmp_float);
  38. format(tmp2,255,"Health: %d",floatround(tmp_float));
  39. format(tmp,255,"items/p%d/text",i);
  40. djSet("dmap_feed.json",tmp,tmp2);
  41. GetPlayerPos(i,tmp_floatx,tmp_floaty,tmp_float);
  42. format(tmp,255,"items/p%d/pos/x",i);
  43. djSetInt("dmap_feed.json",tmp,floatround(tmp_floatx));
  44. format(tmp,255,"items/p%d/pos/y",i);
  45. djSetInt("dmap_feed.json",tmp,floatround(tmp_floaty));
  46. } else if (dmap_saved[i]) {
  47. // saved, but not connected, remove him!
  48. format(tmp,255,"items/p%d",i);
  49. djUnset("dmap_feed.json",tmp);
  50. dmap_saved[i] = false;
  51. }
  52. }
  53. djCommit("dmap_feed.json");
  54. djAutocommit(true);
  55. }
  56. dmap_GameModeExit() {
  57. djson_GameModeExit();
  58. }
  59. dmap_GameModeInit() {
  60. printf(" <dmap> DMap 0.3 // (c) 2008 DracoBlue // http://www.dracoblue.net");
  61. printf(" <dmap> Loading ...");
  62. djson_GameModeInit();
  63. djCreateFile("dmap_feed.json");
  64. SetTimer("dmap_TIMER",5000,1);
  65. printf(" <dmap> .. done!");
  66. }