Sergey_Walter Posted April 25, 2013 Posted April 25, 2013 local sphere = createColSphere ( 1054.2170,-903.6371,42.5435, 5.0 ) addEventHandler("onColShapeHit", sphere, function() local theVehicle = getPedOccupiedVehicle(???) openPicker(theVehicle, "#FFFFFF", "Смена цвета") end) Помогите узнать ид элемента игрока на стороне сервера... Да и почему этот же код нельзя использовать на стороне клиента? Он попросту у меня не срабатывает..
TheNormalnij Posted April 25, 2013 Posted April 25, 2013 ВСЕ клиентские события начинаются на onClient... игрок-элемент это hitElement, только надо будет отфильтровать другие элементы и function( hitElement, matchingDimension ) в таких случаях тоже обзывается
Sergey_Walter Posted April 25, 2013 Author Posted April 25, 2013 Не очень хорошо обьяснил, ну ладно, возможно ли этот же код реализовать на стороне клиента? Так как функция openPicker находится там же... Или может сделать так? https://wiki.multitheftauto.com/wiki/OnColShapeHit
Kenix Posted April 25, 2013 Posted April 25, 2013 onClientColShapeHit/Leave вызывается не только для клиентских кулшейпов, но и для серверных тоже.
Sergey_Walter Posted April 25, 2013 Author Posted April 25, 2013 local sphere = createColSphere ( 1054.2170,-903.6371,42.5435, 5.0 ) function picker( thePlayer, matchingDimension) if getElementType ( thePlayer ) == "player" then local theVehicle = getPedOccupiedVehicle(thePlayer) openPicker(theVehicle, "#FFFFFF", "Смена цвета") end end addEventHandler ( "onColShapeHit", sphere, picker ) сделал так пишет: http://screenshot.su/show.php?img=a1387 ... b07363.jpg
Kenix Posted April 25, 2013 Posted April 25, 2013 local sphere = createColSphere ( 1054.2170,-903.6371,42.5435, 5.0 ) function picker( thePlayer, matchingDimension) if getElementType ( thePlayer ) == "player" then local theVehicle = getPedOccupiedVehicle(thePlayer) openPicker(theVehicle, "#FFFFFF", "Смена цвета") end end addEventHandler ( "onColShapeHit", sphere, picker ) сделал так пишет: http://screenshot.su/show.php?img=a1387 ... b07363.jpg Функция 'openPicker' нигде не определена.
Sergey_Walter Posted April 25, 2013 Author Posted April 25, 2013 function openPicker(id, start, title) if id and not pickerTable[id] then pickerTable[id] = colorPicker.create(id, start, title) pickerTable[id]:updateColor() return true end return false end addEvent( "openPicker", true ) addEventHandler ( "openPicker", openPicker ) local sphere = createColSphere ( 1054.2170,-903.6371,42.5435, 5.0 ) function picker() local theVehicle = getPedOccupiedVehicle(getLocalPlayer()) openPicker(theVehicle, "#FFFFFF", "Смена цвета") end addEventHandler ( "onColShapeHit", sphere, picker ) так? чёто не срабатывает всё равно( это на стороне клиента..
Kenix Posted April 25, 2013 Posted April 25, 2013 onColShapeHit это серверное событие, а не клиентское.
Sergey_Walter Posted April 25, 2013 Author Posted April 25, 2013 Возможно ли узнать цвет автомобиля через getVehicleColor ( theVehicle ) и превратить в такой код #ffffff ?
Sergey_Walter Posted April 25, 2013 Author Posted April 25, 2013 а это не оно? function hsv2rgb(h, s, v) local r, g, b local i = math.floor(h * 6) local f = h * 6 - i local p = v * (1 - s) local q = v * (1 - f * s) local t = v * (1 - (1 - f) * s) local switch = i % 6 if switch == 0 then r = v g = t b = p elseif switch == 1 then r = q g = v b = p elseif switch == 2 then r = p g = v b = t elseif switch == 3 then r = p g = q b = v elseif switch == 4 then r = t g = p b = v elseif switch == 5 then r = v g = p b = q end return math.floor(r*255), math.floor(g*255), math.floor(b*255) end function rgb2hsv(r, g, b) r, g, b = r/255, g/255, b/255 local max, min = math.max(r, g, b), math.min(r, g, b) local h, s local v = max local d = max - min s = max == 0 and 0 or d/max if max == min then h = 0 elseif max == r then h = (g - b) / d + (g < b and 6 or 0) elseif max == g then h = (b - r) / d + 2 elseif max == b then h = (r - g) / d + 4 end h = h/6 return h, s, v end
Kenix Posted April 25, 2013 Posted April 25, 2013 Нет Если вам нужен конвертер из rgb в hex, то используйте функцию выше, там также можно найти пример использования.
Sergey_Walter Posted April 25, 2013 Author Posted April 25, 2013 local color1, color2, color3, color4 = getVehicleColor ( theVehicle ) а где тут rgb? color1,color2,color3 здесь?
Kenix Posted April 25, 2013 Posted April 25, 2013 В твоём коде будут возвращены иды цветов, но тебе ведь нужны не иды цветов, а цвета в RGB формате. Если аргумент bRGB в этой функции это истина, то тогда будут возвращены 4 пары по 3 (RGB), всего 12 возвращаемых значений. local iR, iG, iB = getVehicleColor( theVehicle, true ); outputChatBox( 'RGB: ' .. iR .. ', ' .. iG .. ', ' .. iB );
Sergey_Walter Posted April 25, 2013 Author Posted April 25, 2013 exports["savevehicle-system"]:saveVehicleMods(vehicle) правда что такой экспорт не работает со стороны клиента?
Kenix Posted April 25, 2013 Posted April 25, 2013 Сделай тригер серверного события из клиента, а потом в этом событии вызывай функцию из другого ресурса. Функции для работы addEvent addEventHandler triggerServerEvent https://wiki.multitheftauto.com/wiki/Event_system
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