HustraDev Posted October 17, 2019 Share Posted October 17, 2019 السلام عليكم ورحمة الله وباركته اخواني عندي مشكلة في سكربت جديد قاعد ابرمج فيه والسكربت عبارة عن عداد تاكسي يحسب بالامتار المشكلة اني اريد ليبل او Label يتغير وهو ليبل السعر حيث لما يوصل عداد الامتار ل 1000 متر يتغير السعر ويصير 1 دينار يعني اليبل يتغير والمشكلة التانية اني ماعرفت اسويله لووب بحيث لما يركب التاكسي بس يطلع الGUI او الواجهة الرسومية الكود : GUIEditor = { button = {}, window = {}, label = {}, memo = {} } function setUp(startedResource) if(startedResource == getThisResource()) then oX,oY,oZ = getElementPosition(getLocalPlayer()) distanceTraveled = 0 GUIEditor.window[1] = guiCreateWindow(1034, 558, 322, 166, "عداد المركبة الناقلة", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.memo[1] = guiCreateMemo(10, 25, 302, 50, "مرحبا بكم على متن هذه المركبة المتنقلة هذه المركبة \nمجهزة بعداد للمسافة وللسعر فكل الف متر نصف دينار", false, GUIEditor.window[1]) GUIEditor.label[1] = guiCreateLabel(204, 81, 108, 20, "المسافة المقطوعة :", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "default-bold-small") GUIEditor.label[2] = guiCreateLabel(204, 101, 98, 20, "سعر الرحلة :", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[2], "default-bold-small") GUIEditor.button[1] = guiCreateButton(10, 122, 86, 34, "إدفع", false, GUIEditor.window[1]) meterlable = guiCreateLabel(134, 81, 108, 20, "999999 متر", false, GUIEditor.window[1]) guiSetFont(meterlable, "default-bold-small") GUIEditor.label[4] = guiCreateLabel(129, 101, 108, 20, "999999 دينار", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[4], "default-bold-small") end end addEventHandler("onClientResourceStart",getRootElement(),setUp) function monitoring() if(isPlayerInVehicle(getLocalPlayer())) then x,y,z = getElementPosition(getLocalPlayer()) distanceTraveled = distanceTraveled + getDistanceBetweenPoints3D(x,y,z,oX,oY,oZ) guiSetText(meterlable," " .. math.floor(distanceTraveled) .. " متر") oX = x oY = y oZ = z end end addEventHandler("onClientRender",getRootElement(),monitoring) ارجو المساعدة وشكرااا Link to comment
HustraDev Posted October 18, 2019 Author Share Posted October 18, 2019 مافي اي مساعدة شباب !؟ Link to comment
SycroX Posted October 18, 2019 Share Posted October 18, 2019 طريقتي تسوي لك عداد تكسي واقعي الكود غير مجرب + لي فتره ما برمجت و كنت اتعلم لغه تانيه فممكن اكون اتلخبط او حاجه local timer = nil local dT = 0 local isAllowedVehicle = { --[ car id ] = true to be active [420] = true, } function getElementSpeed(theElement, unit) assert(isElement(theElement), "Bad argument 1 @ getElementSpeed (element expected, got " .. type(theElement) .. ")") local elementType = getElementType(theElement) assert(elementType == "player" or elementType == "ped" or elementType == "object" or elementType == "vehicle" or elementType == "projectile", "Invalid element type @ getElementSpeed (player/ped/object/vehicle/projectile expected, got " .. elementType .. ")") assert((unit == nil or type(unit) == "string" or type(unit) == "number") and (unit == nil or (tonumber(unit) and (tonumber(unit) == 0 or tonumber(unit) == 1 or tonumber(unit) == 2)) or unit == "m/s" or unit == "km/h" or unit == "mph"), "Bad argument 2 @ getElementSpeed (invalid speed unit)") unit = unit == nil and 0 or ((not tonumber(unit)) and unit or tonumber(unit)) local mult = (unit == 0 or unit == "m/s") and 50 or ((unit == 1 or unit == "km/h") and 180 or 111.84681456) return (Vector3(getElementVelocity(theElement)) * mult).length end function Traveled_Distance ( ) if isPedInVehicle ( localPlayer ) and isAllowedVehicle [ getElementModel ( getPedOccupiedVehicle ( localPlayer ) ) ] then dT = dT + getElementSpeed ( getPedOccupiedVehicle ( localPlayer ) , 0 ) guiSetText ( meterlable , " " .. math.floor(dT) .. " متر" ) else killTimer ( timer ) end end addEventHandler ( "onClientVehicleEnter" , root , function ( ) if isAllowedVehicle [ getElementModel ( source ) ] then if not isTimer ( timer ) then timer = setTimer ( Traveled_Distance , 1000 , 0 ) end end end ) Link to comment
#\_oskar_/# Posted October 18, 2019 Share Posted October 18, 2019 taple = { {km = 100 , dinar = '1'}, {km = 200 , dinar = '2'}, {km = 300 , dinar = '3'}, {km = 400 , dinar = '4'}, {km = 500 , dinar = '5'}, {km = 600 , dinar = '6'}, {km = 700 , dinar = '7'}, {km = 800 , dinar = '8'}, {km = 900 , dinar = '9'}, {km = 1000 , dinar = '10'}, {km = 1100 , dinar = '11'}, {km = 1200 , dinar = '12'}, {km = 1300 , dinar = '13'}, } local start = getTickCount() function monitoring() if(isPlayerInVehicle(getLocalPlayer())) then local now = getTickCount() speed = now - start if speed > 1000 then x,y,z = getElementPosition(getLocalPlayer()) distanceTraveled = distanceTraveled + getDistanceBetweenPoints3D(x,y,z,oX,oY,oZ) sd = math.floor(distanceTraveled) guiSetText(meterlable," " .. sd .. " متر") for k,v in ipairs (taple) do if sd > v.km then guiSetText(GUIEditor.label[4] ,v.dinar .. ' دينار ') end end oX = x oY = y oZ = z start = getTickCount() end end end addEventHandler("onClientRender",getRootElement(),monitoring) سويت لك تحقق من السعر شوف كدا اللي تقصده ولا لا ؟ 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