Sergey_Walter Posted August 3, 2013 Share Posted August 3, 2013 g_Pickups = {} g_VisiblePickups = {} function createCustomPickup() local object = createObject(2900, 155, 72, 20, 45) local parachute = createObject(2903, 155, 72, 20) setObjectScale(parachute, 0.35) attachElements(parachute, object, 0, 1.9, 1.9, -45) moveObject(object, 10000, 155, 72, 2.8 ) setTimer(function(p) if isElement(p) then detachElements(p) local x, y, z = getElementPosition(p) moveObject(p, 4000, x, y, z - 10, 0, 0, 720) setTimer(destroyElement, 2000, 1, p) end end, 10000, 1, parachute) setElementCollisionsEnabled(object, false) local colshape = createColSphere(0, 0, 0, 3.5) attachElements(colshape, object) g_Pickups[colshape] = { object = object } g_Pickups[colshape].load = true end addCommandHandler("lol", createCustomPickup) addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() engineImportTXD(engineLoadTXD("crate.txd"), 2900) engineReplaceModel(engineLoadDFF("crate.dff", 2900), 2900) g_PickupStartTick = getTickCount() end) addEventHandler("onClientElementStreamIn", getRootElement(), function() local colshape = table.find(g_Pickups, "object", source) if colshape then g_VisiblePickups[colshape] = source end end) addEventHandler("onClientElementStreamOut", getRootElement(), function() local colshape = table.find(g_VisiblePickups, source) if colshape then g_VisiblePickups[colshape] = nil end end) function updatePickups() local angle = math.fmod((getTickCount() - g_PickupStartTick) * 360 / 2000, 360) for colshape, elem in pairs(g_VisiblePickups) do if g_Pickups[colshape].load then setElementRotation(elem, 45, 0, angle)--Здесь вращается ящик end end end addEventHandler("onClientRender", getRootElement(), updatePickups) Почему не срабатывает onClientElementStreamIn? addEventHandler("onClientElementStreamIn", getRootElement(), function() local colshape = table.find(g_Pickups, "object", source) if colshape then g_VisiblePickups[colshape] = source end И что за функция table.find я её нигде раньше не встречал Link to comment
TheNormalnij Posted August 3, 2013 Share Posted August 3, 2013 Ищи что-то типо скрипта utilits.lua там обычно такое кастром выкладуется. Пример с фрирома: function table.find(t, ...) local args = { ... } if #args == 0 then for k,v in pairs(t) do if v then return k end end return false end local value = table.remove(args) if value == '[nil]' then value = nil end for k,v in pairs(t) do for i,index in ipairs(args) do if type(index) == 'function' then v = index(v) else if index == '[last]' then index = #v end v = v[index] end end if v == value then return k end end return false end onClientElementStreamIn срабатывает один раз, когда элемент начинает стримится. Это где-то 300 метров. Link to comment
Sergey_Walter Posted August 3, 2013 Author Share Posted August 3, 2013 О збс, робит терь) спасибо Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now