qaisjp Posted April 15, 2011 Share Posted April 15, 2011 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
Kenix Posted April 15, 2011 Share Posted April 15, 2011 in my opinion it is already added to the MTA 1.1 Link to comment
Castillo Posted April 15, 2011 Share Posted April 15, 2011 I don't understand, why do you need this? MTA has it already... if you modify any data file of GTA:SA you can't join any server. Link to comment
qaisjp Posted April 15, 2011 Author Share Posted April 15, 2011 I don't only need it for handling. I need it for something else too. (The downhill thing) Link to comment
Moderators Citizen Posted April 15, 2011 Moderators Share Posted April 15, 2011 (edited) 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 April 15, 2011 by Guest Link to comment
Arran Posted April 15, 2011 Share Posted April 15, 2011 getElementRotation would be able to tell you if a vehicle is going down a hill just play around with it and see which of the X Y Z will be what when its going down hill. Link to comment
Moderators Citizen Posted April 15, 2011 Moderators Share Posted April 15, 2011 CODE EDITED: I had badly understood Link to comment
Oz. Posted April 16, 2011 Share Posted April 16, 2011 Wow the basic premise of that script looks strangely familiar... Link to comment
Castillo Posted April 16, 2011 Share Posted April 16, 2011 Well, Oz, we already know that AFS is using stolen DKR client side scripts Link to comment
qaisjp Posted April 21, 2011 Author Share Posted April 21, 2011 (edited) Thanks Citizen! Edited October 27, 2016 by qaisjp Link to comment
Castillo Posted April 22, 2011 Share Posted April 22, 2011 Well, as you know, some of AFS scripts (such as chat channel) is stolen client-side scripts from DKR. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now