Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*************************************************
- DEformers Team Presents:
- SafetyBelt v1.2 by Andy1210
- Email: [email protected]
- Xfire: andy1210
- DO NOT REMOVE CREDITS
- If you borrow bits of code would be nice to..
- credit the original authors
- *************************************************/
- #include <a_samp>
- #include <zcmd>
- #define COLOR_CYAN 0x00FFFFAA
- #define COLOR_RED 0xFF0000AA
- new safetybelt[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" SafetyBelt FilterScript:");
- print(" by DEformers - Andy1210");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n--------------------------------------");
- print(" SafetyBelt by Andy1210 UNLOADED");
- print("--------------------------------------\n");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- return 1;
- }
- stock GetPlayerSpeed(playerid,bool:kmh) // by misco
- {
- new Float:Vx,Float:Vy,Float:Vz,Float:rtn;
- if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),Vx,Vy,Vz); else GetPlayerVelocity(playerid,Vx,Vy,Vz);
- rtn = floatsqroot(floatabs(floatpower(Vx + Vy + Vz,2)));
- return kmh?floatround(rtn * 100 * 1.61):floatround(rtn * 100);
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
- {
- new BikeModel = GetVehicleModel(GetPlayerVehicleID(playerid));
- switch(BikeModel)
- {
- case 448,461,462,463,468,471,509,510,521,522,523,581,586:{
- }
- default:
- {
- safetybelt[playerid]=0;
- SendClientMessage(playerid, COLOR_CYAN, "Buckle up your seatbelt ! \"/buckle\"");
- SendClientMessage(playerid, COLOR_CYAN, "If you don't buckle up, when your vehicle damaged, then you will injured!");
- }
- }
- }
- else if(newstate == PLAYER_STATE_ONFOOT)
- {
- safetybelt[playerid]=0;
- }
- return 1;
- }
- public OnVehicleDamageStatusUpdate(vehicleid,playerid)
- {
- new Float:health;
- for(new i=0;i<MAX_PLAYERS;i++)
- {
- if(IsPlayerConnected(i) && IsPlayerInVehicle(i,vehicleid))
- {
- if(safetybelt[i] == 0)
- {
- if(GetPlayerSpeed(i,true) >= 60)
- {
- GetPlayerHealth(i,health);
- SetPlayerHealth(i,health-1);
- }
- if(GetPlayerSpeed(i,true) >= 75)
- {
- GetPlayerHealth(i,health);
- SetPlayerHealth(i,health-3);
- }
- if(GetPlayerSpeed(i,true) >= 85)
- {
- GetPlayerHealth(i,health);
- SetPlayerHealth(i,health-6);
- }
- if(GetPlayerSpeed(i,true) >= 100)
- {
- GetPlayerHealth(i,health);
- SetPlayerHealth(i,health-12);
- }
- if(GetPlayerSpeed(i,true) >= 160)
- {
- GetPlayerHealth(i,health);
- SetPlayerHealth(i,health-16);
- }
- if(GetPlayerSpeed(i,true) >= 180)
- {
- GetPlayerHealth(i,health);
- SetPlayerHealth(i,health-20);
- }
- if(GetPlayerSpeed(i,true) >= 200)
- {
- GetPlayerHealth(i,health);
- SetPlayerHealth(i,health-30);
- }
- if(GetPlayerSpeed(i,true) >= 220)
- {
- GetPlayerHealth(i,health);
- SetPlayerHealth(i,health-40);
- }
- if(GetPlayerSpeed(i,true) >= 250)
- {
- GetPlayerHealth(i,health);
- SetPlayerHealth(i,health-75);
- }
- }
- }
- }
- return 1;
- }
- CMD:buckle(playerid, params[])
- {
- if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle to use this command");
- if(IsPlayerInAnyVehicle(playerid))
- {
- new BikeModel = GetVehicleModel(GetPlayerVehicleID(playerid));
- switch(BikeModel)
- {
- case 448,461,462,463,468,471,509,510,521,522,523,581,586: {
- SendClientMessage(playerid, COLOR_CYAN, "This vehicle do has not seatbelt");
- }
- default: {
- if(safetybelt[playerid] == 0)
- {
- safetybelt[playerid] = 1;
- SendClientMessage(playerid, COLOR_CYAN, "You have buckled up your seatbelt");
- SendClientMessage(playerid, COLOR_CYAN, "To unbuckle seatbelt use: \"/buckle\" command");
- }
- else if(safetybelt[playerid] == 1)
- {
- safetybelt[playerid] = 0;
- SendClientMessage(playerid, COLOR_CYAN, "You have unbuckled your seatbelt");
- SendClientMessage(playerid, COLOR_CYAN, "To buckle seatbelt use: \"/buckle\" command");
- }
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment