Jump to content

Tycka

Members
  • Posts

    53
  • Joined

  • Last visited

Posts posted by Tycka

  1. Hello, for example I have function like this:

     

    function HP ( )
    setElementData(source, "HP", 100)
    end 
    addEvent( "HP", true )
    addEventHandler( "HP", getRootElement(),HP )

    How to make that after this function is used, next time it can be used after 15minutes? (For every player individually)

  2. Don't work :/

    I think I can use something like that:

    if skin == 73 then  
           attachElementToBone(helmet, source, 1, 0, 0.02, -0.53, 0, 0, 90)  
          elseif skin == 287 then  
           attachElementToBone(helmet, source, 1, 0, 0.01, -0.56, 0, 0, 90)  
          elseif skin == 286 then  
           attachElementToBone(helmet, source, 1, 0.015, 0.025, -0.54, 0, 0, 90)  
    

    But I don't know how to make it.

  3. Here is code:

    local elementBackpack = {}

    function helmetAttach (dataName,oldValue)

    local skin = getElementModel(source)

    if getElementType(source) == "player" and dataName =="helmetOn" and skin == 73 then

    local newValue = getElementData(source,dataName)

    if elementBackpack[source] then

    detachElementFromBone(elementBackpack[source])

    destroyElement(elementBackpack[source])

    elementBackpack[source] = false

    end

    local x,y,z = getElementPosition(source)

    local rx,ry,rz = getElementRotation(source)

    if newValue == 1 then

    elementBackpack[source] = createObject(902,x,y,z)

    attachElementToBone(elementBackpack[source],source,1,0.002,-0.055,-0.650,0,0,90)

    elseif newValue == 0 then

    return

    end

    end

    end

    addEventHandler ( "onElementDataChange", getRootElement(), helmetAttach )

    local elementBackpack = {}

    function helmetAttach (dataName,oldValue)

    local skin = getElementModel(source)

    if getElementType(source) == "player" and dataName =="helmetOn" and skin == 287 then

    local newValue = getElementData(source,dataName)

    if elementBackpack[source] then

    detachElementFromBone(elementBackpack[source])

    destroyElement(elementBackpack[source])

    elementBackpack[source] = false

    end

    local x,y,z = getElementPosition(source)

    local rx,ry,rz = getElementRotation(source)

    if newValue == 1 then

    elementBackpack[source] = createObject(902,x,y,z)

    attachElementToBone(elementBackpack[source],source,1,0.002,-0.055,-0.650,0,0,90)

    elseif newValue == 0 then

    return

    end

    end

    end

    addEventHandler ( "onElementDataChange", getRootElement(), helmetAttach )

    Is it possible to connect this 2 functions to one? Because when I put helm when I'm with 73 skin, I can't take it off when I with skin 287.

  4. I don't get any error/warning, and I get message You eat food name

    Here is code:

    function onPlayerSickPlus(itemName,itemInfo,data) 
        if data == "sick" then 
        if itemName == "Rotten Pizza" or itemName == "Rotten Burger" or itemName == "Rotten Milk" or itemName == "Dirty water" or itemName == "Raw Meat"  then 
        value = gameplayVariables["loseSick"] 
        end 
        setPedAnimation (source,"FOOD","EAT_Burger",nil,false,false,nil,false) 
        setElementData(source,itemName,getElementData(source,itemName)-1)  
        addPlayerStats (source,"sick",value) 
    end 
    triggerClientEvent (source, "displayClientInfo", source,"Food",shownInfos["youconsumed"].." "..itemName,22,255,0) 
    triggerClientEvent(source,"refreshInventoryManual",source) 
    end 
    addEvent("onPlayerSickPlus",true) 
    addEventHandler("onPlayerSickPlus",getRootElement(),onPlayerSickPlus) 
    

    Animation didn't start, sick didn't - and and food didn't -1.

  5. This code must voice chat do local but its didn't work voice chat still global

    local nearbyPlayers = {} 
      
    addEventHandler( 'onPlayerVoiceStart', root, 
        function() 
              local chatRadius = 10 
              local posX, posY, posZ = getElementPosition( source ) 
              local chatSphere = createColSphere( posX, posY, posZ, chatRadius ) 
              nearbyPlayers = getElementsWithinColShape( chatSphere, "player" ) 
              destroyElement( chatSphere ) 
              local empty = exports.voice:getNextEmptyChannel ( ) 
              exports.voice:setPlayerChannel(source, empty) 
               for index, player in ipairs (nearbyPlayers) do 
                      exports.voice:setPlayerChannel(player, empty) 
               end 
        end) 
         
    addEventHandler("onPlayerVoiceStop",root, 
        function() 
             exports.voice:setPlayerChannel(source) 
             for index, player in ipairs (nearbyPlayers) do 
                      exports.voice:setPlayerChannel(player) 
             end 
              nearbyPlayers = {} 
        end) 
    

  6. post your code, i think you source no is one player(Expected player at argument 1, got nil]) no exist
    function repairVehicle (veh) 
    if repairTimer[veh] then triggerClientEvent (source, "displayClientInfo", source,"Vehicle",getVehicleName(veh).." is currently being repaired!",255,22,0) return end 
    local health = math.floor(getElementHealth(veh)) 
    repairTimer[veh] = setTimer(fixVehicleDayZ,(1000-health)*120,1,veh,source)       
    setElementFrozen (veh,true) 
    setElementData(veh,"repairer",source) 
    setElementData(source,"repairingvehicle",veh) 
    setPedAnimation (source,"SCRATCHING","sclng_r",nil,true,false) 
    toggleAllControls ( source, false )  --I used player, ThePlayer and it didn't work to 
    triggerClientEvent (source, "displayClientInfo", source,"Vehicle","You started to repair "..getVehicleName(veh),22,255,0) 
    end 
    addEvent("repairVehicle",true) 
    addEventHandler("repairVehicle",getRootElement(),repairVehicle) 
    

  7. I need help with toggleAllControls, I try disable control to player when his fixing vehicle.

    I use this:

    toggleAllControls ( source, false)  
    

    But I didn't disable and I get this warning:

    Bad argument @ 'toggleAllControls' [Expected player at argument 1, got nil] 
    

  8. If you want to set alpha for all 336 code object, you can use loop. e.g:
    for index, object in ipairs(getElementsByType ("object")) do 
    if getElementModel(object) == 336 then 
    setElementAlpha(object, 255) 
    end 
    end 
    

    If not, create object with variable and try this;

    object = createObject(blablabla) 
    setElementAlpha(object, 255) 
    

    I use this:

    for index, object in ipairs(getElementsByType ("object")) do 
    if getElementModel(object) == 336 then 
    setElementAlpha(object, 255) 
    end 
    end 
    

    But when I have bat in hand I still see it.

  9.   
    local elementBackpack = {} 
    function backPackBack (dataName,oldValue) 
        if getElementType(source) == "player" and dataName =="rucksak" then 
            local newValue = getElementData(source,dataName) 
            if not #newValue or #newValue <= 0 then 
                setElementData ( source, "rucksak", { 0 } ) 
                return true 
            end 
            if not oldValue or not #oldValue then 
                oldValue = { 0 } 
            end 
            if newValue[1] == 0 then 
                if elementBackpack[source] then 
                    detachElementFromBone(elementBackpack[source]) 
                    destroyElement(elementBackpack[source]) 
                    elementBackpack[source] = false 
                end 
            elseif newValue[1] ~= oldValue[1] then 
                if elementBackpack[source] then 
                    detachElementFromBone(elementBackpack[source]) 
                    destroyElement(elementBackpack[source]) 
                    elementBackpack[source] = false 
                end 
                
                local x,y,z = getElementPosition(source) 
                local rx,ry,rz = getElementRotation(source) 
                local model = newValue[1] 
                if model == 1 then 
                    elementBackpack[source] = createObject(3026,x,y,z) 
                elseif model == 2 then 
                    elementBackpack[source] = createObject(1248,x,y,z) -- Here with backpack 
                elseif model == 3 then 
                    elementBackpack[source] = createObject(1575,x,y,z) 
                elseif model == 4 then 
                    elementBackpack[source] = createObject(1252,x,y,z) 
                elseif model == 5 then 
                    elementBackpack[source] = createObject(2405,x,y,z) 
                else 
                return false 
                end 
                if model == 3 then 
                    attachElementToBone(elementBackpack[source],source,3,0,-0.16,0.05,270,0,180) 
                else 
                    attachElementToBone(elementBackpack[source],source,3,0,-0.225,0.05,90,0,0) 
                end 
            end 
        end 
        if getElementType(source) == "player" and dataName == "helmetOn" then 
            if getElementData ( source, dataName ) then 
                local x, y, z = getElementPosition(source) 
                local helmet = createObject(2052, x, y, z) 
                setElementData ( source, "helmetObject", helmet ) 
                local skin = getElementModel ( source ) 
                if skin == 73 then 
                    attachElementToBone(helmet, source, 1, 0, 0.02, -0.53, 0, 0, 90) 
                elseif skin == 287 then 
                    attachElementToBone(helmet, source, 1, 0, 0.01, -0.56, 0, 0, 90) 
                elseif skin == 18 then 
                    attachElementToBone(helmet, source, 1, 0.015, 0.025, -0.54, 0, 0, 90) 
                elseif skin == 23 then 
                    attachElementToBone(helmet, source, 1, 0, 0.015, -0.574, 0, 0, 90) 
                elseif skin == 24 then 
                    attachElementToBone(helmet, source, 1, 0, 0.015, -0.575, 0, 0, 90) 
                elseif skin == 1 then 
                    attachElementToBone(helmet, source, 1, 0, 0.015, -0.545, 0, 0, 90) 
                elseif skin == 2 then 
                    attachElementToBone(helmet, source, 1, 0.015, 0.025, -0.59, 0, 0, 90) 
                else 
                    attachElementToBone(helmet, source, 1, 0, 0.015, -115, 0, 0, 90) 
                end 
            else 
                if isElement ( getElementData ( source, "helmetObject" ) ) then 
                    detachElementFromBone( getElementData ( source, "helmetObject" ) ) 
                    destroyElement ( getElementData ( source, "helmetObject" ) ) 
                    setElementData ( source, "helmetObject", false ) 
                end 
            end 
        end 
    end 
    addEventHandler ( "onElementDataChange", getRootElement(), backPackBack ) 
    

  10. Code:

    function moveRucksakOutOfInventory (itemName) 
        local sack = getElementData ( source, "rucksak" ) 
        if sack and sack[1] ~= 0 then 
            local x,y,z = getElementPosition(source) 
            local item,itemString = getItemTablePosition(itemName) 
            local itemPickup = createItemPickup(item,x+math.random(-1.25,1.25),y+math.random(-1.25,1.25),z,itemString,sack) 
            if elementBackpack[source] then 
                detachElementFromBone(elementBackpack[source]) 
                destroyElement(elementBackpack[source]) 
            end 
            setElementData ( source, "rucksak", { 0 } ) 
        end 
    end 
    

    Error: attempt to index global 'elementBackpack' (a nil value) (Error line: if elementBackpack[source] then)

  11. Code working but when I try drop backpack this code didint work:

    function moveRucksakOutOfInventory (itemName) 
        local sack = getElementData ( source, "rucksak" ) 
        if sack and sack[1] ~= 0 then 
            local x,y,z = getElementPosition(source) 
            local item,itemString = getItemTablePosition(itemName) 
            local itemPickup = createItemPickup(item,x+math.random(-1.25,1.25),y+math.random(-1.25,1.25),z,itemString,sack) 
            if elementBackpack[source] then 
                detachElementFromBone(elementBackpack[source]) 
                destroyElement(elementBackpack[source]) 
            end 
            setElementData ( source, "rucksak", { 0 } ) 
        end 
    end 
    

    In this line I get error:

    if elementBackpack[source] then 
    

    Error:

    attempt to index global 'elementBackpack' (a nil value)
  12. Code:

    local elementBackpack = {}

    function backPackBack (dataName,oldValue)

    if getElementType(source) == "player" and dataName =="rucksak" then

    local newValue = getElementData(source,dataName)

    if not #newValue or #newValue <= 0 then

    setElementData ( source, "rucksak", { 0 } )

    return true

    end

    if not oldValue or not #oldValue then

    oldValue = { 0 }

    end

    if newValue[1] == 0 then

    if elementBackpack[source] then

    detachElementFromBone(elementBackpack[source])

    destroyElement(elementBackpack[source])

    elementBackpack[source] = false

    end

    elseif newValue[1] ~= oldValue[1] then

    if elementBackpack[source] then

    detachElementFromBone(elementBackpack[source])

    destroyElement(elementBackpack[source])

    elementBackpack[source] = false

    end

    local x,y,z = getElementPosition(source)

    local rx,ry,rz = getElementRotation(source)

    local model = newValue[1]

    if model == 1 then

    elementBackpack[source] = createObject(3026,x,y,z)

    elseif model == 2 then

    elementBackpack[source] = createObject(1248,x,y,z)

    elseif model == 3 then

    elementBackpack[source] = createObject(1575,x,y,z)

    elseif model == 4 then

    elementBackpack[source] = createObject(1252,x,y,z)

    elseif model == 5 then

    elementBackpack[source] = createObject(2405,x,y,z)

    else

    return false

    end

    if model == 3 then

    attachElementToBone(elementBackpack[source],source,3,0,-0.16,0.05,270,0,180)

    else

    attachElementToBone(elementBackpack[source],source,3,0,-0.225,0.05,90,0,0)

    end

    end

    -- end

    if getElementType(source) == "player" and dataName == "helmetOn" then

    if getElementData ( source, dataName ) then

    local x, y, z = getElementPosition(source)

    local helmet = createObject(2052, x, y, z)

    setElementData ( source, "helmetObject", helmet )

    local skin = getElementModel ( source )

    if skin == 73 then

    attachElementToBone(helmet, source, 1, 0, 0.02, -0.53, 0, 0, 90)

    elseif skin == 287 then

    attachElementToBone(helmet, source, 1, 0, 0.01, -0.56, 0, 0, 90)

    elseif skin == 18 then

    attachElementToBone(helmet, source, 1, 0.015, 0.025, -0.54, 0, 0, 90)

    elseif skin == 23 then

    attachElementToBone(helmet, source, 1, 0, 0.015, -0.574, 0, 0, 90)

    elseif skin == 24 then

    attachElementToBone(helmet, source, 1, 0, 0.015, -0.575, 0, 0, 90)

    elseif skin == 1 then

    attachElementToBone(helmet, source, 1, 0, 0.015, -0.545, 0, 0, 90)

    elseif skin == 2 then

    attachElementToBone(helmet, source, 1, 0.015, 0.025, -0.59, 0, 0, 90)

    else

    attachElementToBone(helmet, source, 1, 0, 0.015, -115, 0, 0, 90)

    end

    else

    if isElement ( getElementData ( source, "helmetObject" ) ) then

    detachElementFromBone( getElementData ( source, "helmetObject" ) )

    destroyElement ( getElementData ( source, "helmetObject" ) )

    setElementData ( source, "helmetObject", false )

    end

    end

    end

    end

    addEventHandler ( "onElementDataChange", getRootElement(), backPackBack )

    And I get error:

     SCRIPT ERROR: [DayZ]/DayZ/survivorSystem.lua:1915: 'end' expected (to close 'function' at line 473) near '<eof>' 
    ERROR: Loading script failed: [DayZ]/DayZ/survivorSystem.lua:1915: 'end' expected (to close 'function' at line 473) near '<eof>' 
    

×
×
  • Create New...