Advertisement
Guest User

SA:MP FS Sicherheitsgurt

a guest
Jul 10th, 2010
741
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.10 KB | None | 0 0
  1. /*
  2.     *
  3.     *   Sicherheitsgurte aka "Durch die Scheibe fliegen" aus GTA IV
  4.     *   by NeoPhoenix aka ArgonX5
  5.     *
  6.     *   www.NeoPhoenix.de
  7.     *
  8.     *   Ein herzlichen Dank an Julian von gta-servers.de für den
  9.     *   Testserver.
  10.     *
  11.     *   Dieses Filterscript steht unter CreativeCommon Licenses. Aber
  12.     *   weil sich eh keiner dran hält ist es mir auch egal, ob ihr
  13.     *   die Copyrights löscht oder nicht.
  14.     *
  15.     *
  16.     *   Thanks to:
  17.     *       - NeoPhoenix (FS, Tester)
  18.     *       - Julian (Testserver)
  19.     *
  20. */
  21.  
  22. #include <a_samp>
  23.  
  24. #define KEY_ANSCHNALL KEY_LOOK_BEHIND
  25. #define MAX_SPIELER 20
  26. #define COLOR_GIFT 0xCCFF00CA
  27. #define SCM SendClientMessage
  28. #define COLOR_RED 0xFF6347AA
  29. #define ZEIT 12000
  30. #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
  31.  
  32. new Float:AlteHP[MAX_VEHICLES];
  33.  
  34. main()
  35. {
  36.     print("\n");
  37.     print("-- Sicherheitsgurte by NeoPhoenix\n");
  38.     print("\n");
  39. }
  40.  
  41. public OnFilterScriptInit()
  42. {
  43.     AddPlayerClass(295, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0);
  44.     for(new car=0; car<MAX_VEHICLES; car++)
  45.     {
  46.         AlteHP[car] = 1000.0;
  47.     }
  48.     return 1;
  49. }
  50.  
  51. stock InvalidVehicle(id)
  52. {
  53.     if(id == 448 || id == 461 || id == 462 || id == 463 || id == 468 || id == 481 || id == 509 || id == 510) return true;//Motorräder
  54.     if(id == 521 || id == 522 || id == 581 || id == 586) return true;//+ Fahrräder
  55.  
  56.     if(id == 430 || id == 446 || id == 452 || id == 453 || id == 545 || id == 472 || id == 473 || id == 485) return true;//Boote
  57.     if(id == 493 || id == 595) return true;//und alles was dazu gehört
  58.  
  59.     if(id == 417 || id == 425 || id == 447 || id == 460 || id == 469 || id == 476 || id == 487 || id == 488) return true;//Flugzeuge,
  60.     if(id == 497 || id == 511 || id == 512 || id == 513 || id == 519 || id == 520 || id == 548 || id == 553) return true;//Helikopter
  61.     if(id == 563 || id == 577 || id == 592 || id == 593) return true;//und weitere Flugvehicle
  62.     return false;
  63. }
  64.  
  65. public OnPlayerConnect(playerid)
  66. {
  67.     SetPVarInt(playerid, "IstAngeschnallt", 0);
  68.     return 1;
  69. }
  70.  
  71. public OnVehicleDamageStatusUpdate(vehicleid, playerid)
  72. {
  73.     if(!IsPlayerInAnyVehicle(playerid)) return true;
  74.     if(InvalidVehicle(GetVehicleModel(GetPlayerVehicleID(playerid)))) return true;
  75.     new Float: vHP;
  76.     GetVehicleHealth(vehicleid, vHP);
  77.     if((AlteHP[vehicleid] - vHP) <= 50)
  78.     {
  79.         AlteHP[vehicleid] = vHP;
  80.         return true;
  81.     }
  82.     if(GetPVarInt(playerid, "IstAngeschnallt") == 0)
  83.     {
  84.         new Float:PosX, Float:PosY, Float:Angle, Float:PosZ, Float:HP, Float:nHP;
  85.         RemovePlayerFromVehicle(playerid);
  86.         GetPlayerPos(playerid, PosX, PosY, PosZ);
  87.         GetPlayerFacingAngle(playerid, Angle);
  88.         SetPlayerPos(playerid,PosX+2,PosY+2,PosZ+0.1);
  89.         GetPlayerHealth(playerid, HP);
  90.         SetPlayerHealth(playerid, HP-20);
  91.         if(GetPlayerHealth(playerid, nHP) > 0)
  92.         {
  93.             ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, ZEIT);
  94.         }
  95.         GameTextForPlayer(playerid, "~r~Du bist durch die Scheibe geflogen", 5000, 5);
  96.     }
  97.     return 1;
  98. }
  99.  
  100. public OnPlayerStateChange(playerid, newstate, oldstate)
  101. {
  102.     if(newstate == PLAYER_STATE_DRIVER)
  103.     {
  104.         if(InvalidVehicle(GetVehicleModel(GetPlayerVehicleID(playerid)))) return true;
  105.         SetPVarInt(playerid, "IstAngeschnallt", 0);
  106.         SCM(playerid, COLOR_RED, "Du bist nicht angeschnallt. Gebe /gurt [anlegen/ablegen] ein um dich an/abzuschnallen.");
  107.     }
  108.     return 1;
  109. }
  110.  
  111. /*public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  112. {
  113.     if(newkeys && KEY_ANSCHNALL)
  114.     {
  115.         if(IsPlayerInAnyVehicle(playerid))
  116.         {
  117.             if(InvalidVehicle(GetVehicleModel(GetPlayerVehicleID(playerid)))) return true;
  118.             if(GetPVarInt(playerid, "IstAngeschnallt") == 0)
  119.             {
  120.                 SCM(playerid, COLOR_GIFT, "Du hast dir den Sicherheitsgurt angelegt.");
  121.                 SetPVarInt(playerid, "IstAngeschnallt", 1);
  122.                 return 1;
  123.             }
  124.             if(GetPVarInt(playerid, "IstAngeschnallt") == 1)
  125.             {
  126.                 SCM(playerid, COLOR_GIFT, "Du hast den Sicherheitsgurt abgelegt.");
  127.                 SetPVarInt(playerid, "IstAngeschnallt", 0);
  128.                 return 1;
  129.             }
  130.         }
  131.     }
  132.     return 1;
  133. }*/
  134.  
  135. public OnPlayerCommandText(playerid, cmdtext[])
  136. {
  137.     dcmd(gurt,4,cmdtext);
  138.     return 1;
  139. }
  140.  
  141. stock n_SetVehicleHealth(car, Float:hp)
  142. {
  143.     AlteHP[car] = hp;
  144.     SetVehicleHealth(var, hp);
  145.     return 1;
  146. }
  147.  
  148. dcmd_gurt(playerid,params[])
  149. {
  150.     new xxx[50];
  151.     if(sscanf(params, "s",xxx))
  152.     {
  153.         return SendClientMessage(playerid,COLOR_RED,"HINWEIS: /gurt [anlegen/ablegen]");
  154.     }
  155.     if(!IsPlayerInAnyVehicle(playerid)) return SCM(playerid, COLOR_RED, "Du bist in keinem Fahrzeug");
  156.     if(InvalidVehicle(GetVehicleModel(GetPlayerVehicleID(playerid)))) return SCM(playerid, COLOR_RED, "Dein jetziges Vehicle hat keine Sicherheitsgurte.");
  157.     if(strcmp(xxx,"anlegen",true) == 0)
  158.     {
  159.         if(GetPVarInt(playerid, "IstAngeschnallt") == 1) { SCM(playerid, COLOR_RED, "Du bist schon angeschnallt"); return 1; }
  160.         SCM(playerid, COLOR_GIFT, "Du hast dir den Sicherheitsgurt angelegt.");
  161.         SetPVarInt(playerid, "IstAngeschnallt", 1);
  162.         return 1;
  163.     }
  164.     else if(strcmp(xxx,"ablegen",true) == 0)
  165.     {
  166.         if(GetPVarInt(playerid, "IstAngeschnallt") == 0) { SCM(playerid, COLOR_RED, "Du bist gar nicht angeschnallt"); return 1; }
  167.         SCM(playerid, COLOR_GIFT, "Du hast dir den Sicherheitsgurt abgelegt.");
  168.         SetPVarInt(playerid, "IstAngeschnallt", 0);
  169.         return 1;
  170.     }
  171.     else
  172.     {
  173.         SendClientMessage(playerid, COLOR_RED, "HINWEIS: /gurt [Aktion]. Aktionen: angelegen, ablegen");
  174.     }
  175.     return true;
  176. }
  177.  
  178. stock sscanf(string[], format[], {Float,_}:...)
  179. {
  180.     #if defined isnull
  181.         if (isnull(string))
  182.     #else
  183.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  184.     #endif
  185.         {
  186.             return format[0];
  187.         }
  188.     #pragma tabsize 4
  189.     new
  190.         formatPos = 0,
  191.         stringPos = 0,
  192.         paramPos = 2,
  193.         paramCount = numargs(),
  194.         delim = ' ';
  195.     while (string[stringPos] && string[stringPos] <= ' ')
  196.     {
  197.         stringPos++;
  198.     }
  199.     while (paramPos < paramCount && string[stringPos])
  200.     {
  201.         switch (format[formatPos++])
  202.         {
  203.             case '\0':
  204.             {
  205.                 return 0;
  206.             }
  207.             case 'i', 'd':
  208.             {
  209.                 new
  210.                     neg = 1,
  211.                     num = 0,
  212.                     ch = string[stringPos];
  213.                 if (ch == '-')
  214.                 {
  215.                     neg = -1;
  216.                     ch = string[++stringPos];
  217.                 }
  218.                 do
  219.                 {
  220.                     stringPos++;
  221.                     if ('0' <= ch <= '9')
  222.                     {
  223.                         num = (num * 10) + (ch - '0');
  224.                     }
  225.                     else
  226.                     {
  227.                         return -1;
  228.                     }
  229.                 }
  230.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  231.                 setarg(paramPos, 0, num * neg);
  232.             }
  233.             case 'h', 'x':
  234.             {
  235.                 new
  236.                     num = 0,
  237.                     ch = string[stringPos];
  238.                 do
  239.                 {
  240.                     stringPos++;
  241.                     switch (ch)
  242.                     {
  243.                         case 'x', 'X':
  244.                         {
  245.                             num = 0;
  246.                             continue;
  247.                         }
  248.                         case '0' .. '9':
  249.                         {
  250.                             num = (num << 4) | (ch - '0');
  251.                         }
  252.                         case 'a' .. 'f':
  253.                         {
  254.                             num = (num << 4) | (ch - ('a' - 10));
  255.                         }
  256.                         case 'A' .. 'F':
  257.                         {
  258.                             num = (num << 4) | (ch - ('A' - 10));
  259.                         }
  260.                         default:
  261.                         {
  262.                             return -1;
  263.                         }
  264.                     }
  265.                 }
  266.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  267.                 setarg(paramPos, 0, num);
  268.             }
  269.             case 'c':
  270.             {
  271.                 setarg(paramPos, 0, string[stringPos++]);
  272.             }
  273.             case 'f':
  274.             {
  275.  
  276.                 new changestr[16], changepos = 0, strpos = stringPos;
  277.                 while(changepos < 16 && string[strpos] && string[strpos] != delim)
  278.                 {
  279.                     changestr[changepos++] = string[strpos++];
  280.                     }
  281.                 changestr[changepos] = '\0';
  282.                 setarg(paramPos,0,_:floatstr(changestr));
  283.             }
  284.             case 'p':
  285.             {
  286.                 delim = format[formatPos++];
  287.                 continue;
  288.             }
  289.             case '\'':
  290.             {
  291.                 new
  292.                     end = formatPos - 1,
  293.                     ch;
  294.                 while ((ch = format[++end]) && ch != '\'') {}
  295.                 if (!ch)
  296.                 {
  297.                     return -1;
  298.                 }
  299.                 format[end] = '\0';
  300.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  301.                 {
  302.                     if (format[end + 1])
  303.                     {
  304.                         return -1;
  305.                     }
  306.                     return 0;
  307.                 }
  308.                 format[end] = '\'';
  309.                 stringPos = ch + (end - formatPos);
  310.                 formatPos = end + 1;
  311.             }
  312.             case 'u':
  313.             {
  314.                 new
  315.                     end = stringPos - 1,
  316.                     id = 0,
  317.                     bool:num = true,
  318.                     ch;
  319.                 while ((ch = string[++end]) && ch != delim)
  320.                 {
  321.                     if (num)
  322.                     {
  323.                         if ('0' <= ch <= '9')
  324.                         {
  325.                             id = (id * 10) + (ch - '0');
  326.                         }
  327.                         else
  328.                         {
  329.                             num = false;
  330.                         }
  331.                     }
  332.                 }
  333.                 if (num && IsPlayerConnected(id))
  334.                 {
  335.                     setarg(paramPos, 0, id);
  336.                 }
  337.                 else
  338.                 {
  339.                     #if !defined foreach
  340.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  341.                         #define __SSCANF_FOREACH__
  342.                     #endif
  343.                     string[end] = '\0';
  344.                     num = false;
  345.                     new
  346.                         name[MAX_PLAYER_NAME];
  347.                     id = end - stringPos;
  348.                     foreach (Player, playerid)
  349.                     {
  350.                         GetPlayerName(playerid, name, sizeof (name));
  351.                         if (!strcmp(name, string[stringPos], true, id))
  352.                         {
  353.                             setarg(paramPos, 0, playerid);
  354.                             num = true;
  355.                             break;
  356.                         }
  357.                     }
  358.                     if (!num)
  359.                     {
  360.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  361.                     }
  362.                     string[end] = ch;
  363.                     #if defined __SSCANF_FOREACH__
  364.                         #undef foreach
  365.                         #undef __SSCANF_FOREACH__
  366.                     #endif
  367.                 }
  368.                 stringPos = end;
  369.             }
  370.             case 's', 'z':
  371.             {
  372.                 new
  373.                     i = 0,
  374.                     ch;
  375.                 if (format[formatPos])
  376.                 {
  377.                     while ((ch = string[stringPos++]) && ch != delim)
  378.                     {
  379.                         setarg(paramPos, i++, ch);
  380.                     }
  381.                     if (!i)
  382.                     {
  383.                         return -1;
  384.                     }
  385.                 }
  386.                 else
  387.                 {
  388.                     while ((ch = string[stringPos++]))
  389.                     {
  390.                         setarg(paramPos, i++, ch);
  391.                     }
  392.                 }
  393.                 stringPos--;
  394.                 setarg(paramPos, i, '\0');
  395.             }
  396.             default:
  397.             {
  398.                 continue;
  399.             }
  400.         }
  401.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  402.         {
  403.             stringPos++;
  404.         }
  405.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  406.         {
  407.             stringPos++;
  408.         }
  409.         paramPos++;
  410.     }
  411.     do
  412.     {
  413.         if ((delim = format[formatPos++]) > ' ')
  414.         {
  415.             if (delim == '\'')
  416.             {
  417.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  418.             }
  419.             else if (delim != 'z')
  420.             {
  421.                 return delim;
  422.             }
  423.         }
  424.     }
  425.     while (delim > ' ');
  426.     return 0;
  427. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement