Guest User

Seatbelt FilterScript v1.2 eng

a guest
Jul 25th, 2010
647
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.50 KB | None | 0 0
  1. /*************************************************
  2. DEformers Team Presents:
  3. SafetyBelt v1.2 by Andy1210
  4. Xfire: andy1210
  5.  
  6. DO NOT REMOVE CREDITS
  7. If you borrow bits of code would be nice to..
  8. credit the original authors
  9.  
  10. *************************************************/
  11. #include <a_samp>
  12. #include <zcmd>
  13.  
  14. #define COLOR_CYAN 0x00FFFFAA
  15. #define COLOR_RED 0xFF0000AA
  16.  
  17. new safetybelt[MAX_PLAYERS];
  18.  
  19. public OnFilterScriptInit()
  20. {
  21.     print("\n--------------------------------------");
  22.     print(" SafetyBelt FilterScript:");
  23.     print(" by DEformers - Andy1210");
  24.     print("--------------------------------------\n");
  25.     return 1;
  26. }
  27.  
  28. public OnFilterScriptExit()
  29. {
  30.     print("\n--------------------------------------");
  31.     print(" SafetyBelt by Andy1210 UNLOADED");
  32.     print("--------------------------------------\n");
  33.     return 1;
  34. }
  35.  
  36. public OnPlayerConnect(playerid)
  37. {
  38.     return 1;
  39. }
  40.  
  41. public OnPlayerDisconnect(playerid, reason)
  42. {
  43.     return 1;
  44. }
  45.  
  46. stock GetPlayerSpeed(playerid,bool:kmh) // by misco
  47. {
  48.     new Float:Vx,Float:Vy,Float:Vz,Float:rtn;
  49.     if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),Vx,Vy,Vz); else GetPlayerVelocity(playerid,Vx,Vy,Vz);
  50.     rtn = floatsqroot(floatabs(floatpower(Vx + Vy + Vz,2)));
  51.     return kmh?floatround(rtn * 100 * 1.61):floatround(rtn * 100);
  52. }
  53.  
  54. public OnPlayerStateChange(playerid, newstate, oldstate)
  55. {
  56.     if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
  57.     {
  58.         new BikeModel = GetVehicleModel(GetPlayerVehicleID(playerid));
  59.         switch(BikeModel)
  60.         {
  61.             case 448,461,462,463,468,471,509,510,521,522,523,581,586:{
  62.             }
  63.             default:
  64.             {
  65.             safetybelt[playerid]=0;
  66.             SendClientMessage(playerid, COLOR_CYAN, "Buckle up your seatbelt ! \"/buckle\"");
  67.             SendClientMessage(playerid, COLOR_CYAN, "If you don't buckle up, when your vehicle damaged, then you will injured!");
  68.             }
  69.         }
  70.     }
  71.     else if(newstate == PLAYER_STATE_ONFOOT)
  72.     {
  73.         safetybelt[playerid]=0;
  74.     }
  75.     return 1;
  76. }
  77.  
  78. public OnVehicleDamageStatusUpdate(vehicleid,playerid)
  79. {
  80.    new Float:health;
  81.    for(new i=0;i<MAX_PLAYERS;i++)
  82.    {
  83.         if(IsPlayerConnected(i) && IsPlayerInVehicle(i,vehicleid))
  84.         {
  85.             if(safetybelt[i] == 0)
  86.             {
  87.                 if(GetPlayerSpeed(i,true) >= 60)
  88.                 {
  89.                     GetPlayerHealth(i,health);
  90.                     SetPlayerHealth(i,health-1);
  91.                 }
  92.                 if(GetPlayerSpeed(i,true) >= 75)
  93.                 {
  94.                     GetPlayerHealth(i,health);
  95.                     SetPlayerHealth(i,health-3);
  96.                 }
  97.                 if(GetPlayerSpeed(i,true) >= 85)
  98.                 {
  99.                     GetPlayerHealth(i,health);
  100.                     SetPlayerHealth(i,health-6);
  101.                 }
  102.                 if(GetPlayerSpeed(i,true) >= 100)
  103.                 {
  104.                     GetPlayerHealth(i,health);
  105.                     SetPlayerHealth(i,health-12);
  106.                 }
  107.                 if(GetPlayerSpeed(i,true) >= 160)
  108.                 {
  109.                     GetPlayerHealth(i,health);
  110.                     SetPlayerHealth(i,health-16);
  111.                 }
  112.                 if(GetPlayerSpeed(i,true) >= 180)
  113.                 {
  114.                     GetPlayerHealth(i,health);
  115.                     SetPlayerHealth(i,health-20);
  116.                 }
  117.                 if(GetPlayerSpeed(i,true) >= 200)
  118.                 {
  119.                     GetPlayerHealth(i,health);
  120.                     SetPlayerHealth(i,health-30);
  121.                 }
  122.                 if(GetPlayerSpeed(i,true) >= 220)
  123.                 {
  124.                     GetPlayerHealth(i,health);
  125.                     SetPlayerHealth(i,health-40);
  126.                 }
  127.                 if(GetPlayerSpeed(i,true) >= 250)
  128.                 {
  129.                     GetPlayerHealth(i,health);
  130.                     SetPlayerHealth(i,health-75);
  131.                 }
  132.             }
  133.         }
  134.    }
  135.    return 1;
  136. }
  137.  
  138. CMD:buckle(playerid, params[])
  139. {
  140.     if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle to use this command");
  141.  
  142.     if(IsPlayerInAnyVehicle(playerid))
  143.     {
  144.         new BikeModel = GetVehicleModel(GetPlayerVehicleID(playerid));
  145.         switch(BikeModel)
  146.         {
  147.             case 448,461,462,463,468,471,509,510,521,522,523,581,586: {
  148.             SendClientMessage(playerid, COLOR_CYAN, "This vehicle do has not seatbelt");
  149.             }
  150.             default: {
  151.             if(safetybelt[playerid] == 0)
  152.             {
  153.                 safetybelt[playerid] = 1;
  154.                 SendClientMessage(playerid, COLOR_CYAN, "You have buckled up your seatbelt");
  155.                 SendClientMessage(playerid, COLOR_CYAN, "To unbuckle seatbelt use: \"/buckle\" command");
  156.             }
  157.             else if(safetybelt[playerid] == 1)
  158.             {
  159.                 safetybelt[playerid] = 0;
  160.                 SendClientMessage(playerid, COLOR_CYAN, "You have unbuckled your seatbelt");
  161.                 SendClientMessage(playerid, COLOR_CYAN, "To buckle seatbelt use: \"/buckle\" command");
  162.             }
  163.             }
  164.         }
  165.     }
  166.     return 1;
  167. }
Advertisement
Add Comment
Please, Sign In to add comment