-
Posts
2,947 -
Joined
-
Last visited
Everything posted by JR10
-
That was just an example of how the function works. Here: function drawText() local width = dxGetTextWidth(hexColorHome..homeName.."("..homeAlivePlayers.."):".."#ffffff "..displayHome, 1, 'default-bold') dxDrawRectangle(sW-90,(sH/2)-50,width,40, tocolor(0,0,0,110)) dxDrawText ( hexColorHome..homeName.."("..homeAlivePlayers.."):".."#ffffff "..displayHome, sW-80, (sH/2.26), sW, sH, tocolor(255, 102, 1, 255), 1, "default-bold", 'right', 'center', false, false, false, true, true, 0, 0, 0) dxDrawText ( hexColorVisit..visitName.."("..visitAlivePlayers.."):".."#ffffff "..displayVisit, sW-80, (sH/2.17), sW, sH, tocolor(255, 0, 0, 255), 1, "default-bold", 'right', 'center', false, false, false, true, true, 0, 0, 0) end addEventHandler("onClientRender", root, drawText) Now just add another dxGetTextWidth for the second dxDrawText.
-
This is exactly what was suggested before, deleting the file. But it surely can be bypassed.
-
[HELP] MySQL - Query Datas and send it to the Client
JR10 replied to =KoG=Rouche's topic in Scripting
Are you sure dbConnect is being used and the variable is being assigned correctly? You should check for the variable to make sure the connection succeeded. Post the part where you run dbConnect. -
He can also just delete it as soon as the script is loaded by just typing the fileDelete function anywhere in the script file, it will be loaded as soon as the script is ran, bypassing it will still be possible by downloading the image and disconnecting before the script is ran, a bit hard but possible.Another way would be to use fetchRemote on an image on the web and then drawing it for the client, check the wiki page for more info and an example.
-
Check this resource which has a similar approach, loading data from the query on start up and storing it in an array for later access.
-
It probably does save but the problem is you're not removing the old account data, so it's still being checked and will return true. You should use something like setAccountData(account, 'hp', 1) setAccountData(account, 'hp', 2) And up to 6, that way you will only have the current one and will not have to worry about the old ones. You should also use root in triggerServerEvent and client on server-side as the player, afaik there are security risks with using source. triggerServerEvent ( "HPStats1", root) And server: function HPLev1 () local playerAccount = getPlayerAccount( client ) ... end
-
[HELP] MySQL - Query Datas and send it to the Client
JR10 replied to =KoG=Rouche's topic in Scripting
I already posted a fixed code for you, use that. Also, you have init as the function handler for onPlayerLogin while it should be initPlayer. -
[HELP] MySQL - Query Datas and send it to the Client
JR10 replied to =KoG=Rouche's topic in Scripting
You're not sending the account in readPlayerDatas. You're also unnecessarily using global variables. Here: ---- MYSQL Connection ---- -- Create an connection object for the Database function connectDB() .... end -- Call the function to create a Connection Object function initVar() connect = connectDB() end addEventHandler("onResourceStart",root,initVar) -- When a player login it calls the readPlayerDatas function function init(_, account) account = "Blabla" -- Test Variable ! ##### readPlayerDatas(account) end addEventHandler("onPlayerLogin",root,init) function readPlayerDatas(account) -- Account must be a input variable from clientside -- Retrieve Player table datas from DB local playerData, EventsData, DMData, OLDData local queryPlayer = dbQuery(myCallBackPlayer,connect, "SELECT * FROM Player WHERE account = ?", account) function myCallBackPlayer(queryPlayer) local resultPlayer = dbPoll(queryPlayer,0) playerData = resultPlayer[1] end -- Retrieve Events table datas from DB local queryEvents = dbQuery(myCallBackEvents,connect, "SELECT * FROM Events WHERE toPlayer = ?", account) function myCallBackEvents(queryEvents) local resultEvents = dbPoll(queryEvents,0) EventsData = resultEvents[1] end -- Retrieve DM datas from DB local queryDM = dbQuery(myCallBackDM,connect, "SELECT * FROM DM WHERE toPlayer = ?", account) function myCallBackDM(queryDM) local resultDM = dbPoll(queryDM,0) DMData = resultDM[1] end -- Retrieve OLD datas from DB local queryOLD = dbQuery(myCallBackOLD,connect, "SELECT * FROM OLD WHERE toPlayer = ?", account) function myCallBackOLD(queryOLD) local resultOLD = dbPoll(queryOLD,0) OLDData = resultOLD[1] end -- Trigger an event clientside and send the previous datas with in triggerClientEvent(thePlayer,"onReplyFromReadDatas",root,playerData,EventsData,DMData,OLDData) end addEvent("onPlayerReadDatas",true) addEventHandler("onPlayerReadDatas",root,readPlayerDatas) -
That's exactly what I suggested in my first post. But, client-side? addAccount is server-side only and givePlayerMoney client-side will not change it server-side and therefore should never be used client-side.
-
BEST MTA:SA CLIENT SKIN?? You changed the windows' edges and call it the best?
-
Not needed and useless. Better invest time on requested features.
-
dxGetTextWidth will return the width of the text when drawn with the same font and scale, you can use that width with dxDrawRectangle (third parameter) to draw the rectangle with the same width as the text. A really basic example: local width = dxGetTextWidth('test') dxDrawRectangle(0, 0, width, 20)
-
Your code is not clear, and obviously you don't even want to invest some time trying to learn, I posted a tutorial and the functions for you. Look around for codes that uses SQL, like the house_system on the community, it will give you a basic example. The wiki has examples too, try to learn from it. What you need is to have the data you want to save server-side and then use the SQL functions to save it. Try something and then post for help with the code.
-
There is no event for onPlayerRegister. The function to add an account is called addAccount, there is no player anywhere so that an event will be triggered for him. You need to track your script and figure out where the account is added and you will probably find the responsible player and will be able to give him money.
-
Element data works throughout the player session, when he quits, the element no longer exists, so it's totally logical that the element's data will be lost. You need a different way to save the data. You can use SQL for this. Read more here and on the wiki. dbQuery dbPoll dbConnect dbFree dbExec
-
[HELP] MySQL - Query Datas and send it to the Client
JR10 replied to =KoG=Rouche's topic in Scripting
https://wiki.multitheftauto.com/wiki/DbQuery You will find examples with callbacks. You're still using onPlayerLogin client-side which is a server-side event only. -
Would be better if you upload it to the community so more people would find it by searching.
-
[HELP] MySQL - Query Datas and send it to the Client
JR10 replied to =KoG=Rouche's topic in Scripting
First of all, rootElement is already defined globally as root so you can just use root instead of rootElement. You're connecting to the database every time you request data which is not optimum, you should connect once at the start of the resource and use the connection variable throughout the scripts. Also, you're using dbPoll with -1 and that will freeze the whole thing until it receives the results, a better way would be to use callbacks, as they will not cause freezing and will be called immediately after the results are ready. onPlayerLogin event is server-side only. -
Indexes are used to search rows with specific values much faster. Without going into more details, read here for more: https://dev.mysql.com/doc/refman/5.0/en ... dexes.html An index name is used so you can later manipulate the index, and for example, drop the index. As for the index type read here: http://stackoverflow.com/questions/7078 ... t-in-mysql
-
Try this local qh = dbQuery(db, 'SELECT LAST_INSERT_ID() AS id') local result = dbPoll(qh, -1) local id = result[1]['id'] You should never use dbPoll with -1 as it freezes the whole thing until it obtains the result, instead use callbacks.
-
getElementPosition getScreenFromWorldPosition dxDrawText There are many resources with examples around the community.
-
Show us the part where the setting is retrieved? My guess is that it only detects the first time, or maybe it only detects changing to 'true'.
-
You can use 'or' to assign a different value if it returns false/nil. This will return either a number or 0 tonumber(getElementData(thePlayer, "Lee Enfield")) or 0
-
Any errors in /debugscript 3? Try to explain what happens maybe?
-
Show us the part where showVehGui is called.