#Rmad~> Posted May 14, 2014 Share Posted May 14, 2014 (edited) السلام عليكم ياشباب معي كود الكولور ابيه يخلي اللون المختار لون السياراة ولما سويته واجهتني مشاكل فيه addEvent ( "onColorPickerOK" ) CCar = guiCreateButton(206, 130, 127, 56, "Color", false, x2) setElementData ( CCar, "Color", "0, 0, 255" ) addEventHandler( "onClientGUIClick", resourceRoot, function() if ( source == CCar ) then exports.cpicker:openPicker ( "Car Color", "#0000FF", "Car Color color picker" ) end end ) addEventHandler ( "onColorPickerOK", root, function ( element, hex, r, g, b ) if ( element == "Car Color" ) then local r, g, b = unpack ( split ( getElementData ( CCar, "Color" ), ", " ) ) r, g, b = tonumber ( r ), tonumber ( g ), tonumber ( b ) hex = "FF" .. ( { hex:gsub ( "#", "" ) } ) [ 1 ] local color = r .. "," .. g .. "," .. b guiSetProperty ( CCar, "NormalTextColour", hex ) setElementData ( CCar, "r", color ) setElementData ( CCar, "g", color ) setElementData ( CCar, "b", color ) triggerServerEvent("onBuy", localPlayer,r, g, b) end end ) function Buy(r,g,b) if (getPlayerMoney(source) >= 100) then takePlayerMoney(source, 100) local vehicle = getPedOccupiedVehicle(source) setVehicleColor ( vehicle, r, g, b ) else outputChatBox ("You Don't have $100",source,255,0,0) end end addEvent("onBuy",true) addEventHandler("onBuy", root, Buy) function Quit() local account = getPlayerAccount( source ) if ( account and not isGuestAccount(account)) then local r = tonumber (getElementData(source,"r")) or 0 setAccountData(account,"r",r) local g = tonumber (getElementData(source,"g")) or 0 setAccountData(account,"g",g) local b = tonumber (getElementData(source,"b")) or 0 setAccountData(account,"b",b) end addEventHandler("onPlayerQuit", root, Quit) addEventHandler( "onPlayerLogin", root, function( _,acc) local r = getAccountData(acc,"r") local g = getAccountData(acc,"g") local b = getAccountData(acc,"b") if ( r and g and b ) then local vehicle = getPedOccupiedVehicle(source) setVehicleColor ( vehicle, r, g, b ) end end) function login () local account = getPlayerAccount( source ) if ( account and not isGuestAccount(account)) then local r = getAccountData( account,"r" ) local g = getAccountData( account,"g" ) local b = getAccountData( account,"b" ) local vehicle = getPedOccupiedVehicle(source) setVehicleColor ( vehicle, r, g, b ) end end end end addEventHandler ("onPlayerPickUpRacePickup", root, login) addEventHandler ("onPlayerVehicleEnter", root, login) المشاكل الي واجهتني انه يشتري تمام بس مشكلته لاشريت مره وحده وشريت مره ثانيه يبقا نفس اللون الاول onPlayerPickUpRacePickup --bad argument got nil onPlayerVehicleEnter -- bad argument got nil وعندي طلب لو سمحتم ابيه لاحدد منطقه بالالوان مثلا وقف عند الازرق تسير السياراة زرقه وااذا قعد يلعب بالماوس جوا الكولبر تتغير معه لون السياراة واذا ظغط اوك يشتري اللون Edited May 14, 2014 by Guest Link to comment
™!>VàLéNTiNô<!™ Posted May 14, 2014 Share Posted May 14, 2014 جرب بعد عملية الشراء if getVehicleColor ( vehicle ) then return setVehicleColor( vehicle, nil ) end setVehicleColor ( vehicle , r, g, b ) Link to comment
Recommended Posts