Sign in to follow this  
Followers 0
ksTakor

First person Script

9 posts in this topic

How can I make the weapon follow my crosshair in a First Person Script

Edited by

Share this post


Link to post

You can change it to a bind instead of a command i think. But if so, you have to edit the script.

Share this post


Link to post

The camera starts when i start the resource it don't have a command.

Share this post


Link to post

Okay, i haven´t tested this, but try to reset "fps.lua" with this. Then when script is started you should be able to do /fps to use firstperson. If it doesn´t work, just download the original script again or tell me the debug.

checking = 0 
carchecking = 0 
wright = false 
wleft = false 
wback = false 
function FPSStart () 
        local skin = engineLoadTXD ( "160.txd" ) -- arm skin 
        engineImportTXD ( skin, 160 ) 
        local x,y,z = getElementPosition( getLocalPlayer() ) 
        Body = createObject (991, x, y, z ) 
        setElementParent(Body, getLocalPlayer()) 
        attachElements ( Body, getLocalPlayer(), 0, -0.1, 0.45, 0, 90, 0) 
        setElementAlpha( Body, 0) 
        setElementData ( getLocalPlayer(), "blocker", Body ) 
        realskin = getElementModel(getLocalPlayer()) 
        if realskin == 160 then 
            realskin = 200 
        end 
        realvoice1, realvoice2 = getPedVoice (getLocalPlayer()) 
        setElementModel ( getLocalPlayer(), 160 ) 
        setPedVoice (getLocalPlayer(),realvoice1,realvoice2) 
        local allcars = getElementsByType ( "vehicle", getRootElement(), false) 
        for theKey,theVehicle in ipairs(allcars) do 
            setElementCollidableWith ( Body, theVehicle, false ) 
        end 
        bindKey ( "left", "both", sidewalking ) 
        bindKey ( "right", "both", sidewalking ) 
        bindKey ( "backwards", "both", sidewalking ) 
        bindKey ( "fire", "both", autoAimMode ) 
         
    end 
end 
addCommandHandler ( "fps", getRootElement(), FPSStart) 
  
function clearcars() 
    if getElementType(source) == "vehicle" then 
        setElementCollidableWith ( Body, source, false ) 
    end 
end 
addEventHandler( "onClientElementStreamIn", getRootElement(),clearcars) 
  
function invisOnSpawn() 
    realskin = getElementModel(getLocalPlayer()) 
    if realskin == 160 then 
        realskin = 200 
    end 
    realvoice1, realvoice2 = getPedVoice (getLocalPlayer()) 
    setElementModel ( getLocalPlayer(), 160 ) 
    setPedVoice (getLocalPlayer(),realvoice1,realvoice2) 
end 
addEventHandler ( "onClientPlayerSpawn", getLocalPlayer(), invisOnSpawn ) 
  
function climbcheck() 
    if isPlayerDead(getLocalPlayer())== false and getControlState("aim_weapon") == false then 
        setElementCollisionsEnabled(Body, false) 

Share this post


Link to post

Hmm, I don´t know that :/ You should ask someone else about that or wait for someone to answear here.

Share this post


Link to post

ok, but you know how to make that when i execute a command come back to third person?

Share this post


Link to post

No sry, I just helped you a bit on the way.

You need something like this, but I don´t really know how to make it in this script.

if (not isEnabled) then 
        isEnabled = true 
        addEventHandler ("onClientPreRender", root, updateCamera) 
        addEventHandler ("onClientCursorMove",root, freecamMouse) 
        radar = false 
    else --reset view 
        isEnabled = false 
        setCameraTarget (localPlayer, localPlayer) 
        removeEventHandler ("onClientPreRender", root, updateCamera) 
        removeEventHandler ("onClientCursorMove", root, freecamMouse) 
        radar = true 

Share this post


Link to post

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
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.