Leaderboard
Popular Content
Showing content with the highest reputation on 08/03/20 in all areas
-
,شرح ممتاز شكرًا لك ومن أفضل الطرق بالنسبة لي عشان تتفادى ذي المشاكل تستعمل المنطق يوم تكتب الأكواد مثلًا هنا تسأل نفسك ليه معرف المتغير بعد ماعطيت اللاعب فلوس؟ وبكذا تعرف إن المفترض تعرف القيمة قبل ماتعطيه اياها2 points
-
شرح بعض الوضائف التي تم اضافتها حديثا في لعبة MULTI THEFT AUTO: SAN os.clock() الوقت المستخدم من قبل اللعبة (CPU) تقوم هذه الوظيفة بإعادة رقم من وحدة المعالجة المركزية على سبيل المثال local x = os.clock() ---- كمتغير لحفض وقت المستخدم من الوحة المركزية (x) وضع print(string.format("elapsed time: %.2f\n",x/360 )) --- (x) طباعة في (الدي بق) قيمة المتغير --[[OUT PUT elapsed time: 23.46 ]] os.date(format [, time]]) تقوم هذه الوظيفة بإرجاع سلسة او جدول يحتوي على التاريخ و الوقت ، منسق و وفقا لتنسيق السلسلة المحددة _______________ | | | TABLE TIME | |_______________| | KEY | VALUE | |_______|______ | | hour | 23 | | min | 42 | | wday | 07 | | day | 07 | | month | 03 | | year | 2020 | | sec | 57 | | yday | 67 | |_______________| ex 1 : for k, v in pairs(os.date("!*t")) do outputConsole(k .." : ".. v) end -- OR table.foreach(os.date("*t"),print) --[[ OUTPUT hour : 22 min : 53 wday : 7 day : 7 month : 3 year : 2020 sec : 54 yday : 67 ex 2 : print("(1) ==>",os.date()) --- (2) print("(2) ==>",os.date("%d.%m.%Y")) --- (1) --[[OUT PUT : (1) ==> Sat Mar 7 23:59:53 2020 (2) ==> 07.03.2020 os.difftime(t2, t1) (t1) و (t2) تقوم هذه الوظيفة بحساب الفرق بالثواني بين ex : t1 = os.time() --- make time system with seconds -- wait a little while then type.... os.difftime(os.time(), t1) --- OUTPUT : 31 os.difftime(os.time(), t1) --- OUTPUT : 38 والسلام عليكم ورحمة الله تعالى وبركته ان شاء الله يكون واضح و مفهوم بالتوفيق (:PiS1 point
-
Hello iPollo, I remember that I helped you synchronize the serverside arrays with all clients using events. You remember those events, right? I think you have to be aware of a big problem if you want to remove items on the clientside: do all clients still have the same items defined? or does one client have more items than another? For that reason I would recommend deleting the items on the server and resynchronizing the arrays using that event that we have discovered earlier this week.1 point
-
1 point
-
1 point
-
1 point
-
1 point
-
1 point
-
1 point
-
Problema, que também afetaria as motos. Tente isso : -- Script Full factor = 0.03 --[[function createVehicles( player ) for i,v in ipairs(getElementsByType("vehicle")) do local fuel = math.random(95,100) setElementData(v, "fuel", fuel) end end--]] function processFuel ( ) for i, v in ipairs(getElementsByType("vehicle")) do if not (getElementModel(v) == 509) and not (getElementModel(v) == 481) and not (getElementModel(v) == 510) then --/> Adicione os ID que Bloqueará ! local fuel = getElementData(v, "fuel") or math.random(95,100) if getVehicleEngineState(v) and fuel > 0 then fuel = fuel - factor setElementData(v, "fuel", fuel) end if (fuel <= 0.99) then fuel = 0 setVehicleEngineState(v, false) end end end end --createVehicles() --/> Não é necessário, o timer já fez isso. setTimer(processFuel, 1000, 0)1 point
-
Great to hear that it works now Let me try to explain to you the difference between the creation function and without a 'function' header. First, let's see the facts. The creation function is called when the "onClientResourceStart" event is triggered. Your placed elements outside of a function are executed when the script is loaded. I think you have to understand that the GUI variables ("lista", etc) are only available after the creation code has been executed. If you want to convert the tutorial script to your approach without a 'function' header, you can do the following (edited your script from the top post): local vehiclesTable = { ["Sparrow"] = 469, ["Stuntplane"] = 513, ["BF-400"] = 581, ["Freeway"] = 463, ["Speeder"] = 452, ["Jester"] = 559, ["Sabre"] = 475, ["Police Ranger"] = 599, ["Utility Van"] = 552, ["Tug"] = 583 } function showVehicleSelection() if (guiGetVisible(vehList) == false) then guiSetVisible (vehList, true) showCursor (true) else guiSetVisible (vehList, false) showCursor (false) end end addCommandHandler("veh",showVehicleSelection) function populateGridlist() -- loop through the table for name,vehicle in pairs(vehiclesTable) do -- add a new row to the gridlist local row = guiGridListAddRow(lista) -- set the text in the first column to the vehicle name guiGridListSetItemText(lista,row,1,name,false,false) -- set the text in the second column to the vehicle type guiGridListSetItemText(lista,row,2,getVehicleType(vehicle),false,false) -- set the data for gridlist slot as the vehicle id guiGridListSetItemData(lista,row,1,tostring(vehicle)) end end function createVehicleHandler(button,state) if button == "left" and state == "up" then -- get the selected item in the gridlist local row,col = guiGridListGetSelectedItem(lista) -- if something is selected if row and col and row ~= -1 and col ~= -1 then -- get the vehicle id data from the gridlist that is selected local selected = guiGridListGetItemData(lista,row,col) -- make sure the vehicle id is a number not a string selected = tonumber(selected) -- get the players position and rotation local rotz = getPedRotation(getLocalPlayer()) local x,y,z = getElementPosition(getLocalPlayer()) -- find the position directly infront of the player x = x + ( math.cos ( math.rad ( rotz+90 ) ) * 3) y = y + ( math.sin ( math.rad ( rotz+90 ) ) * 3) if selected and x and y and z then -- trigger the server triggerServerEvent("createVehicleFromGUI",getRootElement(),selected,x,y,z) -- hide the gui and the cursor guiSetVisible(windowVehicleSelection,false) showCursor(false,false) else outputChatBox("Invalid arguments.") end else -- otherwise, output a message to the player outputChatBox("Please select a vehicle.") end end end -- Create the GUI here. do vehList = guiCreateWindow(0.06, 0.33, 0.31, 0.30, "Vehiculos", true) guiWindowSetSizable(vehList, false) botonCrear = guiCreateButton(149, 260, 101, 31, "Crear", false, vehList) lista = guiCreateGridList(0.06, 0.12, 0.87, 0.69, true, vehList) guiGridListAddColumn(lista, "Coches", 0.9) guiSetVisible(vehList,false) populateGridlist() addEventHandler("onClientGUIClick", botonCrear, createVehicleHandler, false) end Both ways have no significant differences in the functionality. You could say that too many event handlers pollute the event system. It is good practice to try to implement it both ways. But I usually resort to without a 'function' header in my code. Then you have to put global functions in a specific order: if function A depends on function B, then function B has to be written earlier in the code than function A. I hope that my explanation has helped you understand more of Lua and MTA1 point
-
Nope, just the way you are doing it in your example. A flat structure, because each complexity in the structure will make it more complicated to save. You can later add a next layer on top of your table, to improve searching performance, if you so desire. Finding your item? Do it how a human would do, check every item in the list until you find the right one and stop searching.1 point
-
1 point
-
.شكرا لأقتراحك و تسلم اخوي ان شاء الله بهذا المشروع ترجع اللعبة لأيامها الاولى1 point
-
1 point
-
1 point
-
1 point
