Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FILTERSCRIPT
- 4.
- 5.
- #include <a_samp>
- 6.
- #include <zcmd>
- 7.
- 8.
- #define COLOR_WHITE 0xFFFFFFAA
- 9.
- 10.
- 11.
- new SeatbeltStatus[MAX_PLAYERS];
- 12.
- 13.
- public OnPlayerConnect(playerid) {
- 14.
- SeatbeltStatus[playerid] = 0;
- 15.
- return 1;
- 16.
- }
- 17.
- 18.
- public OnFilterScriptInit()
- 19.
- {
- 20.
- print("\n---------------------------------------------------------");
- 21.
- print(" Seatbelt System for Roleplay. Dafuq's second Fs. ");
- 22.
- print("---------------------------------------------------------\n");
- 23.
- return 1;
- 24.
- }
- 25.
- 26.
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- 27.
- {
- 28.
- SeatbeltStatus[playerid] = 0;
- 29.
- }
- 30.
- 31.
- public OnPlayerExitVehicle(playerid, vehicleid)
- 32.
- {
- 33.
- new string[50 + MAX_PLAYER_NAME];
- 34.
- if(SeatbeltStatus[playerid] == 1)
- 35.
- {
- 36.
- format(string, sizeof(string), "* %s reaches for their seatbelt, and unbuckles it.", GetPlayerNameEx(playerid));
- 37.
- SCBubble(playerid,string,true,0xFFFF00AA,10,5000);
- 38.
- SendClientMessage(playerid, COLOR_WHITE, "You have taken off your seatbelt.");
- 39.
- }
- 40.
- return 1;
- 41.
- }
- 42.
- 43.
- 44.
- CMD:seatbelt(playerid, params[])
- 45.
- {
- 46.
- if(IsPlayerInAnyVehicle(playerid) == 0)
- 47.
- {
- 48.
- SendClientMessage(playerid, COLOR_WHITE, "You are not in a vehicle!");
- 49.
- return 1;
- 50.
- }
- 51.
- new string[50 + MAX_PLAYER_NAME];
- 52.
- if(IsPlayerInAnyVehicle(playerid) == 1 && SeatbeltStatus[playerid] == 0)
- 53.
- {
- 54.
- SeatbeltStatus[playerid] = 1;
- 55.
- if(IsAMotorBike(GetPlayerVehicleID(playerid)))
- 56.
- {
- 57.
- format(string, sizeof(string), "* %s reaches for their helmet, and puts it on.", GetPlayerNameEx(playerid));
- 58.
- SCBubble(playerid,string,true,0xFFFF00AA,10,5000);
- 59.
- SendClientMessage(playerid, COLOR_WHITE, "You have put on your helmet.");
- 60.
- }
- 61.
- else
- 62.
- {
- 63.
- format(string, sizeof(string), "* %s reaches for their seatbelt, and buckles it up.", GetPlayerNameEx(playerid));
- 64.
- SCBubble(playerid,string,true,0xFFFF00AA,10,5000);
- 65.
- SendClientMessage(playerid, COLOR_WHITE, "You have put on your seatbelt.");
- 66.
- }
- 67.
- 68.
- }
- 69.
- else if(IsPlayerInAnyVehicle(playerid) == 1 && SeatbeltStatus[playerid] == 1)
- 70.
- {
- 71.
- SeatbeltStatus[playerid] = 0;
- 72.
- if(IsAMotorBike(GetPlayerVehicleID(playerid)))
- 73.
- {
- 74.
- format(string, sizeof(string), "* %s reaches for their helmet, and takes it off.", GetPlayerNameEx(playerid));
- 75.
- SCBubble(playerid,string,true,0xFFFF00AA,10,5000);
- 76.
- SendClientMessage(playerid, COLOR_WHITE, "You have taken off your helmet.");
- 77.
- }
- 78.
- else
- 79.
- {
- 80.
- format(string, sizeof(string), "* %s reaches for their seatbelt, and unbuckles it.", GetPlayerNameEx(playerid));
- 81.
- SCBubble(playerid,string,true,0xFFFF00AA,10,5000);
- 82.
- SendClientMessage(playerid, COLOR_WHITE, "You have taken off your seatbelt.");
- 83.
- }
- 84.
- }
- 85.
- return 1;
- 86.
- }
- 87.
- 88.
- CMD:checkseatbelt(playerid, params[])
- 89.
- {
- 90.
- if(SeatbeltStatus[playerid] == 1)
- 91.
- {
- 92.
- format(string, sizeof(string), "* %s check's his seatbelt.", GetPlayerNameEx(playerid));
- 93.
- SendClientMessage(playerid, 0xFFFF00AA, "You have your seatbelt on.");
- 94.
- SendClientMessage(playerid, 0xFFFF00AA, "Have a safety ride.");
- 95.
- }
- 96.
- else
- 97.
- {
- 98.
- format(string, sizeof(string), "* %s check's his seatbelt.", GetPlayerNameEx(playerid));
- 99.
- SendClientMessage(playerid, 0xFFFF00AA, "Seems like you don't have your seatbelt on!");
- 100.
- SendClientMessage(playerid, 0xFFFF00AA, "Better but your seatbelt on before you crash a car.");
- 101.
- }
- 102.
- return 1;
- 103.
- }
- 104.
- 105.
- stock GetPlayerNameEx(playerid) {
- 106.
- 107.
- new
- 108.
- sz_playerName[MAX_PLAYER_NAME],
- 109.
- i_pos;
- 110.
- 111.
- GetPlayerName(playerid, sz_playerName, MAX_PLAYER_NAME);
- 112.
- while ((i_pos = strfind(sz_playerName, "_", false, i_pos)) != -1) sz_playerName[i_pos] = ' ';
- 113.
- return sz_playerName;
- 114.
- }
- 115.
- 116.
- 117.
- stock IsAMotorBike(carid) {
- 118.
- switch(GetVehicleModel(carid)) {
- 119.
- case 509, 510, 462, 448, 581, 522, 461, 521, 523, 463, 586, 468, 471: return 1;
- 120.
- }
- 121.
- return 0;
- 122.
- }
- 123.
- 124.
- 125.
- stock SCBubble(playerid,stringtext[],bool:selftext,color,range,time)
- 126.
- {
- 127.
- SetPlayerChatBubble(playerid,stringtext,color,range,time);
- 128.
- if(selftext)
- 129.
- {
- 130.
- if(strlen(stringtext) > 64)
- 131.
- {
- 132.
- new strings1[65];
- 133.
- strmid(strings1,stringtext,64,128);
- 134.
- strdel(stringtext,64,128);
- 135.
- format(stringtext,66,"%s-",stringtext);
- 136.
- format(strings1,66,"-%s",strings1);
- 137.
- SendClientMessage(playerid,color,stringtext);
- 138.
- SendClientMessage(playerid,color,strings1);
- 139.
- }
- 140.
- else SendClientMessage(playerid,color,stringtext);
- 141.
- }
- 142.
- return 1;
- 143.
- }
- 144.
- 145.
- new Float:CarHealth[MAX_PLAYERS];
- 146.
- public OnPlayerUpdate(playerid)
- 147.
- {
- 148.
- if(IsPlayerInAnyVehicle(playerid) == 1 && SeatbeltStatus[playerid] == 0)
- 149.
- {
- 150.
- new Float:TempCarHealth;
- 151.
- GetVehicleHealth(GetPlayerVehicleID(playerid), TempCarHealth);
- 152.
- new Float:Difference = floatsub(CarHealth[playerid], TempCarHealth);
- 153.
- if((floatcmp(CarHealth[playerid], TempCarHealth) == 1) && (floatcmp(Difference,100.0) == 1))
- 154.
- {
- 155.
- Difference = floatdiv(Difference, 10.0);
- 156.
- new Float:OldHealth;
- 157.
- GetPlayerHealth(playerid, OldHealth);
- 158.
- SetPlayerHealth(playerid, floatsub(OldHealth, Difference));
- 159.
- }
- 160.
- CarHealth[playerid] = TempCarHealth;
- 161.
- }
- 162.
- else
- 163.
- {
- 164.
- CarHealth[playerid] = 0.0;
- 165.
- }
- 166.
- return 1;
- 167.
- }
Advertisement
Add Comment
Please, Sign In to add comment