SA-MP Forums Archive
Need help with vehicle crash script - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need help with vehicle crash script (/showthread.php?tid=601314)



Need help with vehicle crash script - sammp - 19.02.2016

Basically, once I start driving it says I've crashed and applied the drunk anim

pawn Код:
Function:CheckSpeed(playerid)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            new Float:speed[3], vid =GetPlayerVehicleID(playerid);
            GetVehicleVelocity(vid, speed[0], speed[1], speed[2]);
            if(speed[0] < -0.4 || speed[0] > 0.4 || speed[1] < -0.4 || speed[1] > 0.4)
            {
                Crashing[playerid] = SetTimerEx("Crash", 100, 1, "i", playerid);
            }
        }
        return 1;
    }
   
    Function:Crash(playerid)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            new
                Float:speed_float,
                speed_int,
                Float:speed[3],
                vehicleid = GetPlayerVehicleID(playerid);
               
            GetVehicleVelocity(playerid, speed[0], speed[1], speed[2]);
           
            if(speed[0] > -0.1 && speed[0] < 0.1 && speed[1] > -0.1 && speed[1] < 0.1)
            {
                SetPlayerDrunkLevel(playerid, 50000);
            }
                                   
            //speed_float = floatsqroot(((speed[0]*speed[0])+(speed[1]*speed[1]))+(speed[2]*speed[2]))*95.0;
            //speed_int = floatround(speed_float, floatround_round);
        }
        return 1;
    }