Guest User

Untitled

a guest
Oct 7th, 2011
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 18.92 KB | None | 0 0
  1. //with love from Russia xD
  2.  
  3. #include <a_samp>
  4. #define nomerok "Car Bond" // number
  5. #define DefaultPaswword "1234" // default password
  6. forward times();
  7. forward nevidim(playerid);
  8. new
  9.     timer1, carbond, strin[25],
  10.     Apec, AHTOXA, time,
  11.     PlayerText3D:CarLabel[MAX_PLAYERS],
  12.     bool:LabelActive[MAX_PLAYERS],
  13.     Float:OldHealth[MAX_PLAYERS],
  14.     Float:OldDamage[MAX_PLAYERS],
  15.     Float:CDamage[MAX_PLAYERS],
  16.     timercar[MAX_PLAYERS],
  17.     Float:plocx,Float:plocy,Float:plocz,Float:ploca,
  18.     ship, passon = 1, pass[32], hpon,
  19.     engine,lights,alarm,doors,bonnet,boot,objective, panels, tires,
  20.     smoketimer, smoke,smoke1,smoke2,
  21.     shiptimer, boomtimer, boomertimer,bool:boomertimerOn,
  22.     vvodpass, obj[46], id;
  23.  
  24. public OnFilterScriptInit()
  25. {
  26.     print("\n--------------------------------------");
  27.     print(" Blank Filterscript by your name here");
  28.     print("--------------------------------------\n");
  29.     time = SetTimer("times", 1000, true);
  30.     carbond = AddStaticVehicle(555,-1944.19995117,265.89999390,35.90000153,90.00000000,0,0); //
  31.     obj[0] = CreateObject(3438,-1943.00000000,266.00000000,34.79999924,0.00000000,90.00000000,0.00000000); //
  32.     obj[1] = CreateObject(3440,-1948.40002441,266.00000000,32.50000000,0.00000000,0.00000000,0.00000000); //
  33.     obj[2] = CreateObject(11472,-1943.59997559,266.00000000,29.10000038,90.00000000,0.00000000,270.00000000); //
  34.     obj[3] = CreateObject(11472,-1943.59960938,266.00000000,29.10000038,90.00000000,0.00000000,242.00000000); //
  35.     obj[4] = CreateObject(11472,-1943.59960938,266.00000000,29.10000038,90.00000000,0.00000000,213.99584961); //
  36.     obj[5] = CreateObject(11472,-1943.59960938,266.00000000,29.10000038,90.00000000,0.00000000,185.99169922); //
  37.     obj[6] = CreateObject(11472,-1941.00000000,266.20001221,29.10000038,90.00000000,0.00000000,185.73559570); //
  38.     obj[7] = CreateObject(11472,-1943.59960938,266.00000000,29.10000038,90.00000000,0.00000000,298.00000000); //
  39.     obj[8] = CreateObject(11472,-1943.59960938,266.00000000,29.10000038,90.00000000,0.00000000,325.99865723); //
  40.     obj[9] = CreateObject(11472,-1943.59960938,266.00000000,29.10000038,90.00000000,0.00000000,353.74731445); //
  41.     obj[10] = CreateObject(11472,-1942.29980469,266.09960938,29.10000038,90.00000000,0.00000000,182.73754883); //
  42.     obj[11] = CreateObject(11472,-1942.30004883,265.89999390,29.10000038,90.00000000,0.00000000,357.49328613); //
  43.     obj[12] = CreateObject(11472,-1941.19995117,265.79998779,29.10000038,90.00000000,0.00000000,352.48962402); //
  44.     obj[13] = CreateObject(3440,-1946.19995117,266.00000000,34.70000076,0.00000000,90.00000000,180.25000000); //
  45.     obj[14] = CreateObject(3440,-1945.80004883,267.70001221,34.70000076,0.00000000,90.00000000,315.00000000); //
  46.     obj[15] = CreateObject(3440,-1945.80004883,264.29998779,34.70000076,0.00000000,90.00000000,45.00000000); //
  47.     obj[16] = CreateObject(1649,-1943.09997559,269.20001221,34.90000153,270.00000000,0.00000000,90.00000000); //
  48.     obj[17] = CreateObject(1649,-1943.09997559,262.79998779,34.90000153,270.00000000,0.00000000,90.00000000); //
  49.     obj[18] = CreateObject(3440,-1941.69995117,269.00000000,34.70000076,0.00000000,90.00000000,90.00000000); //
  50.     obj[19] = CreateObject(3440,-1944.80004883,268.79998779,34.70000076,0.00000000,90.00000000,90.00000000); //
  51.     obj[20] = CreateObject(3440,-1944.80004883,263.20001221,34.70000076,0.00000000,90.00000000,270.00000000); //
  52.     obj[21] = CreateObject(3440,-1941.69995117,262.89999390,34.70000076,0.00000000,90.00000000,270.00000000); //
  53.     obj[22] = CreateObject(3440,-1944.80004883,271.10000610,32.40000153,0.00000000,0.00000000,0.00000000); //
  54.     obj[23] = CreateObject(3440,-1941.59997559,271.10000610,32.40000153,0.00000000,0.00000000,0.00000000); //
  55.     obj[24] = CreateObject(3440,-1941.69995117,260.70001221,32.40000153,0.00000000,0.00000000,0.00000000); //
  56.     obj[25] = CreateObject(3440,-1944.80004883,260.89999390,32.40000153,0.00000000,0.00000000,0.00000000); //
  57.     obj[26] = CreateObject(3440,-1947.40002441,262.70001221,32.40000153,0.00000000,0.00000000,0.00000000); //
  58.     obj[27] = CreateObject(3440,-1947.40002441,269.29998779,32.40000153,0.00000000,0.00000000,0.00000000); //
  59.     obj[28] = CreateObject(1649,-1946.27001953,266.00000000,34.90000153,270.00000000,0.00000000,0.00000000); //
  60.     obj[29] = CreateObject(2707,-1945.90002441,267.79998779,35.11999893,0.00000000,179.99450684,179.99450684); //
  61.     obj[30] = CreateObject(2707,-1944.80004883,268.70001221,35.11999893,0.00000000,179.99450684,179.99450684); //
  62.     obj[31] = CreateObject(2707,-1944.80004883,263.29998779,35.11999893,0.00000000,179.99450684,179.99450684); //
  63.     obj[32] = CreateObject(2707,-1945.93005371,264.29998779,35.11999893,0.00000000,179.99450684,179.99450684); //
  64.     obj[33] = CreateObject(2707,-1946.50000000,266.01953125,35.11999893,0.00000000,179.99450684,179.99450684); //
  65.     obj[34] = CreateObject(19284,-1946.50000000,266.00000000,35.20000076,0.00000000,0.00000000,0.00000000); //
  66.     obj[35] = CreateObject(19284,-1945.90002441,267.79998779,35.20000076,0.00000000,0.00000000,0.00000000); //
  67.     obj[36] = CreateObject(19284,-1944.80004883,268.70001221,35.20000076,0.00000000,0.00000000,0.00000000); //
  68.     obj[37] = CreateObject(19284,-1944.80004883,263.29998779,35.20000076,0.00000000,0.00000000,0.00000000); //
  69.     obj[38] = CreateObject(19284,-1946.00000000,264.29998779,35.20000076,0.00000000,0.00000000,0.00000000); //
  70.     obj[39] = CreateObject(19279,-1947.40002441,262.60000610,35.09999847,0.00000000,0.00000000,312.25000000); //
  71.     obj[40] = CreateObject(19279,-1947.50000000,269.39999390,35.09999847,0.00000000,0.00000000,232.24792480); //
  72.     obj[41] = CreateObject(19279,-1944.80004883,271.20001221,35.09999847,0.00000000,0.00000000,182.24548340); //
  73.     obj[42] = CreateObject(19279,-1944.80004883,260.79998779,35.09999847,0.00000000,0.00000000,0.00000000); //
  74.     obj[43] = CreateObject(9123,-1943.19995117,266.00000000,9.50000000,0.00000000,90.00000000,0.00000000); //
  75.     obj[44] = CreateObject(9129,-1940.69995117,265.79998779,34.79999924,0.00000000,0.00000000,270.00000000); //
  76.     obj[45] = CreateObject(9129,-1940.69995117,265.79998779,32.90000153,0.00000000,0.00000000,270.00000000); //
  77.     SetVehicleNumberPlate(carbond,nomerok);
  78.     SetVehicleToRespawn(carbond);
  79.     AddVehicleComponent(carbond, 1010);
  80.     strmid(pass,DefaultPaswword,0,32);
  81.     return 1;
  82. }
  83. public OnFilterScriptExit()
  84. {
  85.     DestroyVehicle(carbond);
  86.     DestroyObject(smoke); DestroyObject(smoke1); DestroyObject(smoke2);
  87.     DestroyObject(ship);
  88.     KillTimer(time);
  89.     for(new i; i < 46; i++)
  90.     {
  91.         DestroyObject(obj[i]);
  92.     }
  93.     return 1;
  94. }
  95.  
  96. public times()// таймер не трогать
  97. {
  98.     if(shiptimer >= 1) { shiptimer -= 1;  }
  99.     if(smoketimer >= 1) { smoketimer -= 1; }
  100.     else { DestroyObject(smoke); DestroyObject(smoke1); DestroyObject(smoke2); }
  101.     if(AHTOXA >= 1) { AHTOXA -= 1; }
  102.     if(boomtimer >= 1) { boomtimer -= 1; }
  103.     if(boomertimerOn == true && boomertimer >= 1) { format(strin,sizeof(strin),"~r~Wait %d",boomertimer); GameTextForPlayer(id, strin, 1000, 4); boomertimer -= 1; }
  104.     else {
  105.     if(boomertimerOn == true) {
  106.     new Float:Coord[3]; GetVehiclePos(carbond,Coord[0],Coord[1],Coord[2]); SetVehicleToRespawn(carbond);
  107.     CreateExplosion(Coord[0],Coord[1],Coord[2],2,10); CreateExplosion(Coord[0]-5,Coord[1],Coord[2],2,10);
  108.     CreateExplosion(Coord[0]+5,Coord[1],Coord[2],2,10); CreateExplosion(Coord[0],Coord[1]-5,Coord[2],2,10);
  109.     CreateExplosion(Coord[0],Coord[1]+5,Coord[2],2,10); boomertimerOn = false;
  110.     }
  111.     }
  112.     return 0;
  113. }
  114.  
  115. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  116. {
  117.     if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return 1;
  118.     if(newkeys & 2048)
  119.     {
  120.         if(!vvodpass && passon) return SendClientMessage(playerid, 0xFFFFFFF,"functional car blocked access the menu / bond");
  121.         if(GetPlayerVehicleID(playerid) == carbond)
  122.         {
  123.             if(!shiptimer)
  124.             {
  125.                 DestroyObject(ship);
  126.                 GetVehicleZAngle(carbond,ploca);
  127.                 GetVehiclePos(carbond,plocx,plocy,plocz);
  128.                 ship = CreateObject(2899, plocx+10.0*floatsin(ploca,degrees),plocy-4.0*floatcos(ploca,degrees),plocz-0.65, 0, 0, ploca-90);
  129.                 shiptimer = 180;
  130.             }
  131.             else
  132.             {
  133.                 format(strin,sizeof(strin),"wait %d reload",shiptimer);
  134.                 SendClientMessage(playerid, 0xFFFFFFF,strin);
  135.             }
  136.         }
  137.         return 1;
  138.     }
  139.     if(newkeys & 8192)
  140.     {
  141.         if(!vvodpass && passon) return SendClientMessage(playerid, 0xFFFFFFF,"functional car blocked access the menu / bond");
  142.         if(GetPlayerVehicleID(playerid) == carbond)
  143.         {
  144.             if(!AHTOXA)
  145.             {
  146.                 AHTOXA = 120; smoketimer = 30;
  147.                 smoke = CreateObject(18715,0,0,0,0,0,0);
  148.                 smoke1 = CreateObject(18715,0,0,0,0,0,0);
  149.                 smoke2 = CreateObject(18715,0,0,0,0,0,0);
  150.                 AttachObjectToVehicle(smoke, carbond, 0, -1, -1, -90, 0, 180);
  151.                 AttachObjectToVehicle(smoke1, carbond, 0, 1, 1, -90, 0, 180);
  152.                 AttachObjectToVehicle(smoke2, carbond, 0, 2, 2, -90, 0, 180);
  153.             }
  154.             else
  155.             {
  156.                 format(strin,sizeof(strin),"wait %d reload",AHTOXA);
  157.                 SendClientMessage(playerid, 0xFFFFFFF,strin);
  158.             }
  159.         }
  160.     }
  161.     if(newkeys & 4096)
  162.     {
  163.         if(!vvodpass && passon) return SendClientMessage(playerid, 0xFFFFFFF,"functional car blocked access the menu / bond");
  164.         if(GetPlayerVehicleID(playerid) == carbond)
  165.         {
  166.             if(!boomtimer)
  167.             {
  168.                 new AHTOXA1;
  169.                 AHTOXA1 = CreateObject(18730, 0, 0, 0, 0, 0, 0);
  170.                 AttachObjectToVehicle(AHTOXA1, carbond, 0, -1, 2, -90, 0, 180);
  171.                 new Float:Cord[4];
  172.                 GetVehicleZAngle(carbond,Cord[3]);
  173.                 GetVehiclePos(carbond,Cord[0],Cord[1],Cord[2]);
  174.                 CreateExplosion(Cord[0]+10.0*floatsin(Cord[3],degrees),Cord[1]-4.0*floatcos(Cord[3],degrees),Cord[2]-0.65, 11, 10.0);
  175.                 boomtimer = 240;
  176.             }
  177.             else
  178.             {
  179.                 format(strin,sizeof(strin),"wait %d reload",boomtimer);
  180.                 SendClientMessage(playerid, 0xFFFFFFF,strin);
  181.             }
  182.         }
  183.     }
  184.     if(newkeys & 16384 && GetPlayerVehicleID(playerid) == carbond) { OnPlayerCommandText(playerid,"/bond"); }
  185.     return 1;
  186. }
  187.  
  188. public OnPlayerCommandText(playerid, cmdtext[])
  189. {
  190.     if(strcmp(cmdtext, "/bond",true) == 0)
  191.     {
  192.         if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return 1;
  193.         if(GetPlayerVehicleID(playerid) == carbond)
  194.         {
  195.             if(passon == 1 && !vvodpass)
  196.             {
  197.                 ShowPlayerDialog(playerid,3425,DIALOG_STYLE_INPUT,"Computer", "This machine is password protected","OK","Cancel");
  198.             }
  199.             else
  200.             {
  201.                 ShowPlayerDialog(playerid,3422,DIALOG_STYLE_LIST,"Computer","[1]Hiding\n[2]Change color\n[3] sensors Damage ON|OFF\n[4]fix the tire\n[5]password\n[6]self-destruction","OK","Cancel");
  202.             }
  203.         }
  204.         else return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in the car");
  205.         return 1;
  206.     }
  207.     if(strcmp(cmdtext, "/getbondcar", true) == 0)
  208.     {
  209.         if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFF, "This car is strongly Out of My League xD");
  210.         new Float:x,Float:y,Float:z;
  211.         GetPlayerPos(playerid,x,y,z);
  212.         SetVehiclePos(carbond,x,y,z);
  213.         PutPlayerInVehicle(playerid,carbond,0);
  214.         return 1;
  215.     }
  216.     if(strcmp(cmdtext, "/getpass", true) == 0)
  217.     {
  218.         if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFF, "Вы не админ");
  219.         SendClientMessage(playerid, 0xFFFFFF,"The default password is 1234");
  220.         format(strin,sizeof(strin),"password now - %s", pass);
  221.         SendClientMessage(playerid, 0xFFFFFF, strin);
  222.         return 1;
  223.     }
  224.     return false;
  225. }
  226.  
  227. public nevidim(playerid)
  228. {
  229.     if(GetVehicleSpeed() != 0)
  230.     {
  231.         LinkVehicleToInterior(carbond, 0);
  232.     }
  233.     else
  234.     {
  235.         LinkVehicleToInterior(carbond, 1);
  236.     }
  237.     return 0;
  238. }
  239. new oldcar;
  240. public OnPlayerStateChange(playerid, newstate, oldstate)
  241. {
  242.     if(newstate == PLAYER_STATE_DRIVER && GetPlayerVehicleID(playerid) == carbond)
  243.     {
  244.         for(new i = 0; i < GetMaxPlayers(); i++)
  245.         {
  246.             ShowPlayerNameTagForPlayer(i, playerid, 0);
  247.         }
  248.         oldcar = carbond;
  249.     }
  250.     if(newstate == PLAYER_STATE_ONFOOT && oldcar)
  251.     {
  252.     LinkVehicleToInterior(carbond, 0);
  253.     KillTimer(timer1);
  254.     vvodpass = 0;
  255.     oldcar = 0;
  256.     for(new i = 0; i < MAX_PLAYERS; i++)
  257.     {
  258.         ShowPlayerNameTagForPlayer(i, playerid, 1);
  259.     }
  260.     }
  261.     return 0;
  262. }
  263. public OnPlayerUpdate(playerid)
  264. {
  265.     if(hpon == 1) UpdateHP(playerid);
  266.     if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  267.     {
  268.         if(IsPlayerInRangeOfPoint(playerid, 3.0, plocx+10.0*floatsin(ploca,degrees),plocy-4.0*floatcos(ploca,degrees),plocz-0.65))
  269.         {
  270.             GetVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, lights, tires);
  271.             tires = encode_tires(1, 1, 1, 1);
  272.             UpdateVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, lights, tires);
  273.             return 0;
  274.         }
  275.     }
  276.     return 1;
  277. }
  278.  
  279. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  280. {
  281.     switch(dialogid)
  282.     {
  283.         case 3422:
  284.         {
  285.             if(response)
  286.             {
  287.                 if(GetPlayerVehicleID(playerid) != carbond) return SendClientMessage(playerid, 0xFFFFFFFF, "you are not in the car");
  288.                 if(listitem == 0)
  289.                 {
  290.                     ShowPlayerDialog(playerid,3423,DIALOG_STYLE_MSGBOX ,"Computer","disguise","ON","OFF");
  291.                 }
  292.                 if(listitem == 1)
  293.                 {
  294.                     if(Apec == 1)
  295.                     {
  296.                         ChangeVehicleColor(carbond, 0, 0);
  297.                         Apec = 0;
  298.                     }
  299.                     else
  300.                     {
  301.                         ChangeVehicleColor(carbond, 1, 1);
  302.                         Apec = 1;
  303.                     }
  304.                 }
  305.                 if(listitem == 2)
  306.                 {
  307.                     if(hpon == 0)
  308.                     {
  309.                         CarLabel[playerid] = CreatePlayer3DTextLabel(playerid," ",-1,0,0,0.9,10.0,INVALID_PLAYER_ID,carbond,1);
  310.                         UpdateBar(playerid);
  311.                         hpon = 1;
  312.                     }
  313.                     else
  314.                     {
  315.                         DeletePlayer3DTextLabel(playerid,CarLabel[playerid]);
  316.                         hpon = 0;
  317.                     }
  318.                 }
  319.                 if(listitem == 3)
  320.                 {
  321.                     new carid = GetPlayerVehicleID(playerid);
  322.                     GetVehicleDamageStatus(carid, panels, doors, lights, tires);
  323.                     tires = encode_tires(0, 0, 0, 0);
  324.                     UpdateVehicleDamageStatus(carid, panels, doors, lights, tires);
  325.                 }
  326.                 if(listitem == 4)
  327.                 {
  328.                     ShowPlayerDialog(playerid,3426,DIALOG_STYLE_LIST ,"Computer","[1]ON/OFF password\n[2]change Password","OK","cancel");
  329.                 }
  330.                 if(listitem == 5)
  331.                 {
  332.                     ShowPlayerDialog(playerid,3428,DIALOG_STYLE_INPUT ,"self-destruction","set time","OK","cancel");
  333.                 }
  334.             }
  335.         }
  336.         case 3423:
  337.         {
  338.             if(response)
  339.             {
  340.                 timer1 = SetTimer("nevidim", 2000, true);
  341.             }
  342.             else
  343.             {
  344.                 KillTimer(timer1);
  345.                 LinkVehicleToInterior(carbond, 0);
  346.             }
  347.         }
  348.         case 3424:
  349.         {
  350.             if(response)
  351.             {
  352.                 GetVehicleParamsEx(carbond,engine,lights,alarm,doors,bonnet,boot,objective);
  353.                 SetVehicleParamsEx(carbond,engine,lights,alarm,doors,bonnet,1,objective);
  354.             }
  355.             else
  356.             {
  357.                 GetVehicleParamsEx(carbond,engine,lights,alarm,doors,bonnet,boot,objective);
  358.                 SetVehicleParamsEx(carbond,engine,lights,alarm,doors,bonnet,0,objective);
  359.             }
  360.         }
  361.         case 3425:
  362.         {
  363.             if(response)
  364.             {
  365.                 if(strcmp(pass, inputtext, false, strlen(inputtext))==0 && strlen(inputtext) == strlen(pass))
  366.                 {
  367.                     vvodpass = 1;
  368.                 }
  369.                 else
  370.                 {
  371.                     ShowPlayerDialog(playerid,3425,DIALOG_STYLE_INPUT,"computer","This machine is password protected","OK","cancel");
  372.                     return 1;
  373.                 }
  374.             }
  375.             else
  376.             {
  377.                 RemovePlayerFromVehicle(playerid);
  378.             }
  379.         }
  380.         case 3426:
  381.         {
  382.             if(response)
  383.             {
  384.                 if(listitem == 0)
  385.                 {
  386.                     if(passon == 0)
  387.                     {
  388.                         passon = 1;
  389.                         SendClientMessage(playerid, 0xFFFFFF, "password protected");
  390.                     }
  391.                     else
  392.                     {
  393.                         passon = 0;
  394.                         SendClientMessage(playerid, 0xFFFFFF, "Тprotection is removed");
  395.                     }
  396.                     return 1;
  397.                 }
  398.                 if(listitem == 1)
  399.                 {
  400.                     ShowPlayerDialog(playerid,3427,DIALOG_STYLE_INPUT,"computer","enter a new password","yes","no");
  401.                     return 1;
  402.                 }
  403.             }
  404.         }
  405.         case 3427:
  406.         {
  407.             if(response)
  408.             {
  409.                 if(!strlen(inputtext)) return SendClientMessage(playerid, 0xFFFFFFFF, "no password");
  410.                 new message[61];
  411.                 strmid(pass,inputtext,0,32);
  412.                 format(message,sizeof(message),"new password - %s",inputtext);
  413.                 SendClientMessage(playerid, 0xFFFFFFFF, message);
  414.             }
  415.         }
  416.         case 3428:
  417.         {
  418.             if(response)
  419.             {
  420.                 if(boomertimerOn == true) return SendClientMessage(playerid, 0xFFFFFFFF, "timer is already running!");
  421.                 if(strval(inputtext) > 60 || strval(inputtext) < 0) return SendClientMessage(playerid, 0xFFFFFFFF, "No more than 60 and not less than 0");
  422.                 boomertimer = strval(inputtext);
  423.                 boomertimerOn = true;
  424.                 id = playerid;
  425.             }
  426.         }
  427.     }
  428.     return 0;
  429. }
  430.  
  431. stock GetVehicleSpeed()
  432. {
  433.     new Float:ST[4];
  434.     GetVehicleVelocity(carbond,ST[0],ST[1],ST[2]);
  435.     ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 150.3;
  436.     return floatround(ST[3]);
  437. }
  438.  
  439. encode_tires(tire1, tire2, tire3, tire4) return tire1 | (tire2 << 1) | (tire3 << 2) | (tire4 << 3);
  440.  
  441. public OnPlayerConnect(playerid) { LabelActive[playerid] = false; SetPlayerColor(playerid, 0xFFFFFF00); }
  442.  
  443. stock UpdateHP(playerid)
  444. {
  445.     if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return 1;
  446.     new Float:HP,veh;
  447.     veh = carbond;
  448.     GetVehicleHealth(veh, HP);
  449.     if(HP != OldHealth[playerid])
  450.     {
  451.         OldDamage[playerid]=OldHealth[playerid]-HP;
  452.         OldHealth[playerid] = HP;
  453.         if(OldDamage[playerid] > 0)
  454.         {
  455.  
  456.             new texts[128];
  457.             if(LabelActive[playerid])
  458.             {
  459.                 CDamage[playerid]+=OldDamage[playerid];
  460.                 format(texts,sizeof(texts),"{ffd800}-%.0f\n%s",CDamage[playerid],UpdateString(HP));
  461.                 KillTimer(timercar[playerid]);
  462.                 timercar[playerid] = SetTimerEx("DeleteText", 2000, 0, "i", playerid);
  463.             }
  464.             else
  465.             {
  466.                 LabelActive[playerid] = true;
  467.                 format(texts,sizeof(texts),"{ffd800}-%.0f\n%s",OldDamage[playerid],UpdateString(HP));
  468.                 timercar[playerid] = SetTimerEx("DeleteText", 2000, 0, "i", playerid);
  469.             }
  470.             UpdatePlayer3DTextLabelText(playerid, CarLabel[playerid], -1, texts);
  471.         }
  472.     }
  473.     return 1;
  474. }
  475.  
  476. stock UpdateBar(playerid)
  477. {
  478.     new Float:HP,veh;
  479.     veh = carbond;
  480.     GetVehicleHealth(veh, HP);
  481.     UpdateString(HP);
  482.     UpdatePlayer3DTextLabelText(playerid, CarLabel[playerid], -1, UpdateString(HP));
  483.     return 1;
  484. }
  485.  
  486. stock UpdateString(Float:HP)
  487. {
  488.     new str[30];
  489.     if(HP == 1000)          format(str,sizeof(str),"{00ff00}••••••••••");
  490.     else if(HP >= 900)      format(str,sizeof(str),"{66ff00}•••••••••{ffffff}•");
  491.     else if(HP >= 800)      format(str,sizeof(str),"{7fff00}••••••••{ffffff}••");
  492.     else if(HP >= 700)      format(str,sizeof(str),"{ccff00}•••••••{ffffff}•••");
  493.     else if(HP >= 600)      format(str,sizeof(str),"{f7f21a}••••••{ffffff}••••");
  494.     else if(HP >= 500)      format(str,sizeof(str),"{f4c430}•••••{ffffff}•••••");
  495.     else if(HP >= 400)      format(str,sizeof(str),"{e49b0f}••••{ffffff}••••••");
  496.     else if(HP >= 300)      format(str,sizeof(str),"{e4650e}•••{ffffff}•••••••");
  497.     else if(HP >= 250)      format(str,sizeof(str),"{ff2400}••{ffffff}••••••••");
  498.     else                    format(str,sizeof(str),"{ff2400}Boom!");
  499.     return str;
  500. }
  501.  
  502.  
  503. forward DeleteText(playerid);
  504. public DeleteText(playerid)
  505. {
  506.     KillTimer(timercar[playerid]);
  507.     LabelActive[playerid] = false;
  508.     UpdateBar(playerid);
  509.     CDamage[playerid]=0;
  510.     return 1;
  511. }
  512.  
  513.  
Advertisement
Add Comment
Please, Sign In to add comment