Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //|===========================Kofferbombensystem von IntelligenT==================================|
- //===========================Teil: Includes==================================
- #include <a_samp>
- #include <UC>
- //===========================Teil: Konfiguration==================================
- #define SM_X 1285.2001 // Schwarzmarkt X-Koordinate vom Befehl
- #define SM_Y -1252.7443 // Schwarzmarkt Y-Koordinate vom Befehl
- #define SM_Z 13.5469 // Schwarzmarkt Z-Koordinate vom Befehl
- #define SM_RANGE 15.0 // Schwarzmarkt Range vom Befehl
- #define BOMBEN_PREIS 100000 // Preis einer Kofferbombe
- //===========================Teil: Enum | Define | new==================================
- enum eKoffer
- {
- Bombe,
- HatKoffer,
- BombenTimer,
- BombeAktiv,
- KofferAbgelegt,
- Float:KofferX,
- Float:KofferY,
- Float:KofferZ
- }
- new KofferInfo[MAX_PLAYERS][eKoffer];
- #define DIALOG_KOFFERMENU 6784
- #define DIALOG_KOFFERTIMER 6785
- #define DIALOG_KOFFERAKTIV 6786
- #define DIALOG_KOFFERKAUFEN 6787
- #define COLOR_BOMBEN_RED 0x7D0000FF
- #define COLOR_BOMBEN_GREEN 0x33AA33AA
- #define COLOR_BOMBEN_GRAD1 0xB4B5B7FF
- new Text:SP0 = Text:INVALID_TEXT_DRAW;
- new Text:SP1 = Text:INVALID_TEXT_DRAW;
- new Text:SP2[MAX_PLAYERS] = Text:INVALID_TEXT_DRAW;
- new SuchTimer[MAX_PLAYERS];
- new PruferAktiv[MAX_PLAYERS]=0;
- //===========================Teil: OnFilterScriptInit==================================
- public OnFilterScriptInit()
- {
- printf("Filterscript [FS]iKofferbomben.amx von IntelligenT geladen\n");
- new string[450]; format(string,sizeof string," Schwarzmarkt - /kofferkaufen um einen Bombenkoffer zu kaufen - Preis: $%d",BOMBEN_PREIS);
- Create3DTextLabel(string, 0xFFFFFFFF, SM_X,SM_Y,SM_Z,SM_RANGE,0);
- CreatePickup(1239,23,SM_X,SM_Y,SM_Z,-1);
- SP0 = TextDrawCreate(164.500, 281.937, "box");
- TextDrawLetterSize(SP0, 0.000, 4.716);
- TextDrawTextSize(SP0, 27.500, 0.000);
- TextDrawAlignment(SP0, 1);
- TextDrawColor(SP0, 0);
- TextDrawUseBox(SP0, 1);
- TextDrawBoxColor(SP0, 102);
- TextDrawFont(SP0, 0);
- SP1 = TextDrawCreate(37.500, 284.375, "Sprengstofftester");
- TextDrawLetterSize(SP1, 0.391, 1.735);
- TextDrawTextSize(SP1, -12.000, -1.312);
- TextDrawAlignment(SP1, 1);
- TextDrawColor(SP1, 929169407);
- TextDrawSetOutline(SP1, 1);
- TextDrawBackgroundColor(SP1, 51);
- TextDrawFont(SP1, 1);
- TextDrawSetProportional(SP1, 1);
- for(new playerid=0; playerid < MAX_PLAYERS; playerid++)
- {
- SP2[playerid] = TextDrawCreate(36.000, 304.062, "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
- TextDrawLetterSize(SP2[playerid], 0.184, 1.629);
- TextDrawAlignment(SP2[playerid], 1);
- TextDrawColor(SP2[playerid], -1);
- TextDrawSetOutline(SP2[playerid], 1);
- TextDrawBackgroundColor(SP2[playerid], 51);
- TextDrawFont(SP2[playerid], 2);
- TextDrawSetProportional(SP2[playerid], 1);
- KofferInfo[playerid][HatKoffer]=0;
- KofferInfo[playerid][BombeAktiv]=0;
- KofferInfo[playerid][BombenTimer]=10;
- KofferInfo[playerid][KofferAbgelegt]=0;
- PruferAktiv[playerid]=0;
- }
- return 1;
- }
- //===========================Teil: OnPlayerConnect==================================
- public OnPlayerConnect(playerid)
- {
- KofferInfo[playerid][HatKoffer]=0;
- KofferInfo[playerid][BombeAktiv]=0;
- KofferInfo[playerid][BombenTimer]=10;
- KofferInfo[playerid][KofferAbgelegt]=0;
- PruferAktiv[playerid]=0;
- return 1;
- }
- //===========================Teil: OnDialogResponse==================================
- public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[])
- {
- if(dialogid == DIALOG_KOFFERMENU)
- {
- if(response)
- {
- switch(listitem)
- {
- case 0: { ShowPlayerDialog(playerid,DIALOG_KOFFERTIMER,DIALOG_STYLE_INPUT,"Einstellen des Bombentimers","Nach wievielen Sekunden soll deine Bombe explodieren ?","Einstellen","Zurück"); }
- case 1: { new string5[256]; format(string5,256,"Möchtest du die Bombe aktivieren ?\n\nAktuelle Timerzeit: %i Sekunden\n\nKlicke auf 'Aktivieren', um die Bombe mit dieser Einstellung zu aktivieren.",KofferInfo[playerid][BombenTimer]); ShowPlayerDialog(playerid,DIALOG_KOFFERAKTIV,DIALOG_STYLE_MSGBOX,"Bombe aktivieren",string5,"Aktivieren","Beenden");}
- case 2:
- {
- if(KofferInfo[playerid][BombeAktiv]==0) return SendClientMessage(playerid,COLOR_BOMBEN_RED,"Kofferbombe ist nicht aktiv!");
- new Float:x,Float:y,Float:z; GetPlayerPos(playerid,x,y,z);
- KofferInfo[playerid][Bombe]=CreateObject(1210,x,y,z-0.8,0.0,0.0,0.0);
- KofferInfo[playerid][KofferX]=x; KofferInfo[playerid][KofferY]=y; KofferInfo[playerid][KofferZ]=z; KofferInfo[playerid][KofferAbgelegt]=1;
- RemovePlayerAttachedObject(playerid, 5);
- SendClientMessage(playerid,COLOR_BOMBEN_GREEN,"Kofferbombe abgelegt.");
- }
- }
- }
- }
- if(dialogid == DIALOG_KOFFERTIMER)
- {
- if(response)
- {
- if(strval(inputtext) > 0 && strlen(inputtext) > 0)
- KofferInfo[playerid][BombenTimer]=strval(inputtext);
- new string5[256]; format(string5,256,"Timer einstellen - Aktuelle Zeit: %i Sekunden\nBombe Aktivieren\n\nKoffer ablegen - Geht nur wenn er aktiv ist!\nBeenden",KofferInfo[playerid][BombenTimer]);
- ShowPlayerDialog(playerid,DIALOG_KOFFERMENU,DIALOG_STYLE_LIST,"Wähle eine Option",string5,"Weiter","Beenden");
- }
- }
- if(dialogid == DIALOG_KOFFERAKTIV)
- {
- if(response)
- {
- if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_BOMBEN_RED,"Du kannst die Kofferbombe in einem Fahrzeug nicht aktivieren!");
- KofferInfo[playerid][BombeAktiv]=1;
- new interval=KofferInfo[playerid][BombenTimer]*1000; SetTimerEx("KofferTimer",interval,0,"i",playerid);
- SetPlayerAttachedObject( playerid, 5, 1210, 5, 0.293188, -0.024004, 0.056436, 144.529037, 278.794769, 0.000000, 1.000000, 1.000000, 1.000000 );
- }
- }
- if(dialogid == DIALOG_KOFFERKAUFEN)
- {
- if(response)
- {
- GivePlayerMoney(playerid, -BOMBEN_PREIS); KofferInfo[playerid][HatKoffer]=1;
- SendClientMessage(playerid, COLOR_BOMBEN_GREEN,"Herzlichen Glückwunsch zum Kauf eines Bombenkoffer's. '/koffer' zum Einstellen der Bombe!");
- }
- }
- return 1;
- }
- //===========================Teil: Befehle und Script==================================
- UC-koffer(pp-)
- {
- new string[256];
- if(KofferInfo[playerid][HatKoffer] == 0) return SendClientMessage(playerid, COLOR_BOMBEN_GRAD1, "Du hast keinen Koffer!");
- format(string,256,"Timer einstellen - Aktuelle Zeit: %i Sekunden\nBombe Aktivieren\n\nKoffer ablegen - Geht nur wenn er aktiv ist!\nBeenden",KofferInfo[playerid][BombenTimer]);
- ShowPlayerDialog(playerid,DIALOG_KOFFERMENU,DIALOG_STYLE_LIST,"Wähle eine Option",string,"Weiter","Beenden");
- return 1;
- }
- forward KofferTimer(playerid);
- public KofferTimer(playerid)
- {
- if(KofferInfo[playerid][KofferAbgelegt] == 1)
- {
- CreateExplosion(KofferInfo[playerid][KofferX],KofferInfo[playerid][KofferY],KofferInfo[playerid][KofferZ],3,1000.0);
- for(new i=0; i<MAX_PLAYERS; i++) { if(IsPlayerInRangeOfPoint(i,25.0,KofferInfo[playerid][KofferX],KofferInfo[playerid][KofferY],KofferInfo[playerid][KofferZ])) { SetPlayerHealth(i,0); } else if(IsPlayerInRangeOfPoint(i,51.0,KofferInfo[playerid][KofferX],KofferInfo[playerid][KofferY],KofferInfo[playerid][KofferZ])) { ResetStatus(playerid); } }
- }
- else
- {
- new Float:x,Float:y,Float:z; GetPlayerPos(playerid,x,y,z); CreateExplosion(x,y,z,3,1000.0);
- for(new i=0; i<MAX_PLAYERS; i++) {
- if(IsPlayerInRangeOfPoint(i,25.0,x,y,z)) { SetPlayerHealth(i,0); } else if(IsPlayerInRangeOfPoint(i,51.0,x,y,z)) { ResetStatus(playerid); } }
- }
- KofferInfo[playerid][HatKoffer]=0; KofferInfo[playerid][BombeAktiv]=0; KofferInfo[playerid][BombenTimer]=10; KofferInfo[playerid][KofferAbgelegt]=0;
- DestroyObject(KofferInfo[playerid][Bombe]);
- SendClientMessage(playerid,COLOR_BOMBEN_GREEN,"Kofferbombe ist explodiert.");
- return 1;
- }
- UC-money(pp-)
- {
- GivePlayerMoney(playerid,BOMBEN_PREIS);
- return 1;
- }
- UC-kofferkaufen(pp-)
- {
- if(!IsPlayerInRangeOfPoint(playerid,SM_RANGE,SM_X,SM_Y,SM_Z)) { SendClientMessage(playerid,0xAA3333AA,"Du bist nicht beim Schwarzmarkt!"); return 1; }
- if(KofferInfo[playerid][HatKoffer] == 1) return SendClientMessage(playerid,0xAA3333AA,"Du hast bereits einen Koffer!");
- if(GetPlayerMoney(playerid) < BOMBEN_PREIS) return SendClientMessage(playerid,0xAA3333AA,"Du hast nicht genügend Geld!");
- ShowPlayerDialog(playerid, DIALOG_KOFFERKAUFEN, DIALOG_STYLE_MSGBOX, "Los Santos Schwarzmarkt", "Möchtest du für 100.000$ einen Bombenkoffer kaufen ?", "Ja", "Nein");
- return 1;
- }
- UC-pruefer(pp-)
- {
- /*if(IsACop(playerid))
- {*/
- new Tat;
- if(sscanf(params,"i",Tat)){ SendClientMessage(playerid, COLOR_BOMBEN_GRAD1, "Benutzung: /pruefer [Nummer]"); SendClientMessage(playerid, COLOR_BOMBEN_GRAD1, "Nummern: 1 = An | 0 = Aus"); return 1; }
- if(Tat==1) { ShowPrufer(playerid); SuchTimer[playerid] = SetTimerEx("SuchBombe",1000,1,"i",playerid); SendClientMessage(playerid,COLOR_BOMBEN_GREEN,"Sprengstoffprüfer aktiviert."); }
- else { KillTimer(SuchTimer[playerid]); HidePrufer(playerid); SendClientMessage(playerid,COLOR_BOMBEN_GREEN,"Sprengstoffprüfer deaktiviert."); }
- return 1;
- /*}
- else return SendClientMessage(playerid,COLOR_BOMBEN_RED,"Du bist kein Beamter!");*/
- }
- stock ShowPrufer(playerid)
- {
- ResetStatus(playerid);
- TextDrawShowForPlayer(playerid,SP0);
- TextDrawShowForPlayer(playerid,SP1);
- TextDrawShowForPlayer(playerid,SP2[playerid]);
- PruferAktiv[playerid] = 1;
- return 1;
- }
- stock HidePrufer(playerid)
- {
- TextDrawHideForPlayer(playerid,SP0);
- TextDrawHideForPlayer(playerid,SP1);
- TextDrawHideForPlayer(playerid,SP2[playerid]);
- PruferAktiv[playerid] = 0;
- return 1;
- }
- stock ResetStatus(playerid)
- {
- new string[256];
- format(string,sizeof(string),"~w~IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII");
- TextDrawSetString(SP2[playerid],string);
- }
- forward SuchBombe(playerid);
- public SuchBombe(playerid)
- {
- if(PruferAktiv[playerid] == 1)
- {
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- if(KofferInfo[i][BombeAktiv] == 1)
- {
- new string[256];
- if(KofferInfo[i][KofferAbgelegt] == 1)
- {
- new Float:Distanz = GetPlayerDistanceFromPoint(playerid,KofferInfo[i][KofferX],KofferInfo[i][KofferY],KofferInfo[i][KofferZ]);
- if(Distanz > 50) { format(string,sizeof(string),"~w~IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII"); }
- else
- {
- new abstand = 51-floatround(Distanz);
- format(string,sizeof(string),"~r~IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII");
- string[abstand+2] = '~'; string[abstand+3] = 'w'; string[abstand+4] = '~';
- }
- TextDrawSetString(SP2[playerid],string);
- }
- else
- {
- new Float:x,Float:y,Float:z;
- GetPlayerPos(i,x,y,z);
- new Float:Distanz = GetPlayerDistanceFromPoint(playerid,x,y,z);
- if(Distanz > 50) { format(string,sizeof(string),"~w~IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII"); }
- else
- {
- new abstand = 51-floatround(Distanz);
- format(string,sizeof(string),"~r~IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII");
- string[abstand+2] = '~'; string[abstand+3] = 'w'; string[abstand+4] = '~';
- }
- TextDrawSetString(SP2[playerid],string);
- }
- }
- }
- }
- return 1;
- }
- //===========================Teil: SSCANF==================================
- stock sscanf(string[], format[], {Float,_}:...)
- {
- #if defined isnull
- if (isnull(string))
- #else
- if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
- #endif
- {
- return format[0];
- }
- #pragma tabsize 4
- new
- formatPos = 0,
- stringPos = 0,
- paramPos = 2,
- paramCount = numargs(),
- delim = ' ';
- while (string[stringPos] && string[stringPos] <= ' ')
- {
- stringPos++;
- }
- while (paramPos < paramCount && string[stringPos])
- {
- switch (format[formatPos++])
- {
- case '\0':
- {
- return 0;
- }
- case 'i', 'd':
- {
- new
- neg = 1,
- num = 0,
- ch = string[stringPos];
- if (ch == '-')
- {
- neg = -1;
- ch = string[++stringPos];
- }
- do
- {
- stringPos++;
- if ('0' <= ch <= '9')
- {
- num = (num * 10) + (ch - '0');
- }
- else
- {
- return -1;
- }
- }
- while ((ch = string[stringPos]) > ' ' && ch != delim);
- setarg(paramPos, 0, num * neg);
- }
- case 'h', 'x':
- {
- new
- num = 0,
- ch = string[stringPos];
- do
- {
- stringPos++;
- switch (ch)
- {
- case 'x', 'X':
- {
- num = 0;
- continue;
- }
- case '0' .. '9':
- {
- num = (num << 4) | (ch - '0');
- }
- case 'a' .. 'f':
- {
- num = (num << 4) | (ch - ('a' - 10));
- }
- case 'A' .. 'F':
- {
- num = (num << 4) | (ch - ('A' - 10));
- }
- default:
- {
- return -1;
- }
- }
- }
- while ((ch = string[stringPos]) > ' ' && ch != delim);
- setarg(paramPos, 0, num);
- }
- case 'c':
- {
- setarg(paramPos, 0, string[stringPos++]);
- }
- case 'f':
- {
- new changestr[16], changepos = 0, strpos = stringPos;
- while(changepos < 16 && string[strpos] && string[strpos] != delim)
- {
- changestr[changepos++] = string[strpos++];
- }
- changestr[changepos] = '\0';
- setarg(paramPos,0,_:floatstr(changestr));
- }
- case 'p':
- {
- delim = format[formatPos++];
- continue;
- }
- case '\'':
- {
- new
- end = formatPos - 1,
- ch;
- while ((ch = format[++end]) && ch != '\'') {}
- if (!ch)
- {
- return -1;
- }
- format[end] = '\0';
- if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
- {
- if (format[end + 1])
- {
- return -1;
- }
- return 0;
- }
- format[end] = '\'';
- stringPos = ch + (end - formatPos);
- formatPos = end + 1;
- }
- case 'u':
- {
- new
- end = stringPos - 1,
- id = 0,
- bool:num = true,
- ch;
- while ((ch = string[++end]) && ch != delim)
- {
- if (num)
- {
- if ('0' <= ch <= '9')
- {
- id = (id * 10) + (ch - '0');
- }
- else
- {
- num = false;
- }
- }
- }
- if (num && IsPlayerConnected(id))
- {
- setarg(paramPos, 0, id);
- }
- else
- {
- #if !defined foreach
- #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
- #define __SSCANF_FOREACH__
- #endif
- string[end] = '\0';
- num = false;
- new
- name[MAX_PLAYER_NAME];
- id = end - stringPos;
- foreach (Player, playerid)
- {
- GetPlayerName(playerid, name, sizeof (name));
- if (!strcmp(name, string[stringPos], true, id))
- {
- setarg(paramPos, 0, playerid);
- num = true;
- break;
- }
- }
- if (!num)
- {
- setarg(paramPos, 0, INVALID_PLAYER_ID);
- }
- string[end] = ch;
- #if defined __SSCANF_FOREACH__
- #undef foreach
- #undef __SSCANF_FOREACH__
- #endif
- }
- stringPos = end;
- }
- case 's', 'z':
- {
- new
- i = 0,
- ch;
- if (format[formatPos])
- {
- while ((ch = string[stringPos++]) && ch != delim)
- {
- setarg(paramPos, i++, ch);
- }
- if (!i)
- {
- return -1;
- }
- }
- else
- {
- while ((ch = string[stringPos++]))
- {
- setarg(paramPos, i++, ch);
- }
- }
- stringPos--;
- setarg(paramPos, i, '\0');
- }
- default:
- {
- continue;
- }
- }
- while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
- {
- stringPos++;
- }
- while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
- {
- stringPos++;
- }
- paramPos++;
- }
- do
- {
- if ((delim = format[formatPos++]) > ' ')
- {
- if (delim == '\'')
- {
- while ((delim = format[formatPos++]) && delim != '\'') {}
- }
- else if (delim != 'z')
- {
- return delim;
- }
- }
- }
- while (delim > ' ');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement