Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- //#include <Dini> wird nicht mehr gebraucht
- #define MAX_BLITZER 50 //<--- Maximale Anzahl an Blitzer | Kann geändert werden.
- #define DIALOG_BLITZER 0 //<--- ACHTUNG: Die Dialogid muss je nach Gamemode angepasst werden!
- #define DIALOG_BLITZER_MAXRANGE 1 //<--- ACHTUNG: Die Dialogid muss je nach Gamemode angepasst werden!
- #define DIALOG_BLITZER_MAXSPEED 2 //<--- ACHTUNG: Die Dialogid muss je nach Gamemode angepasst werden!
- #define ROT 0xFF0000FF
- #define GRÜN 0x00FF00FF
- #define GRAU 0x5A5A5AFF
- forward BlitzedOff(playerid);
- forward IsInRangeOfBlitzer(playerid);
- new Temp[MAX_PLAYERS],Blitzed[MAX_PLAYERS],BBlitzer[MAX_PLAYERS];
- enum _BlitzerData
- {
- Float:BlitzerX,
- Float:BlitzerY,
- Float:BlitzerZ,
- Float:BlitzerRotation,
- Text3D:label,
- erstellt,
- maxrange,
- maxspeed,
- Obj
- };
- new Blitzer[MAX_BLITZER][_BlitzerData];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Blitzersystem - sa-mp.de");
- print("--------------------------------------\n");
- BlitzerLaden();
- return 1;
- }
- public OnFilterScriptExit()
- {
- BlitzerSpeichern();
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(strcmp("/createblitzer",cmdtext,true,10) == 0)
- {
- if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,ROT,"Du bist kein Admin!");
- ShowPlayerDialog(playerid,DIALOG_BLITZER,DIALOG_STYLE_LIST,"Blitzersystem - 123marvin123","Blitzer aufstellen\nBlitzer abbauen\nAlle Blitzer abbauen","Bestätigen","Abbrechen");
- return 1;
- }
- return 0;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(newstate == PLAYER_STATE_DRIVER)
- {
- BBlitzer[playerid] = SetTimerEx("IsInRangeOfBlitzer",1000,true,"i",playerid);
- }
- else if(oldstate == PLAYER_STATE_DRIVER)
- {
- KillTimer(BBlitzer[playerid]);
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- new Float:x,Float:y,Float:z,Float:rotation,string[50];
- GetPlayerPos(playerid,x,y,z);
- GetPlayerFacingAngle(playerid,rotation);
- switch (dialogid)
- {
- case DIALOG_BLITZER:
- {
- switch (listitem)
- {
- case 0:
- {
- if(response)
- {
- ShowPlayerDialog(playerid,DIALOG_BLITZER_MAXRANGE,DIALOG_STYLE_INPUT,"Blitzersystem - 123marvin123","Gebe nun den Radius ein:","Bestätigen","Abbrechen");
- }
- }
- case 1:
- {
- if(response)
- {
- for(new i = 0; i < MAX_BLITZER; i++)
- {
- if(Blitzer[i][erstellt] == 0)continue;
- if(Blitzer[i][erstellt] == 1)
- {
- if(IsPlayerInRangeOfPoint(playerid,10.0,Blitzer[i][BlitzerX],Blitzer[i][BlitzerY],Blitzer[i][BlitzerZ]))
- {
- DestroyObject(Blitzer[i][Obj]);
- Blitzer[i][BlitzerX] = 0;
- Blitzer[i][BlitzerY] = 0;
- Blitzer[i][BlitzerZ] = 0;
- Blitzer[i][erstellt] = 0;
- Blitzer[i][maxrange] = 0;
- Blitzer[i][maxspeed] = 0;
- Blitzer[i][Obj] = -1;
- Delete3DTextLabel(Blitzer[i][label]);
- //dini_Remove(Datei);
- BlitzerSpeichern();
- }
- }
- }
- }
- }
- case 2:
- {
- if(response)
- {
- for(new i = 0; i < MAX_BLITZER; i++)
- {
- if(Blitzer[i][erstellt] == 0)continue;
- if(Blitzer[i][erstellt] == 1)
- {
- DestroyObject(Blitzer[i][Obj]);
- Blitzer[i][BlitzerX] = 0;
- Blitzer[i][BlitzerY] = 0;
- Blitzer[i][BlitzerZ] = 0;
- Blitzer[i][erstellt] = 0;
- Blitzer[i][maxrange] = 0;
- Blitzer[i][maxspeed] = 0;
- Blitzer[i][Obj] = -1;
- Delete3DTextLabel(Blitzer[i][label]);
- //dini_Remove(Datei);
- }
- }
- BlitzerSpeichern();
- }
- }
- }
- }
- case DIALOG_BLITZER_MAXRANGE:
- {
- new zahl = strval(inputtext);
- Temp[playerid] = zahl;
- ShowPlayerDialog(playerid,DIALOG_BLITZER_MAXSPEED,DIALOG_STYLE_INPUT,"Blitzersystem - 123marvin123","Gebe nun die Maximale Geschwindigkeit in km/h an:","Bestätigen","Abbrechen");
- }
- case DIALOG_BLITZER_MAXSPEED:
- {
- new zahl = strval(inputtext);
- for(new i = 0; i < MAX_BLITZER; i++)
- {
- if(Blitzer[i][erstellt] == 1)continue;
- Blitzer[i][BlitzerX] = x;
- Blitzer[i][BlitzerY] = y;
- Blitzer[i][BlitzerZ] = z;
- Blitzer[i][erstellt] = 1;
- Blitzer[i][maxspeed] = zahl;
- Blitzer[i][maxrange] = Temp[playerid];
- Blitzer[i][BlitzerRotation] = rotation;
- Blitzer[i][Obj] = CreateObject(18880,x+1,y+1,z-1,0.0,0.0,rotation);
- format(string,sizeof(string),"Blitzer ID: %i\nMax. Speed: %i km/h\nRadius: %i",i,zahl,Temp[playerid]);
- Blitzer[i][label] = Create3DTextLabel(string,GRAU,x+1,y+1,z+1,Temp[playerid] / 2,0);
- Temp[playerid] = 0;
- return 1;
- }
- }
- }
- return 1;
- }
- stock BlitzerSpeichern()
- {
- new File: file = fopen("Blitzer/Blitzer.cfg", io_write);
- if (file)
- {
- for(new i = 0; i < MAX_BLITZER; i++)
- {
- if(Blitzer[i][erstellt] == 0)continue;
- new coordsstring[100];
- format(coordsstring, sizeof(coordsstring), "%f|%f|%f|%d|%d|%f\n",
- Blitzer[i][BlitzerX],
- Blitzer[i][BlitzerY],
- Blitzer[i][BlitzerZ],
- Blitzer[i][maxspeed],
- Blitzer[i][maxrange],
- Blitzer[i][BlitzerRotation]);
- fwrite(file, coordsstring);
- }
- fclose(file);
- }
- return 1;
- }
- stock BlitzerLaden()
- {
- for(new i = 0;i < MAX_BLITZER; i++)
- {
- Blitzer[i][erstellt] = 0;
- }
- new arrCoords[6][20];
- new strFromFile2[100];
- new string[50];
- new File: file = fopen("Blitzer/Blitzer.cfg", io_read);
- if (file)
- {
- new i = 0;
- while (fread(file, strFromFile2))
- {
- split(strFromFile2, arrCoords, '|');
- Blitzer[i][BlitzerX] = floatstr(arrCoords[0]);
- Blitzer[i][BlitzerY] = floatstr(arrCoords[1]);
- Blitzer[i][BlitzerZ] = floatstr(arrCoords[2]);
- Blitzer[i][maxspeed] = strval(arrCoords[3]);
- Blitzer[i][maxrange] = strval(arrCoords[4]);
- Blitzer[i][BlitzerRotation] = floatstr(arrCoords[5]);
- Blitzer[i][erstellt] = 1;
- format(string,sizeof(string),"Blitzer ID: %i\nMax. Speed: %i km/h\nRadius: %i",i,Blitzer[i][maxspeed],Blitzer[i][maxrange]);
- Blitzer[i][label] = Create3DTextLabel(string,GRAU,Blitzer[i][BlitzerX]+1,Blitzer[i][BlitzerY]+1,Blitzer[i][BlitzerZ]+1,Blitzer[i][maxrange] / 2,0);
- Blitzer[i][Obj] = CreateObject(18880,Blitzer[i][BlitzerX]+1,Blitzer[i][BlitzerY]+1,Blitzer[i][BlitzerZ]-1,0.0,0.0,Blitzer[i][BlitzerRotation]);
- i ++;
- }
- fclose(file);
- }
- return 1;
- }
- stock split(const strsrc[], strdest[][], delimiter)
- {
- new i, li;
- new aNum;
- new len;
- while(i <= strlen(strsrc)){
- if(strsrc[i]==delimiter || i==strlen(strsrc)){
- len = strmid(strdest[aNum], strsrc, li, i, 128);
- strdest[aNum][len] = 0;
- li = i+1;
- aNum++;
- }
- i++;
- }
- return 1;
- }
- stock ErmittleGeschwindigkeit(playerid,bool:kmh) {
- new Float:x,Float:y,Float:z,Float:rtn;
- if(IsPlayerInAnyVehicle(playerid))
- {
- GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z);
- }
- else
- {
- GetPlayerVelocity(playerid,x,y,z);
- }
- rtn = floatsqroot(x*x+y*y+z*z);
- return kmh?floatround(rtn * 100 * 1.61):floatround(rtn * 100);
- }
- public BlitzedOff(playerid)
- {
- Blitzed[playerid] = 0;
- return 1;
- }
- public IsInRangeOfBlitzer(playerid)
- {
- new string[128],zuviel;
- if(!IsPlayerInAnyVehicle(playerid))return 1;
- if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)return 1;
- for(new i = 0; i < MAX_BLITZER; i++)
- {
- if(Blitzer[i][erstellt] == 0)continue;
- if(Blitzed[playerid] == 1)return 1;
- if(Blitzer[i][erstellt] == 1)
- {
- if(IsPlayerInRangeOfPoint(playerid,Blitzer[i][maxrange],Blitzer[i][BlitzerX],Blitzer[i][BlitzerY],Blitzer[i][BlitzerZ]))
- {
- if(ErmittleGeschwindigkeit(playerid,true) > Blitzer[i][maxspeed])
- {
- zuviel = ErmittleGeschwindigkeit(playerid,true)-Blitzer[i][maxspeed];
- GivePlayerMoney(playerid,-zuviel*10);
- format(string,sizeof(string),"Du bist %ikm/h zuschnell gefahren! Das heißt $%i Strafe!",zuviel,zuviel*10);
- SendClientMessage(playerid,ROT,string);
- Blitzed[playerid] = 1;
- SetTimerEx("BlitzedOff",6000,false,"i",playerid);
- return 1;
- }
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement