Jump to content

NO! Handling


qaisjp

Recommended Posts

I have made a resource with a friend that detects and warns the player that he has handling modifications. I have a clean handling and I recently became aware that it also detects when going downhill. I need a bit of help in this, cos when people set their position to something high and go dropping down in a car this sometimes goes to 500kmph (Especially when I created a tram and warped my ped into it)

Code:

  
  
local playerVehicleTimer = { } 
local playerCaught = { } 
  
local maxSpeedList = { 
    160, -- Landstalker (and so on and on and on in a proper order) 
} 
function detectSpeedMod(thePlayer) 
    if isElement(thePlayer) then 
        if (playerCaught[thePlayer] == false) then 
            local theVehicle = getPedOccupiedVehicle(thePlayer) 
            if (theVehicle == false) then 
                playerCaught[thePlayer] = false 
                if (playerVehicleTimer[source] ~= false and playerVehicleTimer[source] ~= nil) then 
                    killTimer(playerVehicleTimer[thePlayer]) 
                end 
                playerVehicleTimer[thePlayer] = nil 
                return 
            end 
             
            local id = getElementModel(theVehicle) 
            local speedX, speedY, speedZ = getElementVelocity(theVehicle) 
            local actualSpeed = math.floor(((speedX ^ 2 + speedY ^ 2 + speedZ ^ 2) ^ (0.5)) * 100 * 1.61) 
             
            local i = (id - 399) 
            local percentage = math.floor(((actualSpeed * 100) / maxSpeedList[i]) - 100) 
            if (percentage >= 21) then 
                -- The player is using speedmod or has a modified handling.cfg. 
                -- We report it. 
                triggerEvent("reportToStaffLog", getRootElement(), thePlayer, "Speedmod / Modified handling", getVehicleName(theVehicle) .. " (+" .. tostring(percentage) .. "%)") 
                playerCaught[thePlayer] = true 
                return 
            end 
  
            playerVehicleTimer[thePlayer] = setTimer(detectSpeedMod, 5000, 1, thePlayer) 
        end 
    end 
end 
  

Don't worry about the calling of the function.

So how to make it detect if the player is going downhill. Could you provide me a function like isPlayerVehicleGoingDownwards()

Link to comment
  • Moderators

Maybe this ? ( uncomment the correct line ):

CODE EDITED: Use isVehicleOnGround in client-side

local playerVehicleTimer = { } 
local playerCaught = { } 
  
local maxSpeedList = { 
    160, -- Landstalker (and so on and on and on in a proper order) 
} 
function detectSpeedMod(thePlayer) 
    if isElement(thePlayer) then 
        if (playerCaught[thePlayer] == false) then 
            local theVehicle = getPedOccupiedVehicle(thePlayer) 
            if (theVehicle == false) then 
                playerCaught[thePlayer] = false 
                if (playerVehicleTimer[source] ~= false and playerVehicleTimer[source] ~= nil) then 
                    killTimer(playerVehicleTimer[thePlayer]) 
                end 
                playerVehicleTimer[thePlayer] = nil 
                return 
            end 
  
            local id = getElementModel(theVehicle) 
            local speedX, speedY, speedZ = getElementVelocity(theVehicle) 
            local actualSpeed = math.floor(((speedX ^ 2 + speedY ^ 2 + speedZ ^ 2) ^ (0.5)) * 100 * 1.61) 
            if ( not IsVehicleOnGround( theVehicle ) ) then return end 
            local i = (id - 399) 
            local percentage = math.floor(((actualSpeed * 100) / maxSpeedList[i]) - 100) 
            if (percentage >= 21) then 
                -- The player is using speedmod or has a modified handling.cfg. 
                -- We report it. 
                triggerEvent("reportToStaffLog", getRootElement(), thePlayer, "Speedmod / Modified handling", getVehicleName(theVehicle) .. " (+" .. tostring(percentage) .. "%)") 
                playerCaught[thePlayer] = true 
                return 
            end 
  
            playerVehicleTimer[thePlayer] = setTimer(detectSpeedMod, 5000, 1, thePlayer) 
        end 
    end 
end  

Edited by Guest
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...