- #include <a_samp>
- #include <zcmd>
- new bool:Cinto[MAX_PLAYERS],
- Float:VidaCarro[MAX_PLAYERS];
- public OnPlayerConnect(playerid)
- {
- Cinto[playerid] = false;
- return 1;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid)
- {
- SendClientMessage(playerid, -1, "Coloque o cinto (/cinto)");
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- Cinto[playerid] = false;
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- if(IsPlayerInAnyVehicle(playerid) && Cinto[playerid] == false)
- {
- new Float:TempVidaCarro;
- GetVehicleHealth(GetPlayerVehicleID(playerid), TempVidaCarro);
- new Float:Difference = floatsub(VidaCarro[playerid], TempVidaCarro);
- if((floatcmp(VidaCarro[playerid], TempVidaCarro) == 1) && (floatcmp(Difference,100.0) == 1))
- {
- Difference = floatdiv(Difference, 10.0);
- new Float:VidaOld;
- GetPlayerHealth(playerid, VidaOld);
- SetPlayerHealth(playerid, floatsub(VidaOld, Difference));
- }
- VidaCarro[playerid] = TempVidaCarro;
- }
- else
- {
- VidaCarro[playerid] = 0.0;
- }
- return 1;
- }
- CMD:cinto(playerid, params[])
- {
- if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "Voce nao esta em um veiculo");
- if(Cinto[playerid] == true)
- {
- Cinto[playerid] = false;
- SendClientMessage(playerid, -1, "Voce tirou o cinto");
- }
- else if(Cinto[playerid] == false)
- {
- Cinto[playerid] = true;
- SendClientMessage(playerid, -1, "Voce colocou o cinto");
- }
- return 1;
- }