-
Posts
6,044 -
Joined
-
Last visited
-
Days Won
207
Everything posted by IIYAMA
-
Thx @Shady1 P.s. I made some last tweaks for installation script. It seems it for some unknown reason didn't always create a meta.xml file for the API credentials.
-
Serverinfo This resource is a small API for MTA server info, which you can modify / expand to your liking. It is many used to display information about the current state if the server. Like for example how many players are playing. Read the installation carefully, because you certainly do not want to put your admin login credentials online. ? Note: before you even download this resource, test if your web interface is even available. Start your server. Open a web browser and fill in your (local) IP and standard port. If it ask for a username and password, it looks like it is OK. If not, something doesn't seems to be correct. !Server hosts that are based on slots, might have disabled the exposure of the web interface. <ip>:<port> Endpoint: <ip>:<port>/<resourceName>/api/<endpointName>.json Local ip and standard port: http://127.0.0.1:22005 Analytics http://127.0.0.1:22005/serverinfo/api/analytics.json Team info http://127.0.0.1:22005/serverinfo/api/teamList.json Chat history http://127.0.0.1:22005/serverinfo/api/chat.json Generic info http://127.0.0.1:22005/serverinfo/api/info.json Player info http://127.0.0.1:22005/serverinfo/api/playerList.json Download: https://community.multitheftauto.com/?p=resources&s=details&id=18781
-
Try this play ground of mine. Should be working, if not it might be a hardware or setting issue. do --[[ Capture content here ]] local renderTarget addEventHandler( "onClientResourceStart", resourceRoot, function() renderTarget = dxCreateRenderTarget( 500, 500, true ) end ) function captureContent( callBack ) if not renderTarget then return false end dxSetRenderTarget( renderTarget, true ) callBack() -- captureContent( >>> function() end <<< ) dxSetRenderTarget() return renderTarget end end do --[[ Cache renderTargets for static content ]] local cache = {} function cacheRenderTarget( key, renderTarget ) local pixels = dxGetTexturePixels( renderTarget ) if not pixels then return false end cache[key] = dxCreateTexture( pixels ) return true end function getTextureFromCache( key ) if cache[key] then iprint( 'from cache' ) end return cache[key] end end addEventHandler( "onClientRender", root, function() -- When updating content local dynamicTexture = captureContent( function() local size = getTickCount() % 501 dxDrawRectangle( 0, 0, size, size, tocolor( 0, 0, 100, 100 ) ) dxDrawText( "abcdefghi dynamic" .. getTickCount(), 10, 0, 500, 500, tocolor( 255, 255, 255 ), 1, "default", "left", "top", false, false, false, false, true ) dxDrawText( "abcdefghi dynamic" .. getTickCount(), 10, 20, 500, 500, tocolor( 255, 255, 255 ), 2, "default", "left", "top", false, false, false, false, true ) end ) if dynamicTexture then dxDrawImage( 0, 500, 500, 500, dynamicTexture ) end -- When just drawing static stuff local staticTexture = getTextureFromCache( 'static' ) if not staticTexture then staticTexture = captureContent( function() dxDrawRectangle( 0, 0, 500, 500, tocolor( 0, 0, 100, 100 ) ) dxDrawText( "abcdefghi static (not so sharp)", 10, 0, 500, 500, tocolor( 255, 255, 255 ), 1, "default", "left", "top", false, false, false, false, true ) dxDrawText( "abcdefghi static (not so sharp)", 10, 20, 500, 500, tocolor( 255, 255, 255 ), 2, "default", "left", "top", false, false, false, false, true ) end ) if staticTexture then cacheRenderTarget( 'static', staticTexture ) end end if staticTexture then dxDrawImage( 500, 500, 500, 500, staticTexture ) end end )
-
Can you create a smaller version of your current resource, so that we can take a closer look at your problem? (small size is important because we can focus mainly on the problem) Just looking at your current code is a very inefficient method in finding a bug. Best to let the computer do the work for us.
-
Keep in mind that the capture process starts at the left-top of the screen. posx = (sX/2)-(x1/2) dxText ( core, posx+2, posy-max*scrolling, rtW, rtH, tocolor ( 255, 255, 255, 255 ), z2*0.90,font,"left","top",true, true, false,false, true) It might not be captured. local rtW, rtH = dxGetMaterialSize(texture) You already know the size of the render target, no need to compute.
-
string.sub(string.gsub("abcdefg69hijklmn7opqrs0tuvw71xyz72", "[^%d]", ""), 1, 4) -- 6970 With string.sub you can make a selection of characters. Arguments: The string Start index: 1 End index: 4 https://www.tutorialspoint.com/string-sub-function-in-lua
-
You can for example replace all non numeric characters with empty strings. string.gsub("abcdefg69hijklmn7opqrs0tuvw71xyz72", "[^%d]", "") --[[ Returns 2 values: Result: 69707172 Items replaced (with empty string): 26 ]]
-
A different technique: Guard Clauses You might want to read this, to get a better understanding of the technique. The result is more or less the same, except there are some differences with the returned values. In your function it doesn't matter, but there are functions where it does matter a lot.
-
First of all, it important to understand there is serverside and there is clientside. Serverside is running on the server application, or just call it the server. This is where all players connect to in order to player the game together. MTA San Andreas 1.5\server\MTA Server.exe Here are server functions available. Clientside in running on each game application. It is literally the MTA game. MTA San Andreas 1.5\Multi Theft Auto.exe Keep in mind that there can multiple clientsides. For each connected player there is a clientside. The data between those clientsides is not shared. Here are client functions available. The reason why some function are not available on the other side is many because of security restrictions. You do not want to grant all players the rights to be able to ban each other, only the server should be able to ban a player. And some functions are just not so useful at the other side, like drawing an image just 1 frame on your screen. Imagine having server doing that every frame, your internet will just die.
-
That looks fine. Next up, write the following in both situations to the serverlog. Collect them from the logs and place them here, so that we can compare the input from both situations. outputServerLog(inspect({freeID, login, vehID, positionVeh, vehcolor, cost, 1000, "TRANZIT", handlings, doors, panels, wheels, lights})) Code should be placed directly before the dbExec function call.
-
local nameveh, cost = getVehicleDataFromTable( vehID ) Does this function accepts strings or numbers? Because addCommandHandler will provide the vehID as a string. local nameveh, cost = getVehicleDataFromTable( tonumber(vehID) ) if not nameveh then return end Please use the code tag for your code, or many forum users will not even attempt to look at your problem
-
@Wozi I have moved your topic to tutorials, so that it is better preserved and easier to find. Good luck with your project!
- 1 reply
-
- 1
-
MTA useful functions do not exist unless they are added. See Code and expand the blue box 'Server- and/or clientside Script', there you can find the source code for that function. In that case I only recommend to post on your own language section. It saves some time for both of us. ?
-
Checkout this useful function: https://wiki.multitheftauto.com/wiki/CheckPassiveTimer
-
setPedStat ( thePlayer, 24, 1000 ) -- increase upper limit to max setElementHealth ( thePlayer, 200 ) -- fill to upper limit >> or spawn the player
-
Sounds like a synchronous data query, which is writing/reading a lot of data all at once. The real reason 'why' is with the developer...
-
Set it to 1000 ?
-
Default value is used to fill in specific columns when you have no value provided for them. Normally the default value is null, when nothing is provided. Solutions: https://stackoverflow.com/questions/41077044/mysql-can-not-insert-because-no-default-value
-
First of all it is important to understand that tables(arrays) in Lua do not start at index 0, they start at index 1. The pairs function does not always loop in order. (unreliable for looping in order) The ipairs function does, but does not start at 0, it just skips it. So if you want a loop starting at 0, the basic for loop is the best option to be honest.
-
https://wiki.multitheftauto.com/wiki/GetElementSpeed This useful function returns 1 speed value (based on x, y, z) What I explained is how the useful function works and how you can change it more or less from 3D(x,y,z) to 2D(x,y).
-
Normally you would get the direction vector X, Y: https://wiki.multitheftauto.com/wiki/Vector/Vector2 And get the length of it: .getLength() / .length This is the 3D variant (useful function): https://wiki.multitheftauto.com/wiki/GetElementSpeed And this would be the 2D variant: local speedX, speedY = getElementVelocity(theElement) -- element speed local speed = Vector2(speedX, speedY).length -- get the direction vector > get .length = direction speed
-
This is red: (cr == 255 and cg == 0 and cb == 0) -- red This is not red: not (cr == 255 and cg == 0 and cb == 0) -- not red if not (cr == 255 and cg == 0 and cb == 0) then end
-
You can build an ACL manager resource with MySQL. But it doesn't exist yet, so you have to build it yourself. And it is not quick job! Lots of things to take in consideration, especially security.
-
OOP (Object-Oriented Programming) is just a way to organize (Lua) code. Mostly used when working with a lot of entities/objects = things. But this option is not for enabling OOP in Lua, it is for enabling OOP in MTA (user-data). When enabled a lot of methods will available on the user-data of players, vehicles, peds etc. element:setPosition(x, y, z) -- MTA OOP setElementPosition(element, x, y, z) -- non MTA OOP Those methods are also available as functions, so basically it is an enhancement but not required in most cases. That is irrelevant, but feel free to count.
-
@greenops011 If the developer sets another resource as a dependency, then the <include /> tag should ? have been used in the meta.xml. https://wiki.multitheftauto.com/wiki/Meta.xml If not, then indeed as Fernando explains, the functions you should look for.