Advertisement
Guest User

Untitled

a guest
Jul 17th, 2012
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.04 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. // Credits:
  3. // Script erstellt von Stas
  4. // Offizieller Scripter der Xtreme - RolePlay - Community
  5. // www.xtreme-roleplay.eu
  6. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  7. // Einstellungen
  8. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. #define MAX_BLITZER 15 // Maximale Anzahl von Blitzern
  10. #define BLITZER_TIMER_INTERVALL 500 // Intervall für das Blitzen (in Milliesekunden)
  11. #define BLITZER_PAUSE 2 // Anzahl der Minuten, in denen der Spieler nicht mehr geblitzt werden kann
  12. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  13. // globale Variablen
  14. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  15. enum eBlitzer {
  16. ID, Float:BlitzerX, Float:BlitzerY, Float:BlitzerZ, Radius, Geschwindigkeit, Erstellt
  17. };
  18. new Blitzer[MAX_BLITZER][eBlitzer];
  19. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  20. // CallBacks
  21. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  22. forward Blitzer_Timer();
  23. public Blitzer_Timer() {
  24. new save, strafe, speed;
  25. for (new playerid = 0; playerid < MAX_PLAYERS; playerid++) {
  26. save = GetPVarInt(playerid, "BlitzPause");
  27. if(save > 0) {
  28. save--;
  29. SetPVarInt(playerid, "BlitzPause", save);
  30. continue;
  31. }
  32. if(!IsPlayerInAnyVehicle(playerid) || IsPlayerNPC(playerid)) continue;
  33. for(new i = 0; i < sizeof(Blitzer); i++) {
  34. if(Blitzer[i][Erstellt] == 1) {
  35. if(IsPlayerInRangeOfPoint(playerid, Blitzer[i][Radius], Blitzer[i][BlitzerX], Blitzer[i][BlitzerY], Blitzer[i][BlitzerZ])) {
  36. speed = ErmittleGeschwindigkeit(playerid,true);
  37. if(speed > Blitzer[i][Geschwindigkeit]) {
  38. new string[128];
  39. // Einstellen des Momentes, in dem der Spieler kein weiteres mal geblitzt werden kann
  40. SetPVarInt(playerid, "BlitzPause", (BLITZER_TIMER_INTERVALL * BLITZER_PAUSE * 60) / 1000);
  41. // Strafe für Spieler
  42. strafe = (speed*2) - Blitzer[i][Geschwindigkeit];
  43. PlayerPlaySound(playerid, 1132, 0.0, 0.0, 0.0);
  44. GivePlayerMoney(playerid, -strafe);
  45. // Text für Spieler
  46. SendClientMessage(playerid, 0xFF6347AA,"Du wurdest wegen zu hoher Geschwindigkeit geblitzt!");
  47. format(string,sizeof(string), "Du bist %d km/h gefahren und musst $%d Bußgeld bezahlen.", speed, strafe);
  48. SendClientMessage(playerid, 0xFF6347AA, string);
  49. }
  50. }
  51. }
  52. }
  53. }
  54. return 1;
  55. }
  56. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  57. // Funktionen
  58. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  59. stock AddBlitzer(playerid,speed,radius) {
  60. new Float:x, Float:y, Float:z;
  61. GetPlayerPos(playerid,x,y,z);
  62. for(new i = 0; i < sizeof(Blitzer); i++) {
  63. if(Blitzer[i][Erstellt] == 0) {
  64. Blitzer[i][BlitzerX] = x + 1.0;
  65. Blitzer[i][BlitzerY] = y + 1.0;
  66. Blitzer[i][BlitzerZ] = z;
  67. Blitzer[i][Geschwindigkeit] = speed;
  68. Blitzer[i][Radius] = radius;
  69. Blitzer[i][Erstellt] = 1;
  70. Blitzer[i][ID] = CreateObject(1278, x + 1.0, y + 1.0, z, 0.0, 0.0, 10);
  71. return 1;
  72. }
  73. }
  74. return 0;
  75. }
  76. stock RemoveBlitzer(playerid) {
  77. for(new i = 0; i < sizeof(Blitzer); i++) {
  78. if(Blitzer[i][Erstellt] == 1) {
  79. if(IsPlayerInRangeOfPoint(playerid, Blitzer[i][eRadius], Blitzer[i][BlitzerX], Blitzer[i][BlitzerY], Blitzer[i][BlitzerZ])) {
  80. Blitzer[i][Erstellt] = 0;
  81. Blitzer[i][BlitzerX] = 0.0;
  82. Blitzer[i][BlitzerY] = 0.0;
  83. Blitzer[i][BlitzerZ] = 0.0;
  84. DestroyObject(Blitzer[i][ID]);
  85. return 1;
  86. }
  87. }
  88. }
  89. return 0;
  90. }
  91. stock RemoveAllBlitzer() {
  92. for(new i = 0; i < sizeof(Blitzer); i++) {
  93. if(Blitzer[i][Erstellt] == 1) {
  94. Blitzer[i][Erstellt] = 0;
  95. Blitzer[i][BlitzerX] = 0.0;
  96. Blitzer[i][BlitzerY] = 0.0;
  97. Blitzer[i][BlitzerZ] = 0.0;
  98. DestroyObject(Blitzer[i][ID]);
  99. }
  100. }
  101. return 0;
  102. }
  103. stock CountBlitzer() {
  104. new anzahl = 0;
  105. for(new i = 0; i < sizeof(Blitzer); i++) {
  106. if(Blitzer[i][Erstellt] == 1) anzahl++;
  107. }
  108. return anzahl;
  109. }
  110. stock ErmittleGeschwindigkeit(playerid,bool:kmh) {
  111. new Float:x,Float:y,Float:z,Float:rtn;
  112. if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z); else GetPlayerVelocity(playerid,x,y,z);
  113. rtn = floatsqroot(x*x+y*y+z*z);
  114. return kmh?floatround(rtn * 100 * 1.61):floatround(rtn * 100);
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement