Jump to content

Attachment script does "nothing"


Einheit-101

Recommended Posts

Hello People,

As you can see I am back from the underground xD. Bad for you?

But I have a problem with this script down there. The objective is to "attach" one of the objects (2052, 2053, 2054) to the HEAD of a player (2052,53 and 54 are helmets) but if i type for example "/stahl 2" nothing happens. Thats the way it should work:

If u type "/stahl 1" element 2052 will be generated

If u type "/stahl 2" element 2053 will be generated

If u type "/stahl 3" element 2054 will be generated

If u type "/stahl 0" all elements will be destroyed.

I think the problems are the arguments, i`ve scripted not for a long time now...

  
helm = nil 
helmart = nil 
zahl = nil 
  
function stahlhelm() 
    if (zahl ~= nil or zahl ~= 0) then 
    local r = getPedRotation (getLocalPlayer) 
    local px, py, pz = getPedBonePosition(getLocalPlayer, 8) 
            if (zahl == 1) then 
                moveObject (helm, 10, px, py, pz+0.05, 0, 0, 0 ) 
                setElementRotation ( helm, 0, 0, r ) 
            end 
    end 
end 
addEventHandler ( "onClientRender", getRootElement(), stahlhelm ) 
  
addCommandHandler("stahl", function (player, command, helmart) 
if helmart ==  or helmart == nil then 
    outputChatBox ( "Valid numbers are 0,1,2 and 3." ) 
end 
  
if (helmart == 0) then 
    destroyElement(helm) 
    zahl = 0 
end 
    if (helmart == 1) then 
        local r = getPedRotation (getLocalPlayer) 
        local px, py, pz = getPedBonePosition(getLocalPlayer, 8) 
        helm = createObject (2052, px, py, pz+0.05, 0, 0, r ) -- tommy 
        zahl = 1 
    end 
    if helmart == 2 then 
        local r = getPedRotation (getLocalPlayer) 
        local px, py, pz = getPedBonePosition(getLocalPlayer, 8) 
        helm = createObject (2053, px, py, pz+0.05, 0, 0, r ) -- jerry 
        zahl = 1 
    end 
    if (helmart == 3) then 
        local r = getPedRotation (getLocalPlayer) 
        local px, py, pz = getPedBonePosition(getLocalPlayer, 8) 
        helm = createObject (2054, px, py, pz+0.05, 0, 0, r ) -- officer 
        zahl = 1 
    end 
    if (helmart > 3) then 
        outputChatBox ( "Valid numbers are 0,1,2 and 3." ) 
    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...