Leaderboard
Popular Content
Showing content with the highest reputation on 22/03/20 in all areas
-
First you could say hi or something, we are not robots so we do have feelings and that would be greatly apreciated. Second, you didn't follow the Formatting guidelines: Your code has to be in a code block with Lua language. Third, you can't request people to make the script for you, try to do it first and if you can't make it work, please show the code you tried.2 points
-
I have a resource for this on community. https://community.multitheftauto.com/index.php?p=resources&s=details&id=180062 points
-
السلام عليكم ورحمة الله تعالى وبركاته كيفكم يا حلوين إن شاء الله طيبين ( مدري هذا راب ولا سلام ههه ) PS : أغلب اذا ما خفت اقول كل فنكشنات الدي إكس تشتغل لك في حدث أو حدثين فقط onClientRender onClientPreRender ( ما عليكم منه ما رح نحتاجه بدورة المبتدئين ) المهم نفتتح الدورة البسيطة ب فنكشنين للتصميم 1 - dxDrawText 2 - dxDrawRectangle dxDrawText الفنكشن هذا يكتب لك على شاشة اللاعب طبعا يكتب لك سترنق ( "TEST" ) لو تجي تحط فيه شي غير نوع المتغير سترنق بيطلع لك بق نشرح الحين الأرقمنتات الضرورية والثانوية bool dxDrawText ( string text, float left, float top [, float right = left, float bottom = top, int color = white, float scale = 1.0, mixed font = "default", string alignX = "left", string alignY = "top", bool clip = false, bool wordBreak = false, bool postGUI = false, bool colorCoded = false, bool subPixelPositioning = false, float fRotation = 0.0, float fRotationCenterX = 0.0, float fRotationCenterY = 0.0 ] ) text = الجملة ولا السترنق اللي تبغى تكتبه في الشاشة left = هذي يقصد فيها الإحداثيات ، لانه إحداثيات الشاشة تبدأ من فوق ويسار top = نفس الشي ، يقصد فيها الإحداثيات ، لكنها للعرض مثلا right = left : هذي تحدد لك وين بيوقف الكتابة (هو ما بيوقفها إلا إذا شغلت أرقمنت آخر بيقطع الكلام و واحد آخر يخلي كل شي متراص ويرجع السطر اذا وصل حدود الإحداثيات bottom = top : نفس الشيء ، إلا انها للعرض color : اللون التكست اللي رسمته في شاشة اللاعب ، اذا ما حطيت له لون بيكون أبيض تلقائيا ، واذا تبغى تحط له لون لازم يكون نوع RGB ( tocolor(Red,Green,Blue,Alpha) ) Red , Green , Blue : كلها أرقام متغيرة تبدأ من ال0 وتنتهي في 255 مثلا tocolor (255,255,255,255) = أبيض Alpha = هذي زي سطوع الألوان ، حتى هي تبتدإ من 0 إلى 255 0 : ما بتشوف شي 255 : سطوع كامل ههه يعني بتشوفه كويس عادي scale : سلم الكتابة ، 1 = بيكون عادي ، 1.5 بيكون أكبر من 1 font : الخط اللي بتكتب فيه ، تقدر تستعمل الخطوط الموجود داخل اللعبة واللي هي ( "default": Tahoma "default-bold": Tahoma Bold "clear": Verdana "arial": Arial "sans": Microsoft Sans Serif "pricedown": Pricedown (GTA's theme text) "bankgothic": Bank Gothic Medium "diploma": Diploma Regular "beckett": Beckett Regular واذا تبي تستعمل خط من عندك ، بتستعمل فنكشن dxCreateFont رح نتطرق للشرح بعدين =) alignX : هذي زي رصف الخط ، تعتمد أيضا على right = left فيها 3 خيارات ، إما left - center - right يعني يا تبدا الكتابة من اليسار ، ولا وسط ، ولا باليمين على حسب وش تبغى انت alignY : نفس شي ، غير أنها top - center- bottom clip : هذي مهمة شوي مقارنة بالآخرين لأن بعض الأرقمنتات اللي فوق تعتمد على هذي بالظبط واللي بعدها ، ( true - false ) هذي يا أخوان بتقطع الكلمة ولا الجملة في حدود الطول والعرض اللي حطيتها wordBreak : زي ما قلت فوق ، لكن هذي يوم يوصل التكست للحدود ، بينقز السطر اللي بعده ( true - false ) postGUI : هذي اذا تحطها true ، مهما كانت التصاميم الأخرى من صور ولا مستطيلات ولا اي شي ، رح تجي فوقهم كلهم colorCoded : هذي اذا تبي تلون التكست حقك بألوان كل كلمة هههه نفسية .. أمزح هذي غير ارقمنت color أسحبو على الآخرين .. هذوا اهم الأرقمنتات اللي يتحاجها مبرمج ك متبدأ =) مثآل : addEventHandler("onClientRender", root, funcion() dxDrawText ( "dx Tutorial by Conolel" , 0, 0 , 180, 32, tocolor(65, 65, 65, 200), 1.0, "default-bold", "left","top",true, true ,false , false ) end) هذي بتترسم فوق الشاشة باليسار فوق الشات تقريبا ، باللون الرمادي وشوي شفاف إنتهى - ___________________________________________________________________________________________________________________________ dxDrawRectangle الفنكشن هذا يرسم لك مستطيل في الشاشة ( 2D ) يعني في الشاشة فقط وليس في عالم GTA شرح الأرقمنتات : bool dxDrawRectangle ( float startX, float startY, float width, float height [, int color = white, bool postGUI = false, bool subPixelPositioning = false ] ) startX : أين راح يبتدي رسم المستطيل ( كل العادة كل رسوميات اللعبة تبتدآ من 0) اليسار startY : زي ما قلت ، لكنه للعرض ( تلاحظ أن فيه تكرار ؟ عادي الدي إكس كذا لو تعرف اشياء بسيطة تتكرر كثير وتصير تشوفها بكثرة ، وكذا تتعود على الدي إكس ويصير سهل ) يبتدإ من 0 ، فوق الشاشة width : عرض المستطيل height : إرتفاع المستقيم color : لون المستطيل , tocolor(255,255,255,255) ابيض ناصع postGUI : زي أسبقية الرسم ، يعني لو تحطها true بيكون فوق كل الرسوميات الأخرى مثآل : addEventHandler("onClientRender", root, funcion() dxDrawText ( "this is a text and below it is a rectangle " , 0, 0 , 180, 32, tocolor(65, 65, 65, 200), 1.0, "default-bold", "left","top",true, true ,false , false ) dxDrawRectangle( 0, 32, 180, 40, tocolor(255,255,255,255), false) end) PS : فيه بعض الأشياء رح يشوفها بعض الناس اللي لديهم خبرة ، بيشوفوها غلط ، لكن ضروري يتعلموا شوي أغلاط لكن تنفع معهم ، بعدين بنصحح كل شيء إن شاء الله أتمنى ان الشرح يكون أفادكم ونال إعجابكم في أمان الله1 point
-
Dear DigDim, if you restart the resource each time you update the ACL then you can just send the ACL info from server to client. server.Lua addEvent("onPlayerReady", true); addEventHandler("onPlayerReady", resourceRoot, function() local has_staff = isObjectInACLGroup ( "user." ..getAccountName(getPlayerAccount(client)), aclGetGroup ("Staff")); triggerClientEvent(client, "onClientReceivePermissions", resourceRoot, has_staff); end, false ); client.Lua local has_got_perms = false; local is_staff = false; function FomeRepeat() if is_staff then if getElementData ( localPlayer, "afkdate" ) == true then return end if getElementData ( localPlayer, "Fome:Logado" ) == true then Fome = getElementData ( localPlayer, "AirNew:Fome" ) -1 SetarFome = setElementData ( localPlayer, "AirNew:Fome", Fome ) if Fome <= 0 then setElementData ( localPlayer, "AirNew:Fome", 10 ) setElementHealth ( localPlayer, 0 ) outputChatBox ( "[ Fome ] - Você Morreu de Fome", 255, 255, 255, true ) outputChatBox ( "[ Fome ] - Vá Até uma Lanchonete e Coma Algo, ou Você Vai Morrer Novamente", 255, 255, 255, true ) end if Fome == 5 then outputChatBox ( "[ Fome ] - Você Esta com Fome e Precisa Comer", 255, 255, 255, true ) outputChatBox ( "[ Fome ] - Vá Até uma Lanchonete e Coma Algo, ou Você Vai Morrer de Fome", 255, 255, 255, true ) playSoundFrontEnd ( 45 ) end end end end addEvent("onClientReceivePermissions", true); addEventHandler("onClientReceivePermissions", resourceRoot, function(_is_staff) has_got_perms = true; is_staff = _is_staff; outputDebugString( "received client permissions (is_staff: " .. tostring(_is_staff) .. ")" ); setTimer(FomeRepeat,FomeTempo,0) end, false ); triggerServerEvent("onPlayerReady", resourceRoot);1 point
-
Sure, the easiest way to check for location change is the onClientRender event in combination with the getZoneName function. Here is a small example. local last_zone = false; local function on_zone_change(zone_name) -- TODO: new zone is in the "zone_name" variable. -- do something here to change the weather. end local function get_relevant_position() local cam_target = getCameraTarget(); if (cam_target) then return getElementPosition(cam_target); end return getElementPosition(getCamera()); end addEventHandler("onClientRender", root, function() local px, py, pz = get_relevant_position(); local cur_zone = getZoneName(px, py, pz); if not (last_zone) or not (last_zone == cur_zone) then on_zone_change(cur_zone); last_zone = cur_zone; end end ); This code does use the position of the camera target or of the camera, depending on what makes most sense.1 point
-
Vc está em viagem junto com o corona vírus... parabéns mesmo heim.1 point
-
Dear slapztea, your problem sounds very similar to a question that has been asked before: Other than that, if you want to define custom zones then just use colshape rectangles with the onClientColShapeHit event.1 point
-
Yes, yes, yes and yes. The game provides the starting value, which is always true. But you cannot rely on any value because there are other scripts that may modify the value.1 point
-
Glad to help you! By the way, nice toilet roll avatar. I think it fits very much into today's times1 point
-
local function setFBumper() local theVeh7 = getPedOccupiedVehicle(localPlayer) if theVeh7 then local alreadyVisible = getVehicleComponentVisible(theVeh7, "bump_front_dummy") setVehicleComponentVisible(theVeh7, "bump_front_dummy", not alreadyVisible) end end addEventHandler("onClientGUIClick", fbumper, setFBumper, false) guiSetVisible (vehmod, false) fixed & optimized. Explanation: you have to give the component name as second argument to getVehicleComponentVisible for it to work the return value of getVehicleComponent is either true or false, not "true" not "false"1 point
-
Hehehe this is, definitely not final. Still learning all the Lua basics so I've been playing around to get things to work. Thanks for your help. Everything seems clear to me now.1 point
-
I recommend to check for an existing account like... -- I assume that there is a variable called "db_conn" with the MySQL connection. local function does_account_exist(username) local query = dbQuery(db_conn, "SELECT username FROM accounts WHERE username='?'", username); if not (query) then return false; end local results = dbPoll(query, -1); if not (results) then return false; end return ( #results >= 1 ); end Then you can use the "does_account_exist' function as part of if-condition to check for the existance. Like... local function create_error_message_dialog(msg) -- TODO: write the GUI logic in here. end local function create_account(username, password) if (does_account_exist(username)) then create_error_message_dialog("This name already exists"); return; end -- TODO: use dbExec to register a new account. end1 point
-
I am glad to be of help! It is especially nice to see experienced developers around here. ? I recommend a read of the wiki's event system info for the full details. But in your case the "root" means to listen to the "updateMoney" event triggers on all elements in the MTA element tree. Thus if you were to execute... triggerEvent("updateMoney", resourceRoot) your server-local event would also fire. But if you were to use "resourceRoot" for the addEventHandler call instead then executing the above code on another resource would not trigger your event handler. The BIG BUT is: executing... triggerEvent("updateMoney", root) does trigger the event handler in both of the above cases. To improve the robustness (not security!) of your resource you can set the propagate argument of addEventHandler to false.1 point
-
Dear iwalidza, do you have a MySQL server set-up already? It can be placed either locally (recommended) or remotely, on another computer. You need to register a user with a secure password as well as a database for use with your resource. And how much experience do you have with MySQL databases in general? You should use the official MTA database functions to connect to your configured MySQL server, in particular... dbConnect - call it once at start of resource to initialize a database connection handle (you need a host, username and password, etc) dbExec - creating new accounts into the MySQL database dbQuery with dbPoll and dbFree - taking account information out of your database In order to implement "This name already exists" you need to query the accounts SQL table on the "username" column and see if any row with that username already exists, for example... SELECT * FROM accounts WHERE username="iwalidza" If you were to use dbQuery on this statement in combination with dbPoll/dbFree you could check the existance of accounts prior to creating a double account. I found an accounts system that claims to use MySQL under-the-hood in the MTA resources community: https://community.multitheftauto.com/index.php?p=resources&s=details&id=7263 Please take a look at it and compare it with what you want to implement.1 point
-
1 point
-
Dear Bartje, welcome to the MTA scripting forums! I am glad to see new faces around here that nicely ask for help. Let me help you by commenting on what you have already scripted: I think you mixed up the clientside definition with the serverside definition of setPlayerMoney. For the clientside definition the first argument is not a player element but just a number with the money that the local player should have. This is because the local player does only know or care about his own money value, not other people's. Thus you can simply remove the first parameter "source" and just pass the money count. The source element that you pass as argument after the event name to triggerEvent-style functions is usually the element that wants to receive or has received a change. In your code you have simply specified "root" which is okay if you want to update the money of all players to the same value. But if you want to update the money of just one player... ... then you have to further adjust this code. The first argument to triggerClientEvent can be a player element that should receive the event. You probably want to limit this to the person that actually logged in. Otherwise even non-logged in players would randomly receive the 1000 gold. - Martin1 point
-
https://wiki.multitheftauto.com/wiki/FindRotation get player position and ped position, set their x and y in the findRotation params, then set the npc rotation with the returned value from findRotation, use setPedRotation to do so1 point
-
It's weird that you are claiming Paradise Roleplay is leaked, while it's an open-source gamemode: https://github.com/mabako/mta-paradise1 point
-
Hello community! Its been over 10 years since I logged in to this forum, but I still believe there are people around, who can remember me and these maps made by me over 13 years ago. So today I decided to hand over my map package free for grabs, as the original link has been dead for several years already. This is the original release: And here you have the link to my official re-upload: https://drive.google.com/open?id=1qE34BU-d8K1e_is7jLr_Yq7Ll9yHkiY5 Have fun! PS. If you have some memories about those good old times, feel free to write something here!1 point
-
Well, you spammed us in multiple ways for this ban, but so far haven't made an appeal on the forums, so I will answer this for good. You will not be unbanned. The reason is that your DDoS practises are really serious, not only did you attack servers often, you also made a YouTube channel to brag about it. People that make channels dedicated to show off criminal activities targetting MTA users and servers, do clearly not belong on MTA, and we need to protect the rest of our users against them. Who wouldn't agree with me? Even though you removed it all, we can now still know what you did. Appeal denied. Please don't make any appeals in the future, and don't contact us. For the record, it applies to both of your serials: AB90CFB2812771462FE7528D41615452 and 3DFEE027D1253511266FC3A70E88AAB2 (i will edit this post with more if you decide to evade, so you can't return to appeal them with a different name).1 point
-
That site is a pain in the ass. The videos load so slow, its ridiculous. What does the debugger say?1 point
-
1 point
-
1 point
-
Glad to be of help. Since you are asking so kindly I want to give you ideas how to continue with your inventory system. I absolutely recommend going with dx because it is more powerful than CEGUI. So these are the functions that should be used: dxDrawImage - drawing inventory icons as well as general GUI images dxDrawText - displaying the item names and descriptions as well as GUI text dxDrawRectangle - styling of the inventory window/grid/whatever bindKey function - opening the inventory with a button onClientRender event - drawing the dx UI each frame onClientClick event - clicking on items in inventory for selection and action onClientMouseMove event - hovering over items to display the description, highlighting, etc triggerServeEvent - asking the server to use an item or update the inventory in some way (throw away item, reordering the inventory, etc) triggerClientEvent - transmitting the inventory to the client Here is how I imagine an inventory to look. Code on requesting the inventory from the server: server.Lua addEvent("onRequestInventory", true); addEventHandler("onRequestInventory", root, function() triggerClientEvent(client, "onClientReceiveInventory", root, player_inventories[client], item_definitions); end ); client.Lua addEvent("onClientReceiveInventory", true); addEventHandler("onClientReceiveInventory", root, function(player_inventory, item_definitions) -- TODO: use the data somehow. end ); local function send_inventory_request() triggerServerEvent("onRequestInventory", root); end Feel free to ask more questions when you have some code done already1 point
-
Hello iwalidza, if you want to have selection support inside edit boxes you need to play around with the text-width. First you have to establish text of a certain font with a certain scale. This gives you the ability to call dxGetTextWidth to obtain metrics about your text. Knowing that you need to search for the text offset into your editbox content at click event. I suggest to set the middle of each character as tipping point. -- THIS IS JUST SAMPLE CODE! It has not been tested using Unicode/UTF-8 so be warned! local strsub = string.sub; local dxGetTextWidth = dxGetTextWidth; function getTextLogicalOffset(text, offset, charScale, charFont) local n = 1; local len = #text; local curOffset = 0; local charWidth; while (n <= len) do charWidth = dxGetTextWidth(strsub(text, n, n), charScale, charFont); curOffset = curOffset + charWidth; n = n + 1; if (curOffset > offset) then break; end end if not (n == 1) and (curOffset - offset > charWidth * 0.5) then return n-1, curOffset - charWidth; end return n, curOffset; end (taken from resedit resource at https://github.com/quiret/resedit/blob/master/utilities_client.Lua#L822) It is very important to establish drag&drop inside of your editbox. This is done by remembering when the player triggered "mouse1" to start the selection and disabling it when he released "mouse1". While the player is pressing down "mouse1" you should update the selection every time the mouse cursor is moved. local select_start = 1 local select_end = 0 local text = "test" local font = "sans" local fontScale = 1.2 local text_pixels_off_x = 2 local is_selecting = false local function has_selection() return ( select_start <= select_end ) end local function mouse_click(x_abs, y_abs) if not (is_selecting) then select_start = getTextLogicalOffset(text, x_abs - text_pixels_off_x, fontScale, font) is_selecting = true end end local function mouse_move(x_abs, y_abs) select_end = getTextLogicalOffset(text, x_abs - text_pixels_off_y, fontScale, font) - 1 end local function mouse_release() if (is_selecting) then is_selecting = false end end (this code has not been tested yet) At render-time you should highlight the text that is selected using a custom rectangle backdrop. This is done by simply remembering start-offset and end-offset of the selection and, if the selection is not empty, using dxDrawRectangle before or after rendering the text at text render offset start-offset to end-offset. I leave it to you as an exercise.1 point
