Angepinnt Kleine-Scripting-Fragen

    • Neu

      Nevo schrieb:

      Hi, kann mir jemand vllt bei diesem Fehler helfen.
      Undzwar spawnen die Fraktionsfahrzeuge nicht und folgendert Fehler erscheint:

      Nevo schrieb:

      ERROR: ...gamemode]/.../fraktionen/adac/adac_vehicles.lua:3: attempt to call global 'createFactionVehicle' (a nil value)

      Nevo schrieb:

      Sitze hier schon seid ner Stunde und checke garnicht warum das nicht klappt:

      Vehicles.lua:

      Nevo schrieb:

      adacVehicles = {}

      adacVehicles[1] = createFactionVehicle ( 525, -2091.2998046875, -108.7001953125, 35.299999237061, 359.98352050781, 0, 270, 14, 255, 255, 0, 0 )

      Nevo schrieb:

      factionVehicles[14] = {}

      function isAdacCar ( car )
      if factionVehicles[14][car] then return true else return false end
      end

      function isAdac(player)
      if tonumber(vioGetElementData ( player, "fraktion" )) == 14 then return true else return false end
      end

      function isEmergencyOnDuty(player)

      local model = getElementModel(player)

      if isMedic (player) then
      for i=1, #factionSkins[10] do
      if factionSkins[10] == model then
      return true
      end
      end

      elseif isMechaniker (player) then
      for i=1, #factionSkins[11] do
      if factionSkins[11][i] == model then
      return true
      end
      end

      elseif isAdac (player) then
      for i=1, #factionSkins[14] do
      if factionSkins[14][i] == model then
      return true
      end
      end
      end

      return false
      end

      function isEvil(player)
      if isMafia(player) or isTriad(player) or isTerror(player) or isAztecas(player) or isBiker(player) or isBallas(player) or isGrove(player) then return true else return false end
      end

      function isEmergency(player)
      if isMedic(player) or isMechaniker(player) or isAdac(player) then return true else return false end
      end

      function isInDepotFaction(player)
      return true
      end

      function startFrespawn ( player )
      frespawnTimer[getPlayerFaction ( player )] = nil
      local frak = vioGetElementData ( player, "fraktion" )
      if frak == 1 then
      for veh, _ in pairs ( factionVehicles[frak] ) do
      if not getVehicleOccupant ( veh ) then
      respawnVehicle ( veh )
      setElementFrozen ( veh, true )
      end
      end
      elseif frak == 2 then
      for veh, _ in pairs ( factionVehicles[frak] ) do
      if not getVehicleOccupant ( veh ) and getElementDimension ( veh ) ~= diegangwardimension then
      respawnVehicle ( veh )
      setElementFrozen ( veh, true )
      end
      end
      elseif frak == 3 then
      for veh, _ in pairs ( factionVehicles[frak] ) do
      if not getVehicleOccupant ( veh ) and getElementDimension ( veh ) ~= diegangwardimension then
      respawnVehicle ( veh )
      setElementFrozen ( veh, true )
      end
      end
      elseif frak == 4 then
      for veh, _ in pairs ( factionVehicles[frak] ) do
      if not getVehicleOccupant ( veh ) then
      respawnVehicle ( veh )
      setElementFrozen ( veh, true )
      end
      end
      elseif frak == 5 then
      for veh, _ in pairs ( factionVehicles[frak] ) do
      if not getVehicleOccupant ( veh ) then
      respawnVehicle ( veh )
      setElementFrozen ( veh, true )
      end
      end
      elseif frak == 6 then
      for veh, _ in pairs ( factionVehicles[frak] ) do
      if not getVehicleOccupant ( veh ) then
      respawnVehicle ( veh )
      setElementFrozen ( veh, true )
      end
      end
      elseif frak == 7 then
      for veh, _ in pairs ( factionVehicles[frak] ) do
      if not getVehicleOccupant ( veh ) and getElementDimension ( veh ) ~= diegangwardimension then
      respawnVehicle ( veh )
      setElementFrozen ( veh, true )
      end
      end
      elseif frak == 8 then
      for veh, _ in pairs ( factionVehicles[frak] ) do
      if not getVehicleOccupant ( veh ) then
      respawnVehicle ( veh )
      setElementFrozen ( veh, true )
      end
      end
      elseif frak == 9 then
      for veh, _ in pairs ( factionVehicles[frak] ) do
      if not getVehicleOccupant ( veh ) and getElementDimension ( veh ) ~= diegangwardimension then
      respawnVehicle ( veh )
      setElementFrozen ( veh, true )
      end
      end
      elseif frak == 10 then
      for i=1, #medicVehicles do
      if not getVehicleOccupant ( medicVehicles[i] ) then
      respawnVehicle ( medicVehicles[i] )
      setElementFrozen ( medicVehicles[i], true )
      end
      end
      elseif frak == 11 then
      for i=1, #mechanikerVehicles do
      if not getVehicleOccupant ( mechanikerVehicles[i] ) then
      respawnVehicle ( mechanikerVehicles[i] )
      setElementFrozen ( mechanikerVehicles[i], true )
      end
      end
      elseif frak == 12 then
      for veh,_ in pairs (factionVehicles[12]) do
      if not getVehicleOccupant ( veh ) and getElementDimension ( veh ) ~= diegangwardimension then
      respawnVehicle ( veh )
      setElementFrozen ( veh, true )
      end
      end
      elseif frak == 13 then
      for veh, _ in pairs (factionVehicles[13]) do
      if not getVehicleOccupant ( veh ) and getElementDimension ( veh ) ~= diegangwardimension then
      respawnVehicle ( veh )
      setElementFrozen ( veh, true )
      end
      end
      elseif frak == 14 then
      for i=1, #adacVehicles do
      if not getVehicleOccupant ( adacVehicles[i] ) then
      respawnVehicle ( adacVehicles[i] )
      setElementFrozen ( adacVehicles[i], true )
      end
      end
      end
      end
    • Neu

      Sorry aber benutz einrückung so versteht man gleich besser das script

      LUA-Quellcode

      1. factionVehicles[14] = {}
      2. function isAdacCar ( car )
      3. if factionVehicles[14][car] then return true else return false end
      4. end
      5. function isAdac(player)
      6. if tonumber(vioGetElementData ( player, "fraktion" )) == 14 then return true else return false end
      7. end
      8. function isEmergencyOnDuty(player)
      9. local model = getElementModel(player)
      10. if isMedic (player) then
      11. for i=1, #factionSkins[10] do
      12. if factionSkins[10] == model then
      13. return true
      14. end
      15. end
      16. elseif isMechaniker (player) then
      17. for i=1, #factionSkins[11] do
      18. if factionSkins[11][i] == model then
      19. return true
      20. end
      21. end
      22. elseif isAdac (player) then
      23. for i=1, #factionSkins[14] do
      24. if factionSkins[14][i] == model then
      25. return true
      26. end
      27. end
      28. end
      29. return false
      30. end
      31. function isEvil(player)
      32. if isMafia(player) or isTriad(player) or isTerror(player) or isAztecas(player) or isBiker(player) or isBallas(player) or isGrove(player) then return true else return false end
      33. end
      34. function isEmergency(player)
      35. if isMedic(player) or isMechaniker(player) or isAdac(player) then return true else return false end
      36. end
      37. function isInDepotFaction(player)
      38. return true
      39. end
      40. function startFrespawn ( player )
      41. frespawnTimer[getPlayerFaction ( player )] = nil
      42. local frak = vioGetElementData ( player, "fraktion" )
      43. if frak == 1 then
      44. for veh, _ in pairs ( factionVehicles[frak] ) do
      45. if not getVehicleOccupant ( veh ) then
      46. respawnVehicle ( veh )
      47. setElementFrozen ( veh, true )
      48. end
      49. end
      50. elseif frak == 2 then
      51. for veh, _ in pairs ( factionVehicles[frak] ) do
      52. if not getVehicleOccupant ( veh ) and getElementDimension ( veh ) ~= diegangwardimension then
      53. respawnVehicle ( veh )
      54. setElementFrozen ( veh, true )
      55. end
      56. end
      57. elseif frak == 3 then
      58. for veh, _ in pairs ( factionVehicles[frak] ) do
      59. if not getVehicleOccupant ( veh ) and getElementDimension ( veh ) ~= diegangwardimension then
      60. respawnVehicle ( veh )
      61. setElementFrozen ( veh, true )
      62. end
      63. end
      64. elseif frak == 4 then
      65. for veh, _ in pairs ( factionVehicles[frak] ) do
      66. if not getVehicleOccupant ( veh ) then
      67. respawnVehicle ( veh )
      68. setElementFrozen ( veh, true )
      69. end
      70. end
      71. elseif frak == 5 then
      72. for veh, _ in pairs ( factionVehicles[frak] ) do
      73. if not getVehicleOccupant ( veh ) then
      74. respawnVehicle ( veh )
      75. setElementFrozen ( veh, true )
      76. end
      77. end
      78. elseif frak == 6 then
      79. for veh, _ in pairs ( factionVehicles[frak] ) do
      80. if not getVehicleOccupant ( veh ) then
      81. respawnVehicle ( veh )
      82. setElementFrozen ( veh, true )
      83. end
      84. end
      85. elseif frak == 7 then
      86. for veh, _ in pairs ( factionVehicles[frak] ) do
      87. if not getVehicleOccupant ( veh ) and getElementDimension ( veh ) ~= diegangwardimension then
      88. respawnVehicle ( veh )
      89. setElementFrozen ( veh, true )
      90. end
      91. end
      92. elseif frak == 8 then
      93. for veh, _ in pairs ( factionVehicles[frak] ) do
      94. if not getVehicleOccupant ( veh ) then
      95. respawnVehicle ( veh )
      96. setElementFrozen ( veh, true )
      97. end
      98. end
      99. elseif frak == 9 then
      100. for veh, _ in pairs ( factionVehicles[frak] ) do
      101. if not getVehicleOccupant ( veh ) and getElementDimension ( veh ) ~= diegangwardimension then
      102. respawnVehicle ( veh )
      103. setElementFrozen ( veh, true )
      104. end
      105. end
      106. elseif frak == 10 then
      107. for i=1, #medicVehicles do
      108. if not getVehicleOccupant ( medicVehicles[i] ) then
      109. respawnVehicle ( medicVehicles[i] )
      110. setElementFrozen ( medicVehicles[i], true )
      111. end
      112. end
      113. elseif frak == 11 then
      114. for i=1, #mechanikerVehicles do
      115. if not getVehicleOccupant ( mechanikerVehicles[i] ) then
      116. respawnVehicle ( mechanikerVehicles[i] )
      117. setElementFrozen ( mechanikerVehicles[i], true )
      118. end
      119. end
      120. elseif frak == 12 then
      121. for veh,_ in pairs (factionVehicles[12]) do
      122. if not getVehicleOccupant ( veh ) and getElementDimension ( veh ) ~= diegangwardimension then
      123. respawnVehicle ( veh )
      124. setElementFrozen ( veh, true )
      125. end
      126. end
      127. elseif frak == 13 then
      128. for veh, _ in pairs (factionVehicles[13]) do
      129. if not getVehicleOccupant ( veh ) and getElementDimension ( veh ) ~= diegangwardimension then
      130. respawnVehicle ( veh )
      131. setElementFrozen ( veh, true )
      132. end
      133. end
      134. elseif frak == 14 then
      135. for i=1, #adacVehicles do
      136. if not getVehicleOccupant ( adacVehicles[i] ) then
      137. respawnVehicle ( adacVehicles[i] )
      138. setElementFrozen ( adacVehicles[i], true )
      139. end
      140. end
      141. end
      142. end
      Alles anzeigen

      Die deutsche Sprache ist Freeware.
      Das heißt, du darfst sie uneingeschränkt nutzen. ABER(!) die deutsche Sprache ist NICHT Open Source.
      Das heißt, du darfst sie nicht nach deinen Vorstellungen verändern!

      Ein Problem ist halb gelöst, wenn es klar formuliert ist.
    • Neu

      LUA-Quellcode

      1. function createFactionVehicle ( model, x, y, z, rx, ry, rz, faction, c1, c2, c3, c4, numberplate )
      2. if not c3 then
      3. c3 = 0
      4. end
      5. if not c4 then
      6. c4 = 0
      7. end
      8. if not numberplate then
      9. numberplate = fraktionNames[faction]
      10. end
      11. local veh = createVehicle ( model, x, y, z, rx, ry, rz, numberplate )
      12. setVehicleColor ( veh, c1, c2, c3, c4 )
      13. setElementHealth ( veh, 1700 )
      14. setVehiclePaintjob ( veh, 3 )
      15. toggleVehicleRespawn ( veh, true )
      16. setVehicleRespawnDelay ( veh, FCarDestroyRespawn * 1000 * 60 )
      17. setVehicleIdleRespawnDelay ( veh, FCarIdleRespawn * 1000 * 60 )
      18. factionVehicles[faction][veh] = true
      19. vioSetElementData ( veh, "owner", fraktionNames[faction] )
      20. vioSetElementData ( veh, "ownerfraktion", faction )
      21. vioSetElementData ( veh, "sportmotor", ( faction == 10 and 3 or 2 ) )
      22. vioSetElementData ( veh, "bremse", ( faction == 10 and 3 or 2 ) )
      23. vioSetElementData ( veh, "antrieb", "awd" )
      24. setElementFrozen ( veh, true )
      25. if faction ~= 1 and faction ~= 6 and faction ~= 8 then
      26. addEventHandler ( "onVehicleStartEnter", veh, function ( player, seat, jacked )
      27. if seat == 0 and vioGetElementData ( player, "fraktion" ) ~= faction then
      28. if not jacked then
      29. cancelEvent ()
      30. end
      31. else
      32. setElementFrozen ( source, false )
      33. end
      34. end )
      35. addEventHandler ( "onVehicleEnter", veh, function ( player, seat, jacked )
      36. if seat == 0 and vioGetElementData ( player, "fraktion" ) ~= faction and jacked then
      37. setElementVelocity ( source, 0, 0, 0 )
      38. setControlState ( player, "enter_exit", false )
      39. setTimer ( removePedFromVehicle, 750, 1, player )
      40. setTimer ( setControlState, 150, 1, player, "enter_exit", false )
      41. setTimer ( setControlState, 200, 1, player, "enter_exit", true )
      42. setTimer ( setControlState, 700, 1, player, "enter_exit", false )
      43. infobox ( player, "Du bist keiner\nvon "..fraktionNames[faction].."!", 4000, 255, 0, 0 )
      44. end
      45. end )
      46. else
      47. addEventHandler ( "onVehicleStartEnter", veh, function ( player, seat, jacked )
      48. if seat == 0 and not isOnDuty ( player ) then
      49. if not jacked then
      50. cancelEvent ()
      51. end
      52. else
      53. setElementFrozen ( source, false )
      54. end
      55. end )
      56. addEventHandler ( "onVehicleEnter", veh, function ( player, seat, jacked )
      57. if seat == 0 and not isOnDuty ( player ) and jacked then
      58. setControlState ( player, "enter_exit", false )
      59. setTimer ( removePedFromVehicle, 750, 1, player )
      60. setTimer ( setControlState, 150, 1, player, "enter_exit", false )
      61. setTimer ( setControlState, 200, 1, player, "enter_exit", true )
      62. setTimer ( setControlState, 700, 1, player, "enter_exit", false )
      63. infobox ( player, "Du bist keiner\nvon "..fraktionNames[faction].."!", 4000, 255, 0, 0 )
      64. end
      65. end )
      66. end
      67. if faction == 1 then
      68. addEventHandler ( "onVehicleEnter", veh,
      69. function ( player, seat )
      70. local veh = source
      71. if not isKeyBound ( player, "sub_mission", "down", policeComputer ) then
      72. bindKey ( player, "sub_mission", "down", policeComputer )
      73. end
      74. end )
      75. elseif faction == 6 then
      76. addEventHandler ( "onVehicleEnter", veh,
      77. function ( player, seat )
      78. local veh = source
      79. if not isKeyBound ( player, "sub_mission", "down", policeComputer ) then
      80. bindKey ( player, "sub_mission", "down", policeComputer )
      81. end
      82. end )
      83. elseif faction == 8 then
      84. addEventHandler ( "onVehicleEnter", veh,
      85. function ( player, seat )
      86. local veh = source
      87. if getPedOccupiedVehicleSeat ( player ) == 0 then
      88. if not isKeyBound ( player, "sub_mission", "down", policeComputer ) and getElementModel ( veh ) ~= 520 then
      89. bindKey ( player, "sub_mission", "down", policeComputer )
      90. end
      91. if getElementModel ( veh ) == 433 then
      92. setElementHealth ( player, 100 )
      93. setPedArmor ( player, 100 )
      94. setElementHunger ( player, 100 )
      95. elseif getElementModel ( veh ) == 432 then
      96. if vioGetElementData ( player, "job" ) ~= "tankcommander" then
      97. opticExitVehicle ( player )
      98. outputChatBox ( "Du hast nicht die erforderliche Klasse!", player, 125, 0, 0 )
      99. end
      100. elseif getElementModel ( veh ) == 425 or getElementModel ( veh ) == 520 then
      101. if vioGetElementData ( player, "job" ) ~= "air" then
      102. opticExitVehicle ( player )
      103. outputChatBox ( "Du hast nicht die erforderliche Klasse!", player, 125, 0, 0 )
      104. end
      105. elseif getElementModel ( veh ) == 563 or getElementModel ( veh ) == 595 then
      106. if vioGetElementData ( player, "job" ) ~= "marine" and seat == 0 then
      107. opticExitVehicle ( player )
      108. outputChatBox ( "Du hast nicht die erforderliche Klasse!", player, 125, 0, 0 )
      109. else
      110. giveWeapon ( player, 46, 3, true )
      111. end
      112. end
      113. else
      114. if not isKeyBound ( player, "sub_mission", "down", policeComputer ) and isOnDuty( player ) then
      115. bindKey ( player, "sub_mission", "down", policeComputer )
      116. end
      117. if getElementModel ( veh ) == 433 then
      118. setElementHealth ( player, 100 )
      119. setPedArmor ( player, 100 )
      120. setElementHunger ( player, 100 )
      121. end
      122. end
      123. end )
      124. end
      125. giveSportmotorUpgrade ( veh )
      126. return veh
      127. end
      Alles anzeigen