Jump to content

Set rotation speed for pickups // How?


papam77

Recommended Posts

Posted

Maybe the pickup wasn't a default one, but a custom pickup.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

How do you know it was a default pickup?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Yes, thank you ;) And this is for someone else ;)

function updatePickups() 
    local setRotationSpeed = 1000 -- in ms 
    local angle = math.fmod((getTickCount() - g_PickupStartTick) * 360 / setRotationSpeed, 360) 
    local g_Pickups = g_Pickups 
    local pickup, x, y, cX, cY, cZ, pickX, pickY, pickZ 
    for colshape,elem in pairs(g_VisiblePickups) do 
        pickup = g_Pickups[colshape] 
        if pickup.load then 
            setElementRotation(elem, 0, 0, angle) 
            if pickup.label then 
                cX, cY, cZ = getCameraMatrix() 
                pickX, pickY, pickZ = unpack(pickup.position) 
                x, y = getScreenFromWorldPosition(pickX, pickY, pickZ + 2.85, 0.08 ) 
                local distanceToPickup = getDistanceBetweenPoints3D(cX, cY, cZ, pickX, pickY, pickZ) 
                if distanceToPickup > 80 then 
                    pickup.labelInRange = false 
                    pickup.label:visible(false) 
                elseif x then 
                    if distanceToPickup < 60 then 
                        if isLineOfSightClear(cX, cY, cZ, pickX, pickY, pickZ, true, false, false, true, false) then 
                            if not pickup.labelInRange then 
                                if pickup.anim then 
                                    pickup.anim:remove() 
                                end 
                                pickup.anim = Animation.createAndPlay( 
                                    pickup.label, 
                                    Animation.presets.dxTextFadeIn(500) 
                                ) 
                                pickup.labelInRange = true 
                                pickup.labelVisible = true 
                            end 
                            if not pickup.labelVisible then 
                                pickup.label:color(255, 255, 255, 255) 
                            end 
                            pickup.label:visible(true) 
                        else 
                            pickup.label:color(255, 255, 255, 0) 
                            pickup.labelVisible = false 
                            pickup.label:visible(false) 
                        end 
                    else 
                        if pickup.labelInRange then 
                            if pickup.anim then 
                                pickup.anim:remove() 
                            end 
                            pickup.anim = Animation.createAndPlay( 
                                pickup.label, 
                                Animation.presets.dxTextFadeOut(1000) 
                            ) 
                            pickup.labelInRange = false 
                            pickup.labelVisible = false 
                            pickup.label:visible(true) 
                        end 
                    end 
                    local scale = (60/distanceToPickup)*0.7 
                    pickup.label:scale(scale) 
                    pickup.label:position(x, y, false) 
                else 
                    pickup.label:color(255, 255, 255, 0) 
                    pickup.labelVisible = false 
                    pickup.label:visible(false) 
                end 
                if Spectate.fadedout then 
                    pickup.label:visible(false) -- Hide pickup labels when screen is black 
                end 
            end 
        else 
            if pickup.label then 
                pickup.label:visible(false) 
                if pickup.labelInRange then 
                    pickup.label:color(255, 255, 255, 0) 
                    pickup.labelInRange = false 
                end 
            end 
        end 
    end 
end 
addEventHandler('onClientRender', g_Root, updatePickups) 

Posted

there are two ways, removing the angle variable and then use:

setElementRotation(elem, 0, 0, (getElementRotation(elem)+1)) 
-- play arround with +1 or +2 etc. 

But by this function the fps will have a huge effect

OR

local angle = math.fmod((getTickCount() - g_PickupStartTick) * 360 / 2000, 360) 

Change the "divided by"(/) to less like / 1000

What you did there.

Just to make it clear for everyone who is interested for making it faster.

Have fun anyways, goodluck with scripting

Sometimes I dream about cheese

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