Leaderboard
Popular Content
Showing content with the highest reputation on 25/11/20 in all areas
-
OK so after many requests from people asking me to install discord bots to their servers I have decided to make the simplest tutorial on setting up a bot for your servers. [NOTE]: THIS IS A VPS TUTORIAL. IF YOUR SERVER ISN'T RUNNING ON A VPS THIS WILL NOT WORK FOR YOU UNLESS YOU UNDERSTAND HOW NODE.JS WORKS. Part 1: Bot creation Part 2: Files Configuration Part 3: SSH commands That should be all now go have fun annoying players in your server. Some feedback would be appreciated Good luck1 point
-
Hi, I was testing fetchRemote function and decide to create script that's gonna load map from cloud / URL. I added some settings soo you can create the whole system out of this few lines of code. Also this resource is gonna need access to 'fetchRemote' function, simply add it in ACL and you can use it. There are 2 maps added so you can test it out. local customMapsRawData = { ["Trash on Grove Street"] = { ["active"] = true, -- is map enabled or not ["link"] = "http://www.gubi.studio/tut/mta/trash-on-grove-street.txt", -- link to text file which contain whole data of your .map file ["visibleTo"] = getRootElement(), -- element which should see the map, can be player/getRootElement() ["annoucment"] = true, -- if set to true will annouce on chat that map has been loaded }, ["Shop on Grove Street"] = { ["active"] = false, ["link"] = "http://www.gubi.studio/tut/mta/shop-on-grove-street.txt", ["visibleTo"] = getRootElement(), ["annoucment"] = false, } } local function createMapFromRawData(data, error, mapName, annoucment, visibleTo) if error == 0 then loadMapData(xmlLoadString(data), visibleTo) outputDebugString("Map "..mapName.." has been loaded!") if annoucment == true then outputChatBox("Map "..mapName.." has been loaded!", root, 0,255,0) end else outputDebugString("Map "..mapName.." failed while loading! Check if link is valid!", 3) end end local function loadCustomMaps() if not hasObjectPermissionTo(getThisResource(), "fetchRemote", true) then outputDebugString("This resource needs access to \"fetchRemote\" in ACL!", 1) return end for mapName, mapData in pairs(customMapsRawData) do if mapData["active"] == true then fetchRemote(mapData["link"], createMapFromRawData, "", false, mapName, mapData["annoucment"], mapData["visibleTo"]) end end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), loadCustomMaps)1 point
-
Você tem diversos crashs desconhecidos e outro relacionado a falta de memória de vídeo - pode ser por conta do servidor abusando de memória gráfico ou scripts ruins fazendo acumular o uso, mas também pode ser pela limitação do seu hardware. Fora isso, você tem arquivos não-originais do GTA e isso também pode causar crashs no MTA. @zDarkyy1 point
-
Mes commentaires/explications dans le code: local qh = dbQuery(db, "SELECT * FROM users WHERE username=?", username) local result = dbPoll (qh, -1) local row = result[1] -- ici tu récupères la row de ta DB if not row then spawnPlayer(source, 1743.63281, -1861.50757, 13.57743) local x, y, z = getElementPosition(source) dbExec(db, 'INSERT INTO users (username, posX, posY, posZ) VALUES (?,?,?,?)', username, x, y, z) else -- ici t'as confirmation que "row" existe mais tu ne fais rien avec, il faut récupérer les valeurs x, y, z depuis la row ! local x, y, z = getElementPosition(source) -- et non pas getElementPosition qui va récupérer la position actuelle du joueur, cad 0, 0, 0 par défaut quand on se connecte setElementPosition(source, x, y, z) -- et il faut utiliser spawnPlayer plutôt que setElementPosition si t'as pas déjà spawn end1 point
-
Map files Table of contents: Introduction How to read a map file? Broken map file, what to do? Editor bugged, what to do? Modify your maps outside of MTA Extra links Introduction A map-file! What is that? The name already gives away the definition. It is a file which contains a MTA map. The format makes maps portable, so that you can send them over to your friends. You can recognize map-files by the extension: .map Here is an example of a map: Syntax highlight When you open a map file in your text editor. The syntax highlight you should use is XML (HTML will work as well, but the semantic is different and could cause issues with auto complete features, that is if you have enabled those). Changing syntax highlight in for example Visual Studio Code. How to read a map file? Before we start, this is what we call a node: <tagName></tagName> If we take a closer look to the following map file: <map> <object id="object (bevgrnd03b_law) (1)" interior="0" collisions="true" alpha="255" doublesided="false" model="6094" scale="1" dimension="0" posX="635.234375" posY="-3827.2275390625" posZ="5" rotX="0" rotY="0" rotZ="0"></object> <object id="object (gaz9_law) (1)" interior="0" collisions="true" alpha="255" doublesided="false" model="6133" scale="1" dimension="0" posX="625.49114990234" posY="-3771.6955566406" posZ="11.479743003845" rotX="0" rotY="0" rotZ="0"></object> <object id="object (CE_grndPALCST03) (1)" interior="0" collisions="true" alpha="255" doublesided="false" model="13120" scale="1" dimension="0" posX="573.09802246094" posY="-3847.013671875" posZ="3.6442375183105" rotX="0" rotY="22" rotZ="352"></object> <object id="object (CE_grndPALCST03) (2)" interior="0" collisions="true" alpha="255" doublesided="false" model="13120" scale="1" dimension="0" posX="572.64624023438" posY="-3769.0698242188" posZ="4.9519920349121" rotX="0" rotY="21.99462890625" rotZ="343.24649047852"></object> <object id="object (CE_grndPALCST03) (3)" interior="0" collisions="true" alpha="255" doublesided="false" model="13120" scale="1" dimension="0" posX="669.66534423828" posY="-3856.0627441406" posZ="3.6442375183105" rotX="0" rotY="63.99462890625" rotZ="175.99389648438"></object> </map> > we see in there the map node: <map></map> When the map is loaded <map></map> will become our map element. And inside of the map node we see more nodes: <object id="object (bevgrnd03b_law) (1)" interior="0" collisions="true" alpha="255" doublesided="false" model="6094" scale="1" dimension="0" posX="635.234375" posY="-3827.2275390625" posZ="5" rotX="0" rotY="0" rotZ="0"></object> <object id="object (gaz9_law) (1)" interior="0" collisions="true" alpha="255" doublesided="false" model="6133" scale="1" dimension="0" posX="625.49114990234" posY="-3771.6955566406" posZ="11.479743003845" rotX="0" rotY="0" rotZ="0"></object> In this case these two nodes will become two in-game objects. Tagname <tagName></tagName> Each node in the map file will become an element in game. !important A node has a tag name. In this case I gave it the name: "tagName" This tag name specifies in MTA the element type. For example: If it has the name <object></object>, the element-type is an object. If it has the name <ped></ped>, the element-type is a ped. What if the tag name is not matching with one of these entities? (The list is not complete, the rest can be found in this class list, only if the XML syntax is implemented) Then the elements are considered custom elements. They are not visible in game. Custom elements Custom elements have their own purposes. You often see those custom elements used in game modes, for example stealth: <mercenaryspawn id="mercenaryspawn (1)" posX="635.58117675781" posY="-3770.458984375" posZ="18.97974395752" rotX="0" rotY="0" rotZ="0"></mercenaryspawn> The tagname for this node is "mercenaryspawn". The element that is produced after loading the map, is used as a spawnpoint for in a stealth map. Custom elements are invisible. Custom elements do have an orientation. The getElementsByType function can be used to get custom elements. Attributes Attributes are properties applied to a node. They are used to attach data to an element. Example: <entity name="IIYAMA" age="5" type="device" resolutionX="1920" resolutionY="1080" displaySize="31"></entity> An attribute exist out of two parts: <entity name="value"></entity> Name Value The name specifies if the node has the attribute. <entity name></entity> <entity age></entity> If the name is "name", then the node has the attribute "name". And if the name is "age", then the node has the attribute "age". The value will be used for the data for each attribute. <entity name="IIYAMA" age="5"></entity> Identifiers (ID) Every elements can have an identifier attribute, which is used to make it accessible for scripting functions. <tagName id="identifier"></tagName> The identifier of an element can be used in getElementByID to grant access to it. Even though identifiers normally should be unique for each individual, it is not the end of the world if they are not in MTA. They might also be considered as unnecessary for map files without scripts. Element specific attributes There are some attributes that do more than just applying properties. They will change the element appearance and orientation. For example this object: <object interior="0" collisions="true" alpha="255" doublesided="false" model="6094" scale="1" dimension="0" posX="635.234375" posY="-3827.2275390625" posZ="5" rotX="0" rotY="0" rotZ="0"></object> It will be created in interior 0. It will have collisions. (You can walk on it) Alpha. It's opacity is 100%. It is not doublesided. (When you stand inside of the object you can look through it. If doublesided is enabled the same colors/paint from the other side will be applied.) It's model is 6094. It is scaled 100%. (0.5 = 50%, 2 = 200%) Etc. If you want to know which attributes do have influence on the elements appearance and orientation, you have to look that up on the wiki. Here a small list of some those attributes: Broken map file, what to do? If your map file is broken. Step 1 Make a backup. + Always make a backup when re-editing your map. Settings can get lost! Step 2 The first thing you want to do, is just open it in a text-editor. Just give it a quick look and check for anything strange. The file could be empty or some strange values could be used. Do you want to know all the syntax rules (XML)? You can find a list right here: http://www.adobepress.com/articles/article.asp?p=1179145 Step 3 Remove the editor definition. This definition could cause problems in case of invalid characters. From: <map edf:definitions="COBDEF,editor_main"> <!-- Map elements --> </map> To: <map> <!-- Map elements --> </map> Step 4 If you can't find the problem, then you could validate the file. There are services out there that validate XML files. They can help you to find out where your file is broken. Validation tool by W3C: https://validator.w3.org/#validate_by_input Note: You need to do step 3 first. Else you can't parse the file. Step 5 In case of re-opening map files in the editor, but doesn't want to get open. Make a backup. Remove custom elements. See chapter How to read? Retry to open the file. Editor is bugged, what to do? Your editor could be bugged and you are not able to save the map or open a new one. The first thing you want to do is backup the editor_dump folder in your server. This folder is located between all your resources. server\mods\deathmatch\resources\editor_dump Rename the folder name. editor_dump > my_broken_map Stop the map editor. Check if there is a new editor_dump folder. If there is, rename that one as well. Start the map editor again. Modify your maps outside of MTA Sometimes you want to modify your maps without going back in to the editor. Your text-editor is in most cases the way to go. For example you want to move all objects to a new dimension. In Notepad++: Make a backup! (if you are new to this) Select in your file the part you want to replace: dimension="0" Commando: ctrl + H (replacement overlay) Fill in the replace field: dimension="1" Click on: replace ALL. Moving your map? There is a nice online tool that can help you with that: https://mtaclub.eu/converters Edit your map with the DOM (Document Object Model) Knowing JavaScript? Your browser inspector can be used to modify your maps at a higher level. (If you so desire) Extra links: Parent, child and how this is reflected in MTA https://wiki.multitheftauto.com/wiki/XML https://wiki.multitheftauto.com/wiki/Element_tree Elementdata <sync_map_element_data /> https://wiki.multitheftauto.com/wiki/Meta.xml Load maps (manually + including in meta.xml) https://wiki.multitheftauto.com/wiki/Meta.xml https://wiki.multitheftauto.com/wiki/LoadMapData Save maps https://wiki.multitheftauto.com/wiki/SaveMapData1 point
-
this function will fade out your window till it disapperas then it will be fade in till it being fully visable you can edit it to be fade in/out when command triggerd or bindkey pressed fadeStatus = true function fading() local fadeRatioPerRender = 0.005 if (fadeStatus == true) then local alpha = guiGetAlpha(window_logo) guiSetAlpha(window_logo, alpha-fadeRatioPerRender) if (alpha == 0) then fadeStatus = false end else local alpha = guiGetAlpha(window_logo) guiSetAlpha(window_logo, alpha+fadeRatioPerRender) if (alpha == 1) then fadeStatus = true end end end addEventHandler("onClientRender", root, fading)1 point
-
Thomas_Nightfire function getPointInFrontOfPoint(x, y, z, rZ, dist) local offsetRot = math.rad(rZ) local vx = x + dist * math.cos(offsetRot) local vy = y + dist * math.sin(offsetRot) return vx, vy, z end function GetMarrot(angle, rz) local marrot = 0 if(angle > rz) then marrot = -(angle-rz) else marrot = rz-angle end if(marrot > 180) then marrot = marrot-360 elseif(marrot < -180) then marrot = marrot+360 end return marrot end function findRotation(x1, y1, x2, y2) local t = -math.deg(math.atan2(x2 - x1, y2 - y1)) return t < 0 and t + 360 or t end local px,py,pz = getElementPosition(localPlayer) local prx,pry,prz = getElementRotation(localPlayer) local vx,vy,vz = getPointInFrontOfPoint(px,py,pz, prz+90, 15) local thePed = createPed(299, vx,vy,vz+1, prz+180) local theVehicle = createVehicle(404, vx,vy,vz+1, 0,0,prz+180) warpPedIntoVehicle(thePed, theVehicle) function UpdateBot() px,py,pz = getElementPosition(localPlayer) prx,pry,prz = getElementRotation(localPlayer) vx,vy,vz = getElementPosition(theVehicle) local vrx,vry,vrz = getElementRotation(theVehicle) local brakes = false local maxspd = 40 local MaxDist = 4 local vehreverse = false if(getDistanceBetweenPoints2D(px,py, vx, vy) < MaxDist) then brakes = true end if(brakes) then setPedAnalogControlState(thePed, "accelerate", 0) setPedAnalogControlState(thePed, "brake_reverse", 0) setPedControlState(thePed, "handbrake", true) setElementVelocity (theVehicle, 0,0,0) else local vxv, vyv, vzv = getElementVelocity(theVehicle) local s = (vxv^2 + vyv^2 + vzv^2)^(0.5)*156 -- Speed local rot = GetMarrot(findRotation(vx,vy,px,py),vrz) if(rot > 80) then if(rot > 100) then vehreverse = true end rot = 20 elseif(rot < -20) then if(rot < -80) then vehreverse = true end rot = -20 end if(vehreverse) then setPedAnalogControlState(thePed, "brake_reverse", 1-(s*1/maxspd)) setPedAnalogControlState(thePed, "accelerate", 0) setPedControlState(thePed, "handbrake", false) if(s > 10) then setPedControlState(thePed, "handbrake", true) else if(rot > 0) then setPedAnalogControlState(thePed, "vehicle_left", (rot)/20) else setPedAnalogControlState(thePed, "vehicle_right", -(rot)/20) end end else if(rot > 0) then setPedAnalogControlState(thePed, "vehicle_right", (rot)/20) else setPedAnalogControlState(thePed, "vehicle_left", -(rot)/20) end setPedAnalogControlState(thePed, "brake_reverse", 0) setPedControlState(thePed, "handbrake", false) if(s < maxspd) then setPedAnalogControlState(thePed, "accelerate", 1-(s*1/maxspd)) else setPedAnalogControlState(thePed, "accelerate", 0) setPedAnalogControlState(thePed, "brake_reverse", (s/maxspd)-1) end end end end setTimer(UpdateBot, 50, 0) Demo1 point