Advertisement
Guest User

Untitled

a guest
Feb 15th, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.13 KB | None | 0 0
  1. #include <a_samp>
  2. //#include <Dini> wird nicht mehr gebraucht
  3.  
  4. #define MAX_BLITZER 50 //<--- Maximale Anzahl an Blitzer | Kann geändert werden.
  5. #define DIALOG_BLITZER 0 //<--- ACHTUNG: Die Dialogid muss je nach Gamemode angepasst werden!
  6. #define DIALOG_BLITZER_MAXRANGE 1 //<--- ACHTUNG: Die Dialogid muss je nach Gamemode angepasst werden!
  7. #define DIALOG_BLITZER_MAXSPEED 2 //<--- ACHTUNG: Die Dialogid muss je nach Gamemode angepasst werden!
  8.  
  9. #define ROT 0xFF0000FF
  10. #define GRÜN 0x00FF00FF
  11. #define GRAU 0x5A5A5AFF
  12.  
  13. forward BlitzedOff(playerid);
  14. forward IsInRangeOfBlitzer(playerid);
  15.  
  16. new Temp[MAX_PLAYERS],Blitzed[MAX_PLAYERS],BBlitzer[MAX_PLAYERS];
  17.  
  18. enum _BlitzerData
  19. {
  20. Float:BlitzerX,
  21. Float:BlitzerY,
  22. Float:BlitzerZ,
  23. Float:BlitzerRotation,
  24. Text3D:label,
  25. erstellt,
  26. maxrange,
  27. maxspeed,
  28. Obj
  29. };
  30.  
  31. new Blitzer[MAX_BLITZER][_BlitzerData];
  32.  
  33. public OnFilterScriptInit()
  34. {
  35. print("\n--------------------------------------");
  36. print(" Blitzersystem - sa-mp.de");
  37. print("--------------------------------------\n");
  38. BlitzerLaden();
  39. return 1;
  40. }
  41.  
  42. public OnFilterScriptExit()
  43. {
  44. BlitzerSpeichern();
  45. return 1;
  46. }
  47.  
  48. public OnPlayerCommandText(playerid, cmdtext[])
  49. {
  50. if(strcmp("/createblitzer",cmdtext,true,10) == 0)
  51. {
  52. if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,ROT,"Du bist kein Admin!");
  53. ShowPlayerDialog(playerid,DIALOG_BLITZER,DIALOG_STYLE_LIST,"Blitzersystem - 123marvin123","Blitzer aufstellen\nBlitzer abbauen\nAlle Blitzer abbauen","Bestätigen","Abbrechen");
  54. return 1;
  55. }
  56. return 0;
  57. }
  58.  
  59. public OnPlayerStateChange(playerid, newstate, oldstate)
  60. {
  61. if(newstate == PLAYER_STATE_DRIVER)
  62. {
  63. BBlitzer[playerid] = SetTimerEx("IsInRangeOfBlitzer",1000,true,"i",playerid);
  64. }
  65. else if(oldstate == PLAYER_STATE_DRIVER)
  66. {
  67. KillTimer(BBlitzer[playerid]);
  68. }
  69. return 1;
  70. }
  71.  
  72. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  73. {
  74. new Float:x,Float:y,Float:z,Float:rotation,string[50];
  75. GetPlayerPos(playerid,x,y,z);
  76. GetPlayerFacingAngle(playerid,rotation);
  77. switch (dialogid)
  78. {
  79. case DIALOG_BLITZER:
  80. {
  81. switch (listitem)
  82. {
  83. case 0:
  84. {
  85. if(response)
  86. {
  87. ShowPlayerDialog(playerid,DIALOG_BLITZER_MAXRANGE,DIALOG_STYLE_INPUT,"Blitzersystem - 123marvin123","Gebe nun den Radius ein:","Bestätigen","Abbrechen");
  88. }
  89. }
  90. case 1:
  91. {
  92. if(response)
  93. {
  94. for(new i = 0; i < MAX_BLITZER; i++)
  95. {
  96. if(Blitzer[i][erstellt] == 0)continue;
  97. if(Blitzer[i][erstellt] == 1)
  98. {
  99. if(IsPlayerInRangeOfPoint(playerid,10.0,Blitzer[i][BlitzerX],Blitzer[i][BlitzerY],Blitzer[i][BlitzerZ]))
  100. {
  101. DestroyObject(Blitzer[i][Obj]);
  102. Blitzer[i][BlitzerX] = 0;
  103. Blitzer[i][BlitzerY] = 0;
  104. Blitzer[i][BlitzerZ] = 0;
  105. Blitzer[i][erstellt] = 0;
  106. Blitzer[i][maxrange] = 0;
  107. Blitzer[i][maxspeed] = 0;
  108. Blitzer[i][Obj] = -1;
  109. Delete3DTextLabel(Blitzer[i][label]);
  110. //dini_Remove(Datei);
  111. BlitzerSpeichern();
  112. }
  113. }
  114. }
  115. }
  116. }
  117. case 2:
  118. {
  119. if(response)
  120. {
  121. for(new i = 0; i < MAX_BLITZER; i++)
  122. {
  123. if(Blitzer[i][erstellt] == 0)continue;
  124. if(Blitzer[i][erstellt] == 1)
  125. {
  126. DestroyObject(Blitzer[i][Obj]);
  127. Blitzer[i][BlitzerX] = 0;
  128. Blitzer[i][BlitzerY] = 0;
  129. Blitzer[i][BlitzerZ] = 0;
  130. Blitzer[i][erstellt] = 0;
  131. Blitzer[i][maxrange] = 0;
  132. Blitzer[i][maxspeed] = 0;
  133. Blitzer[i][Obj] = -1;
  134. Delete3DTextLabel(Blitzer[i][label]);
  135. //dini_Remove(Datei);
  136. }
  137. }
  138. BlitzerSpeichern();
  139. }
  140. }
  141. }
  142. }
  143. case DIALOG_BLITZER_MAXRANGE:
  144. {
  145. new zahl = strval(inputtext);
  146. Temp[playerid] = zahl;
  147. ShowPlayerDialog(playerid,DIALOG_BLITZER_MAXSPEED,DIALOG_STYLE_INPUT,"Blitzersystem - 123marvin123","Gebe nun die Maximale Geschwindigkeit in km/h an:","Bestätigen","Abbrechen");
  148. }
  149. case DIALOG_BLITZER_MAXSPEED:
  150. {
  151. new zahl = strval(inputtext);
  152. for(new i = 0; i < MAX_BLITZER; i++)
  153. {
  154. if(Blitzer[i][erstellt] == 1)continue;
  155. Blitzer[i][BlitzerX] = x;
  156. Blitzer[i][BlitzerY] = y;
  157. Blitzer[i][BlitzerZ] = z;
  158. Blitzer[i][erstellt] = 1;
  159. Blitzer[i][maxspeed] = zahl;
  160. Blitzer[i][maxrange] = Temp[playerid];
  161. Blitzer[i][BlitzerRotation] = rotation;
  162. Blitzer[i][Obj] = CreateObject(18880,x+1,y+1,z-1,0.0,0.0,rotation);
  163. format(string,sizeof(string),"Blitzer ID: %i\nMax. Speed: %i km/h\nRadius: %i",i,zahl,Temp[playerid]);
  164. Blitzer[i][label] = Create3DTextLabel(string,GRAU,x+1,y+1,z+1,Temp[playerid] / 2,0);
  165. Temp[playerid] = 0;
  166. return 1;
  167. }
  168. }
  169. }
  170. return 1;
  171. }
  172.  
  173. stock BlitzerSpeichern()
  174. {
  175. new File: file = fopen("Blitzer/Blitzer.cfg", io_write);
  176. if (file)
  177. {
  178. for(new i = 0; i < MAX_BLITZER; i++)
  179. {
  180. if(Blitzer[i][erstellt] == 0)continue;
  181. new coordsstring[100];
  182. format(coordsstring, sizeof(coordsstring), "%f|%f|%f|%d|%d|%f\n",
  183. Blitzer[i][BlitzerX],
  184. Blitzer[i][BlitzerY],
  185. Blitzer[i][BlitzerZ],
  186. Blitzer[i][maxspeed],
  187. Blitzer[i][maxrange],
  188. Blitzer[i][BlitzerRotation]);
  189. fwrite(file, coordsstring);
  190. }
  191. fclose(file);
  192. }
  193. return 1;
  194. }
  195.  
  196. stock BlitzerLaden()
  197. {
  198. for(new i = 0;i < MAX_BLITZER; i++)
  199. {
  200. Blitzer[i][erstellt] = 0;
  201. }
  202. new arrCoords[6][20];
  203. new strFromFile2[100];
  204. new string[50];
  205. new File: file = fopen("Blitzer/Blitzer.cfg", io_read);
  206. if (file)
  207. {
  208. new i = 0;
  209. while (fread(file, strFromFile2))
  210. {
  211. split(strFromFile2, arrCoords, '|');
  212. Blitzer[i][BlitzerX] = floatstr(arrCoords[0]);
  213. Blitzer[i][BlitzerY] = floatstr(arrCoords[1]);
  214. Blitzer[i][BlitzerZ] = floatstr(arrCoords[2]);
  215. Blitzer[i][maxspeed] = strval(arrCoords[3]);
  216. Blitzer[i][maxrange] = strval(arrCoords[4]);
  217. Blitzer[i][BlitzerRotation] = floatstr(arrCoords[5]);
  218. Blitzer[i][erstellt] = 1;
  219. format(string,sizeof(string),"Blitzer ID: %i\nMax. Speed: %i km/h\nRadius: %i",i,Blitzer[i][maxspeed],Blitzer[i][maxrange]);
  220. Blitzer[i][label] = Create3DTextLabel(string,GRAU,Blitzer[i][BlitzerX]+1,Blitzer[i][BlitzerY]+1,Blitzer[i][BlitzerZ]+1,Blitzer[i][maxrange] / 2,0);
  221. Blitzer[i][Obj] = CreateObject(18880,Blitzer[i][BlitzerX]+1,Blitzer[i][BlitzerY]+1,Blitzer[i][BlitzerZ]-1,0.0,0.0,Blitzer[i][BlitzerRotation]);
  222. i ++;
  223. }
  224. fclose(file);
  225. }
  226. return 1;
  227. }
  228.  
  229. stock split(const strsrc[], strdest[][], delimiter)
  230. {
  231. new i, li;
  232. new aNum;
  233. new len;
  234. while(i <= strlen(strsrc)){
  235. if(strsrc[i]==delimiter || i==strlen(strsrc)){
  236. len = strmid(strdest[aNum], strsrc, li, i, 128);
  237. strdest[aNum][len] = 0;
  238. li = i+1;
  239. aNum++;
  240. }
  241. i++;
  242. }
  243. return 1;
  244. }
  245.  
  246. stock ErmittleGeschwindigkeit(playerid,bool:kmh) {
  247. new Float:x,Float:y,Float:z,Float:rtn;
  248. if(IsPlayerInAnyVehicle(playerid))
  249. {
  250. GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z);
  251. }
  252. else
  253. {
  254. GetPlayerVelocity(playerid,x,y,z);
  255. }
  256. rtn = floatsqroot(x*x+y*y+z*z);
  257. return kmh?floatround(rtn * 100 * 1.61):floatround(rtn * 100);
  258. }
  259.  
  260. public BlitzedOff(playerid)
  261. {
  262. Blitzed[playerid] = 0;
  263. return 1;
  264. }
  265.  
  266. public IsInRangeOfBlitzer(playerid)
  267. {
  268. new string[128],zuviel;
  269. if(!IsPlayerInAnyVehicle(playerid))return 1;
  270. if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)return 1;
  271. for(new i = 0; i < MAX_BLITZER; i++)
  272. {
  273. if(Blitzer[i][erstellt] == 0)continue;
  274. if(Blitzed[playerid] == 1)return 1;
  275. if(Blitzer[i][erstellt] == 1)
  276. {
  277. if(IsPlayerInRangeOfPoint(playerid,Blitzer[i][maxrange],Blitzer[i][BlitzerX],Blitzer[i][BlitzerY],Blitzer[i][BlitzerZ]))
  278. {
  279. if(ErmittleGeschwindigkeit(playerid,true) > Blitzer[i][maxspeed])
  280. {
  281. zuviel = ErmittleGeschwindigkeit(playerid,true)-Blitzer[i][maxspeed];
  282. GivePlayerMoney(playerid,-zuviel*10);
  283. format(string,sizeof(string),"Du bist %ikm/h zuschnell gefahren! Das heißt $%i Strafe!",zuviel,zuviel*10);
  284. SendClientMessage(playerid,ROT,string);
  285. Blitzed[playerid] = 1;
  286. SetTimerEx("BlitzedOff",6000,false,"i",playerid);
  287. return 1;
  288. }
  289. }
  290. }
  291. }
  292. return 1;
  293. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement