-
Posts
6,058 -
Joined
-
Last visited
-
Days Won
208
Everything posted by IIYAMA
-
Some typo's. <meta> <script src="c.lua" type"="client" cache="false"/> <script src="s.lua"/> <file src="font.ttf"/> </meta> Green = added Red = removed <meta> <script src="c.lua" type="client" cache="false" /> <script src="s.lua" /> <file src="font.ttf" /> </meta>
-
No worries. BTW, you can only send the hunger value when you know which account this player has logged in to. There is a chance that the player hasn't logged in yet when the resource has been loaded. On closer inspection it might be better to try it on onPlayerLogin and using a login panel to delay the user-interaction. addEventHandler ("onPlayerLogin",root, afterlogin)
-
sx+2, sy+2, sx+2, sy+2, Lets not move the right-side of the text boundingbox beyond the left-side of the boundingbox.
-
Doing it at the right moment. For example on the event "onPlayerResourceStart" and sending it only to this player. https://wiki.multitheftauto.com/wiki/OnPlayerResourceStart Read the wiki of that event carefully, since there is info in it that most people forget to read...
-
You are sending a message to all clients/players directly when the server is executing the script. The clients/players haven't loaded their scripts yet, to receive the message.
-
That happens when you fire a query (with a callback) and restart/stop the resource directly after that.
-
In that case, try to make a bug report. And cache the audio files for now on the server. (For clients to dowload from)
-
Because you didn't save it there. You have not written a (memory) cache for your database.
-
First of all, you do not need to use my library. Only if you are going to make use of callbacks. You do not get the hunger, you send it using triggerClientEvent. for _,row in ipairs(result) do Hunger = row["Hunger"] Thirst = row["Thirst"] break end local row = result[1] Hunger = row["Hunger"] Thirst = row["Thirst"] You should get here the current hunger values from the database. https://wiki.multitheftauto.com/wiki/DbPrepareString Finish the code yourself. local players = getElementsByType("player") local queryString = dbPrepareString( db, "SELECT Hunger,Thirst FROM stats WHERE Account IN ( " -- loop with player account names queryString = queryString .. dbPrepareString( db, "?, ", AccName) -- loop end queryString = queryString .. " )" local handle = dbQuery( db, queryString ) -- Receive data here and combine the correct database data with the player.
-
client is only available when you call hms with a triggerServerEvent.
-
Like the code below. I have put the bandwidth limit very low so that you can see the transfer status in action. Just make sure you are the only player in the server. local playerLatentHandles = {} local bandwidthLimit = 100 -- 104857600 function hms(x,y,z) triggerLatentClientEvent("mirarA", bandwidthLimit, false, client, x,y,z) -- Get the current handle local handles = getLatentEventHandles(client) local currentHandle = handles[#handles] playerLatentHandles[client] = currentHandle end addEvent('mirarPS', true) addEventHandler('mirarPS', root, hmc) -- Testing: setTimer(function () local player = getRandomPlayer() local currentHandle = playerLatentHandles[player] if currentHandle then local status = getLatentEventStatus( player, currentHandle) iprint(player, status) end end, 500, 0) @Cronoss I did fixed a bug just a sec ago.
-
triggerServerEvent is unable to receive data. If you take a look at the syntax of that function, you will see that it only returns a boolean(true/false): https://wiki.multitheftauto.com/wiki/TriggerServerEvent You can make it possible using this library, but that wouldn't create a solid system. The server should be in charge of the hunger and Thirst values. What you want is the following: Server A timer (or multiple timers) This one gets the Hunger and Thirst Updates the Hunger and Thirst (-1) according to your needs. Sets the health or kills the player. triggerClientEvent (or elementdata with https://wiki.multitheftauto.com/wiki/AddElementDataSubscriber + setElementData [syncMode is "subscribe"]) Client Just updates the UI to show the player his hunger and thirst values.
-
And if you use this event? https://wiki.multitheftauto.com/wiki/OnClientSoundFinishedDownload
-
At the side the triggerClient/ServerEvent is locaties. The debug console only shows you errors, warnings by default. If you want more information than that. You will have to add debug lines. (iprint) Those lines will show up as soon as the code execute them. If they are not shown up while they should, that means that there is a mistake before them. If you keep moving them forwards/backwards, you will eventually find the location of the problem. Between showing up and not showing up, is the problem. iprint("A") if false then --[[ <<<< B not is showing up? And A is? Then here is the problem ]] iprint("B") end They are also handy to debug variables, which are often containing incorrect values when there is a bug.
-
Wiki: except the transmission rate of the data contained in the arguments can be limited and other network traffic is not blocked while the data is being transferred. It does 2 things: - It can be limited - It does not block while transferring. If you increase the bandwidth to max 100 MB: 100*1024*1024 You basically undo the first thing. That is fine if you only send a little bit of data. What might lag for some players is the head movement. Which is caused by the non-block transfer thing. - If the player his download is not fast enough, there will be a delay. But there will be no/little lag created for other things, like remote-player movement. (Remote-players = other player elements than yourself in your game) - And if the player download is not fast enough and can't keep up. It will stack all those latent events in a queue, which only gets longer. If you are going to use this function, then I recommend to use getLatentEventStatus for each player to check if the player receives the data. If yes, then send the next update.
-
This update rate is fine, unless you have about/more than ~40 players in your server. Fix for that: Client (set Thirst with sync disabled) Thirst = Thirst - 1 setElementData(localPlayer, "Thirst", Thirst, false) + https://wiki.multitheftauto.com/wiki/TriggerServerEvent (https://wiki.multitheftauto.com/wiki/TriggerLatentServerEvent) + Server (set Thirst with sync disabled) setElementData(client, "Thirst", Thirst, false)
-
It can full fill that part if you want, since MTA has a build in webserver, but you might want to add some serverside stuff for your website as middleware for anti-abuse performance reasons. Anyway I leave an example below for those that are interested. Resource name: webserver Filename: meta.xml <meta> <info version="1.0.0" name="webserver" type="script" description="Web server info" /> <html src="playerCount.html" /> <script src="main_s.lua" type="server" /> <export function="getPlayerCount" http="true" /> </meta> Method: 1 Filename: playerCount.html <* httpWrite( #getElementsByType ( "player" ) ) *> URL: http://127.0.0.1:22005/webserver/playerCount.html Returns: <what ever you want> Method: 2 Filename: main_s.lua function getPlayerCount() return #getElementsByType( "player" ) end URL: http://127.0.0.1:22005/webserver/call/getPlayerCount Returns: JSON Skip login? (it is not recommended to skip for production, use middleware instead for the credentials) Add: <right name="resource.webserver.http" access="true"></right> Under default: <acl name="Default"> <right name="resource.webserver.http" access="true"></right>
-
Probably, can you show me that clientside part just to be sure?
-
You can increase the lock wait timeout: https://stackoverflow.com/questions/6000336/how-to-debug-lock-wait-timeout-exceeded-on-mysql There are multiple reasons why this error can occur, so maybe that will not be enough. Also consider to index your most used columns, like Account: https://www.w3resource.com/mysql/creating-table-advance/create-index.php This will speed up your search queries. But de-increase the speed of removal queries. (which you probably only use when removing accounts)
-
@Vestorn There is a build in method as far as I can remember. But never used it myself. (Maybe somebody else knows) But this is the custom(isable) resource method you can use: https://wiki.multitheftauto.com/wiki/Resource_Web_Access https://wiki.multitheftauto.com/wiki/HttpWrite
-
Account data is a database interface and manager for ONLY account-bounded-data. dbConnect + all other db functions, allows you to create your own database interface and manager. This gives you a lot of freedom, but it also means that you have to write a lot yourself.
-
I updated Burak his example. But I have not refactored the variable names. function AccDatacallback(AccData, player, account, AccName) local result = dbPoll( AccData, 0 ) if AccData and #AccData > 0 then return end local ID = getFreeID() local SetData = dbExec(db,"INSERT INTO stats (ID,Account) VALUES (?, ?)", ID, AccName) end function getpaccount (_,account) local AccName = getAccountName(account) setPlayerName(source,tostring(AccName)) dbQuery(AccDatacallback, {source, account, AccName}, db, "SELECT * FROM stats WHERE Account=? LIMIT 1", AccName) end addEventHandler("onPlayerLogin",root, getpaccount) The function was called instead of provided as function. local AccData = dbQuery(AccDatacallback(), db,"SELECT * FROM stats WHERE Account=? LIMIT 1", AccName) This is now moved inside of the call back function. Since the data is not immediately available. if(AccData) then if(#AccData > 0) then return end end local ID = getFreeID() local SetData = dbExec(db,"INSERT INTO stats (ID,Account) VALUES (?, ?)",ID, AccName)
-
That might be indeed the case. That 5000ms timer is a bit hacky in my opinion. Just listen in the resource (that has the hashCheck function) to the event: "onClientReceivePermissions" (you can cross listen to events of another resources, as long as the element you are listen to is a parent or the source) The predefined variables of that event will be enough to figure out which resource is ready and which is not. See list of predefined variables: https://wiki.multitheftauto.com/wiki/AddEventHandler
-
It might be a ppi issue. (I am not a shader expert) but let me speculate a bit. Afaik: When playing with border less settings and window mode, the same resolution is returned on https://wiki.multitheftauto.com/wiki/GuiGetScreenSize Not sure if you used that one to create your render target. This might put a difference between the resolution the shader is placing the texture on the screen and the resolution delivered by the texture. If this situation is matching yours, what if you do not scale the texture? But placing it with the exact size. Either by the texture size or by the pixels the shader is about to draw. Anyway, those artifacts are most of the time caused by some sort of scaling.