Advertisement
Guest User

Untitled

a guest
Jul 6th, 2012
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. /*
  2. Tretminen-FS
  3. (c) 2012 by pwnfl4sh
  4. */
  5. #include <a_samp>
  6. #include <zcmd>
  7.  
  8. #define PREIS 0 // preis pro tretmine
  9.  
  10. forward BombTimer();
  11.  
  12. enum b_Info
  13. {
  14. b_Object,
  15. Float:b_Pos[3],
  16. bool:b_Active
  17. }
  18. new BombInfo[MAX_PLAYERS][b_Info];
  19.  
  20. public OnFilterScriptInit()
  21. {
  22. for(new i=0;i<MAX_PLAYERS;i++)
  23. {
  24. ResetPlayerBombStats(i);
  25. }
  26.  
  27. SetTimer("BombTimer",1000,true);
  28.  
  29. print("TretMinen-FS gestartet!");
  30. return 1;
  31. }
  32.  
  33. public OnFilterScriptExit()
  34. {
  35. print("TretMinen-FS beendet!");
  36. return 1;
  37. }
  38.  
  39. public OnPlayerConnect(playerid)
  40. {
  41. ResetPlayerBombStats(playerid);
  42. return 1;
  43. }
  44.  
  45. public OnPlayerDisconnect(playerid,reason)
  46. {
  47. ResetPlayerBombStats(playerid);
  48. return 1;
  49. }
  50.  
  51. public BombTimer()
  52. {
  53. for(new i=0;i<MAX_PLAYERS;i++)
  54. {
  55. if(IsPlayerConnected(i))
  56. {
  57. if(IsPlayerInRangeOfBomb(i) != -1)
  58. {
  59. SendClientMessage(i,0xFF0000FF,"Du bist auf eine Tretmine getreten :D");
  60. new b = IsPlayerInRangeOfBomb(i);
  61. ExplodeBomb(b);
  62. }
  63. }
  64. }
  65. return 1;
  66. }
  67.  
  68. ResetPlayerBombStats(playerid)
  69. {
  70. if(BombInfo[playerid][b_Active] == true)
  71. {
  72. DestroyObject(BombInfo[playerid][b_Object]);
  73. BombInfo[playerid][b_Active] = false;
  74. }
  75. return 1;
  76. }
  77.  
  78. ExplodeBomb(playerid)
  79. {
  80. if(BombInfo[playerid][b_Active] == false) return 0;
  81.  
  82. CreateExplosion(BombInfo[playerid][b_Pos][0],BombInfo[playerid][b_Pos][1],BombInfo[playerid][b_Pos][2],6,20.0);
  83. ResetPlayerBombStats(playerid);
  84. return 1;
  85. }
  86.  
  87. IsPlayerInRangeOfBomb(playerid,Float:range = 2.0)
  88. {
  89. for(new i=0;i<MAX_PLAYERS;i++)
  90. {
  91. if(BombInfo[i][b_Active] == true)
  92. {
  93. if(IsPlayerInRangeOfPoint(playerid,range,BombInfo[i][b_Pos][0],BombInfo[i][b_Pos][1],BombInfo[i][b_Pos][2]))
  94. {
  95. return i;
  96. }
  97. }
  98. }
  99. return -1;
  100. }
  101.  
  102. CreateBomb(playerid,Float:x,Float:y,Float:z)
  103. {
  104. BombInfo[playerid][b_Object] = CreateObject(1654,x,y,z-1.0,0.0,0.0,0.0);
  105. BombInfo[playerid][b_Pos][0] = x;
  106. BombInfo[playerid][b_Pos][1] = y;
  107. BombInfo[playerid][b_Pos][2] = z;
  108. BombInfo[playerid][b_Active] = true;
  109. return 1;
  110. }
  111.  
  112. COMMAND:terstellen(playerid,params)
  113. {
  114. if(BombInfo[playerid][b_Active] == true) return SendClientMessage(playerid,0xFF0000FF,"Deine Tretmine ist bereits aktiv, bitte warte bis sie ausgelöst wird.");
  115. if(GetPlayerMoney(playerid) < PREIS)
  116. {
  117. new str[144];
  118. format(str,144,"Du brauchst $%d!",PREIS);
  119. SendClientMessage(playerid,0xFF0000FF,str);
  120. return 1;
  121. }
  122.  
  123. GivePlayerMoney(playerid,-PREIS);
  124. new Float:Pos[3];
  125. GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
  126. CreateBomb(playerid,Pos[0],Pos[1]+2.5,Pos[2]);
  127. return 1;
  128. }
  129.  
  130. COMMAND:tentschaerfen(playerid,params[])
  131. {
  132. if(IsPlayerInRangeOfBomb(playerid,4.0) == -1) return SendClientMessage(playerid,0xFF0000FF,"Du bist nicht in der Nähe einer Tretmine!");
  133.  
  134. new b = IsPlayerInRangeOfBomb(playerid,4.0);
  135. ResetPlayerBombStats(b);
  136. SendClientMessage(playerid,0xFF0000FF,"Tretmine entschärft.");
  137. return 1;
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement