RdX Posted April 29, 2014 Posted April 29, 2014 السلام عليكم ورحمة الله وبركاته عندي سكربت Rainbow Car لكن انا ابيه يشتغل على الي ضغط الزر مو كلهم الحين لو ضغطت الزر كل الموجودين تتلون سيراتهم وش الحل
RdX Posted April 29, 2014 Author Posted April 29, 2014 ---ClientSide--- local rainbowSteps = { {255, 0, 0}, {255, 255, 0}, {0, 255, 0}, {0, 255, 255}, {0, 0, 255}, {255, 0, 255}, {255, 255, 255}, {0, 0, 0}, } local currentStep = 1 local timeStep = 1000 function calculateRGB() if (tick - start) >= timeStep then currentStep = currentStep + 1 if currentStep > #rainbowSteps then currentStep = 1 end start = tick return calculateRGB() else local lastStep = currentStep - 1 if currentStep == 1 then lastStep = #rainbowSteps end local progress = (tick - start) / timeStep progress = clamp(0, progress, 1) return interpolateBetween(rainbowSteps[lastStep][1], rainbowSteps[lastStep][2], rainbowSteps[lastStep][3], rainbowSteps[currentStep][1], rainbowSteps[currentStep][2], rainbowSteps[currentStep][3], progress, 'Linear') end end function clamp(mi, value, ma) return math.max(mi, math.min(ma, value)) end addEvent('onServerNoticesSettingChange', true) addEventHandler('onServerNoticesSettingChange', resourceRoot, function (speed) timeStep = speed end ) addEventHandler('onClientRender', root, function () if toggleRainbow and #streamedVehicles > 0 then for i, vehicle in ipairs(streamedVehicles) do if not isElement(vehicle) or not isElementStreamedIn(vehicle) or isVehicleBlown(vehicle) then table.remove(streamedVehicles, i) end end tick = getTickCount() if #streamedVehicles > 0 then if not start then start = tick if lastDifference then start = start + lastDifference lastDifference = false end end local r, g, b = calculateRGB() for i, vehicle in ipairs(streamedVehicles) do if isElement(vehicle) then setVehicleColor(vehicle, r, g, b, r, g, b, r, g, b, r, g, b) else table.remove(streamedVehicles, i) end end else lastDifference = (tick - start) if lastDifference > timeStep then lastDifference = tick end end end end ) function onStartRainbowCars() streamedVehicles = {} local vehicles = getElementsByType 'vehicle' if #vehicles > 0 then for i, vehicle in ipairs(vehicles) do addStreamedVehicle(vehicle) end end end function addStreamedVehicle(vehicle) if isElement(vehicle) and getElementType(vehicle) == 'vehicle' and isElementStreamedIn(vehicle) and not isVehicleListed(vehicle) and not isVehicleBlown(vehicle) then table.insert(streamedVehicles, vehicle) end end function isVehicleListed(vehicle) if #streamedVehicles > 0 then for i, veh in ipairs(streamedVehicles) do if veh == vehicle then return true end end end return false end addEventHandler('onClientGUIClick', root, function () if source == RianbowColor then onStartRainbowCars() if SkilledProRacers then addEventHandler('onClientRender', root, toggleRainbow ) else toggleRainbow = true end triggerServerEvent('onClientStartsResource', resourceRoot) end end ) ---ServerSide--- addEvent('onClientStartsResource', true) addEventHandler('onClientStartsResource', resourceRoot, function () local val = defaultSpeed if get('speed') then local ret = tonumber(get('speed')) if ret >= 50 and ret <= 1000 then val = ret end end triggerClientEvent('onServerNoticesSettingChange', resourceRoot, val * 20) end )
KaduRo Posted April 29, 2014 Posted April 29, 2014 أخوي , ممكن يحظروا حسابك بتكرار المواضيع ! كمل ردك في الموضوع القديم ولاتسوي واحد جديد !!!
ALw7sH Posted April 29, 2014 Posted April 29, 2014 ---ClientSide--- local rainbowSteps = { {255, 0, 0}, {255, 255, 0}, {0, 255, 0}, {0, 255, 255}, {0, 0, 255}, {255, 0, 255}, {255, 255, 255}, {0, 0, 0}, } local currentStep = 1 local timeStep = 1000 function calculateRGB() if (tick - start) >= timeStep then currentStep = currentStep + 1 if currentStep > #rainbowSteps then currentStep = 1 end start = tick return calculateRGB() else local lastStep = currentStep - 1 if currentStep == 1 then lastStep = #rainbowSteps end local progress = (tick - start) / timeStep progress = clamp(0, progress, 1) return interpolateBetween(rainbowSteps[lastStep][1], rainbowSteps[lastStep][2], rainbowSteps[lastStep][3], rainbowSteps[currentStep][1], rainbowSteps[currentStep][2], rainbowSteps[currentStep][3], progress, 'Linear') end end function clamp(mi, value, ma) return math.max(mi, math.min(ma, value)) end addEvent('onServerNoticesSettingChange', true) addEventHandler('onServerNoticesSettingChange', resourceRoot, function (speed) timeStep = speed end ) addEventHandler('onClientRender', root, function () if toggleRainbow and #streamedVehicles > 0 then for i, vehicle in ipairs(streamedVehicles) do if not isElement(vehicle) or not isElementStreamedIn(vehicle) or isVehicleBlown(vehicle) then table.remove(streamedVehicles, i) end end tick = getTickCount() if #streamedVehicles > 0 then if not start then start = tick if lastDifference then start = start + lastDifference lastDifference = false end end local r, g, b = calculateRGB() for i, vehicle in ipairs(streamedVehicles) do if isElement(vehicle) then setVehicleColor(vehicle, r, g, b, r, g, b, r, g, b, r, g, b) else table.remove(streamedVehicles, i) end end else lastDifference = (tick - start) if lastDifference > timeStep then lastDifference = tick end end end end ) function onStartRainbowCars() streamedVehicles = {} local vehicles = getElementsByType 'vehicle' if #vehicles > 0 then for i, vehicle in ipairs(vehicles) do addStreamedVehicle(vehicle) end end end function addStreamedVehicle(vehicle) if isElement(vehicle) and getElementType(vehicle) == 'vehicle' and isElementStreamedIn(vehicle) and not isVehicleListed(vehicle) and not isVehicleBlown(vehicle) then table.insert(streamedVehicles, vehicle) end end function isVehicleListed(vehicle) if #streamedVehicles > 0 then for i, veh in ipairs(streamedVehicles) do if veh == vehicle then return true end end end return false end addEventHandler('onClientGUIClick', root, function () if source == RianbowColor then onStartRainbowCars() if SkilledProRacers then addEventHandler('onClientRender', getLocalPlayer(), toggleRainbow ) else toggleRainbow = true end triggerServerEvent('onClientStartsResource', resourceRoot) end end )
RdX Posted April 30, 2014 Author Posted April 30, 2014 يا كلونيل انت ما سويت شيء ما صار شيء لمن اضغط البوتن السيارات كلها تتلون
#DRAGON!FIRE Posted April 30, 2014 Posted April 30, 2014 جرب الان .. : ---ClientSide--- local rainbowSteps = { {255, 0, 0}, {255, 255, 0}, {0, 255, 0}, {0, 255, 255}, {0, 0, 255}, {255, 0, 255}, {255, 255, 255}, {0, 0, 0}, } local currentStep = 1 local timeStep = 1000 function calculateRGB() if (tick - start) >= timeStep then currentStep = currentStep + 1 if currentStep > #rainbowSteps then currentStep = 1 end start = tick return calculateRGB() else local lastStep = currentStep - 1 if currentStep == 1 then lastStep = #rainbowSteps end local progress = (tick - start) / timeStep progress = clamp(0, progress, 1) return interpolateBetween(rainbowSteps[lastStep][1], rainbowSteps[lastStep][2], rainbowSteps[lastStep][3], rainbowSteps[currentStep][1], rainbowSteps[currentStep][2], rainbowSteps[currentStep][3], progress, 'Linear') end end function clamp(mi, value, ma) return math.max(mi, math.min(ma, value)) end addEvent('onServerNoticesSettingChange', true) addEventHandler('onServerNoticesSettingChange', root, function (speed) timeStep = speed end ) addEventHandler('onClientRender', root, function () if toggleRainbow and #streamedVehicles > 0 then for i, vehicle in ipairs(streamedVehicles) do if not isElement(vehicle) or not isElementStreamedIn(vehicle) or isVehicleBlown(vehicle) then table.remove(streamedVehicles, i) end end tick = getTickCount() if #streamedVehicles > 0 then if not start then start = tick if lastDifference then start = start + lastDifference lastDifference = false end end local r, g, b = calculateRGB() for i, vehicle in ipairs(streamedVehicles) do if isElement(vehicle) then setVehicleColor(vehicle, r, g, b, r, g, b, r, g, b, r, g, b) else table.remove(streamedVehicles, i) end end else lastDifference = (tick - start) if lastDifference > timeStep then lastDifference = tick end end end end ) function onStartRainbowCars() streamedVehicles = {} local vehicles = getElementsByType 'vehicle' if #vehicles > 0 then for i, vehicle in ipairs(vehicles) do addStreamedVehicle(vehicle) end end end function addStreamedVehicle(vehicle) if isElement(vehicle) and getElementType(vehicle) == 'vehicle' and isElementStreamedIn(vehicle) and not isVehicleListed(vehicle) and not isVehicleBlown(vehicle) then table.insert(streamedVehicles, vehicle) end end function isVehicleListed(vehicle) if #streamedVehicles > 0 then for i, veh in ipairs(streamedVehicles) do if veh == vehicle then return true end end end return false end addEventHandler('onClientGUIClick', root, function () if source == RianbowColor then onStartRainbowCars() if SkilledProRacers then addEventHandler('onClientRender', root, toggleRainbow ) else toggleRainbow = true end triggerServerEvent('onClientStartsResource', localPlayer) end end ) ---ServerSide--- addEvent('onClientStartsResource', true) addEventHandler('onClientStartsResource', root, function () local val = defaultSpeed if get('speed') then local ret = tonumber(get('speed')) if ret >= 50 and ret <= 1000 then val = ret end end triggerClientEvent(source, 'onServerNoticesSettingChange', root, val * 20) end )
#DRAGON!FIRE Posted April 30, 2014 Posted April 30, 2014 جرب كذا .. : ---ServerSide--- addEvent('onClientStartsResource', true) addEventHandler('onClientStartsResource', root, function () local val = defaultSpeed if get('speed') then local ret = tonumber(get('speed')) if ret >= 50 and ret <= 1000 then val = ret end end triggerClientEvent(source, 'onServerNoticesSettingChange', source, val * 20) end )
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