Jump to content

arithmetic help


K4stic

Recommended Posts

Posted (edited)
  
function blablabla (hitPlayer) 
local vehicle = getPedOccupiedVehicle(hitPlayer) 
local speed = getElementSpeed(vehicle,1) 
if speed < 30 then 
  
function getElementSpeed(element,unit) 
    if (unit == nil) then unit = 0 end 
    if (isElement(element)) then 
        local x,y,z = getElementVelocity(element) 
        if (unit=="mph" or unit==1 or unit =='1') then 
            return (x^2 + y^2 + z^2) ^ 0.5 * 100 
        else 
            return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 
        end 
    else 
        return false 
    end 
end 

on first 5 lines is the one part of all code so i just no add end to this 5 lines

the error at line 5: attempt to compare boolean with number

Edited by Guest

Giving a Fuck? Nope, That isn't in My Skill Set

castie11.png

Posted (edited)

You need to add 'end's. And it's giving that error because "hitPlayer" is either not an element (but that would give the error 'Bad ped pointer' @ 'getPedOccupiedVehicle' function) or "hitPlayer" is not inside a vehicle, so you're comparing a boolean value with a number.

Edited by Guest

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted (edited)
on first 5 lines is the one part of all code so i just no add end to this 5 lines
Edited by Guest

Giving a Fuck? Nope, That isn't in My Skill Set

castie11.png

Posted

Talk in a proper english then.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

I already explained you the possible problems, it's up to you to check, I don't guess things..

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted
  
addEventHandler("onClientVehicleEnter",root, 
function ()      
addEventHandler ( "onClientRender", getRootElement(), getPlayerSpeed ) 
end 
)    
addEventHandler("onClientVehicleExit",root, 
function ()      
removeEventHandler ( "onClientRender", getRootElement(), getPlayerSpeed ) 
end 
) 
function getPlayerSpeed ( ) 
local sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) 
return (sx^2 + sy^2 + sz^2)^0.5*180 
end      
  

Now u can get the speed example :

  
if(tonumber( math.floor( getPlayerSpeed() ) ) < 30 ) then 
  

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...