Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *
- * Sicherheitsgurte aka "Durch die Scheibe fliegen" aus GTA IV
- * by NeoPhoenix aka ArgonX5
- *
- * www.NeoPhoenix.de
- *
- * Ein herzlichen Dank an Julian von gta-servers.de für den
- * Testserver.
- *
- * Dieses Filterscript steht unter CreativeCommon Licenses. Aber
- * weil sich eh keiner dran hält ist es mir auch egal, ob ihr
- * die Copyrights löscht oder nicht.
- *
- *
- * Thanks to:
- * - NeoPhoenix (FS, Tester)
- * - Julian (Testserver)
- *
- */
- #include <a_samp>
- #define KEY_ANSCHNALL KEY_LOOK_BEHIND
- #define MAX_SPIELER 20
- #define COLOR_GIFT 0xCCFF00CA
- #define SCM SendClientMessage
- #define COLOR_RED 0xFF6347AA
- #define ZEIT 12000
- #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
- new Float:AlteHP[MAX_VEHICLES];
- main()
- {
- print("\n");
- print("-- Sicherheitsgurte by NeoPhoenix\n");
- print("\n");
- }
- public OnFilterScriptInit()
- {
- AddPlayerClass(295, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
- for(new car=0; car<MAX_VEHICLES; car++)
- {
- AlteHP[car] = 1000.0;
- }
- return 1;
- }
- stock InvalidVehicle(id)
- {
- if(id == 448 || id == 461 || id == 462 || id == 463 || id == 468 || id == 481 || id == 509 || id == 510) return true;//Motorräder
- if(id == 521 || id == 522 || id == 581 || id == 586) return true;//+ Fahrräder
- if(id == 430 || id == 446 || id == 452 || id == 453 || id == 545 || id == 472 || id == 473 || id == 485) return true;//Boote
- if(id == 493 || id == 595) return true;//und alles was dazu gehört
- if(id == 417 || id == 425 || id == 447 || id == 460 || id == 469 || id == 476 || id == 487 || id == 488) return true;//Flugzeuge,
- if(id == 497 || id == 511 || id == 512 || id == 513 || id == 519 || id == 520 || id == 548 || id == 553) return true;//Helikopter
- if(id == 563 || id == 577 || id == 592 || id == 593) return true;//und weitere Flugvehicle
- return false;
- }
- public OnPlayerConnect(playerid)
- {
- SetPVarInt(playerid, "IstAngeschnallt", 0);
- return 1;
- }
- public OnVehicleDamageStatusUpdate(vehicleid, playerid)
- {
- if(!IsPlayerInAnyVehicle(playerid)) return true;
- if(InvalidVehicle(GetVehicleModel(GetPlayerVehicleID(playerid)))) return true;
- new Float: vHP;
- GetVehicleHealth(vehicleid, vHP);
- if((AlteHP[vehicleid] - vHP) <= 50)
- {
- AlteHP[vehicleid] = vHP;
- return true;
- }
- if(GetPVarInt(playerid, "IstAngeschnallt") == 0)
- {
- new Float:PosX, Float:PosY, Float:Angle, Float:PosZ, Float:HP, Float:nHP;
- RemovePlayerFromVehicle(playerid);
- GetPlayerPos(playerid, PosX, PosY, PosZ);
- GetPlayerFacingAngle(playerid, Angle);
- SetPlayerPos(playerid,PosX+2,PosY+2,PosZ+0.1);
- GetPlayerHealth(playerid, HP);
- SetPlayerHealth(playerid, HP-20);
- if(GetPlayerHealth(playerid, nHP) > 0)
- {
- ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, ZEIT);
- }
- GameTextForPlayer(playerid, "~r~Du bist durch die Scheibe geflogen", 5000, 5);
- }
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(newstate == PLAYER_STATE_DRIVER)
- {
- if(InvalidVehicle(GetVehicleModel(GetPlayerVehicleID(playerid)))) return true;
- SetPVarInt(playerid, "IstAngeschnallt", 0);
- SCM(playerid, COLOR_RED, "Du bist nicht angeschnallt. Gebe /gurt [anlegen/ablegen] ein um dich an/abzuschnallen.");
- }
- return 1;
- }
- /*public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(newkeys && KEY_ANSCHNALL)
- {
- if(IsPlayerInAnyVehicle(playerid))
- {
- if(InvalidVehicle(GetVehicleModel(GetPlayerVehicleID(playerid)))) return true;
- if(GetPVarInt(playerid, "IstAngeschnallt") == 0)
- {
- SCM(playerid, COLOR_GIFT, "Du hast dir den Sicherheitsgurt angelegt.");
- SetPVarInt(playerid, "IstAngeschnallt", 1);
- return 1;
- }
- if(GetPVarInt(playerid, "IstAngeschnallt") == 1)
- {
- SCM(playerid, COLOR_GIFT, "Du hast den Sicherheitsgurt abgelegt.");
- SetPVarInt(playerid, "IstAngeschnallt", 0);
- return 1;
- }
- }
- }
- return 1;
- }*/
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- dcmd(gurt,4,cmdtext);
- return 1;
- }
- stock n_SetVehicleHealth(car, Float:hp)
- {
- AlteHP[car] = hp;
- SetVehicleHealth(var, hp);
- return 1;
- }
- dcmd_gurt(playerid,params[])
- {
- new xxx[50];
- if(sscanf(params, "s",xxx))
- {
- return SendClientMessage(playerid,COLOR_RED,"HINWEIS: /gurt [anlegen/ablegen]");
- }
- if(!IsPlayerInAnyVehicle(playerid)) return SCM(playerid, COLOR_RED, "Du bist in keinem Fahrzeug");
- if(InvalidVehicle(GetVehicleModel(GetPlayerVehicleID(playerid)))) return SCM(playerid, COLOR_RED, "Dein jetziges Vehicle hat keine Sicherheitsgurte.");
- if(strcmp(xxx,"anlegen",true) == 0)
- {
- if(GetPVarInt(playerid, "IstAngeschnallt") == 1) { SCM(playerid, COLOR_RED, "Du bist schon angeschnallt"); return 1; }
- SCM(playerid, COLOR_GIFT, "Du hast dir den Sicherheitsgurt angelegt.");
- SetPVarInt(playerid, "IstAngeschnallt", 1);
- return 1;
- }
- else if(strcmp(xxx,"ablegen",true) == 0)
- {
- if(GetPVarInt(playerid, "IstAngeschnallt") == 0) { SCM(playerid, COLOR_RED, "Du bist gar nicht angeschnallt"); return 1; }
- SCM(playerid, COLOR_GIFT, "Du hast dir den Sicherheitsgurt abgelegt.");
- SetPVarInt(playerid, "IstAngeschnallt", 0);
- return 1;
- }
- else
- {
- SendClientMessage(playerid, COLOR_RED, "HINWEIS: /gurt [Aktion]. Aktionen: angelegen, ablegen");
- }
- return true;
- }
- 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