Advertisement
Guest User

Weihnachtsbaum (c) by Kaliber

a guest
Nov 28th, 2014
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.46 KB | None | 0 0
  1. /* SA-MP Include Weihnachtsbaum
  2.  *
  3.  * (c) by Kaliber, 2014
  4.  *
  5.  */
  6. #if !defined _samp_included
  7.     #include <a_samp>
  8. #endif
  9. #if defined _samp_christmas_tree
  10.     #endinput
  11. #endif
  12. #define _samp_christmas_tree
  13. #if !defined MAX_TREES
  14.     #define MAX_TREES 100
  15. #endif
  16. static tree[MAX_TREES];
  17.  
  18. stock AddBaum(playerid)
  19. {
  20.     new Float:pos[3],idx = _GetIndex();
  21.     if(idx == -1) return printf("* Fehler: Es wurden schon %d Weihnachtsbäume erstellt!",MAX_TREES);
  22.     GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
  23.     #if !defined STREAMER_OBJECT_TYPE_DYNMAIC
  24.         tree[idx] = CreateObject(19076,pos[0],pos[1],pos[2]-1.5,0.0,0.0,0.0);
  25.     #else
  26.         tree[idx] = CreateDynamicObject(19076,pos[0],pos[1],pos[2]-1.5,0.0,0.0,0.0,300.0);
  27.     #endif
  28.     return idx;
  29. }
  30.  
  31. stock RemoveBaum(index)
  32. {
  33.     if(index >= MAX_TREES || index < 0) return print("* Fehler: Index out of Bounds!");
  34.     #if !defined STREAMER_OBJECT_TYPE_DYNMAIC
  35.         DestroyObject(tree[index]);
  36.     #else
  37.         DestroyDynamicObject(tree[index]);
  38.     #endif
  39.     return tree[index] = 0;
  40. }
  41.  
  42. stock RemoveAllBaum()
  43. {
  44.     for(new i; i<MAX_TREES; i++)
  45.     {
  46.         if(!tree[i]) continue;
  47.         #if !defined STREAMER_OBJECT_TYPE_DYNMAIC
  48.             DestroyObject(tree[i]);
  49.         #else
  50.             DestroyDynamicObject(tree[i]);
  51.         #endif
  52.         tree[i] = 0;
  53.     }
  54.     return 1;
  55. }
  56.  
  57. stock _GetIndex()
  58. {
  59.     for(new i; i<MAX_TREES; i++) if(!tree[i]) return i;
  60.     return -1;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement