-
Posts
1,518 -
Joined
-
Last visited
-
Days Won
8
Everything posted by Simple0x47
-
[ENCUESTA] Persona más odiada de la comunidad MTA Hispana.
Simple0x47 replied to Simple0x47's topic in Offtopic
El voto nunca cerrara, apresurense :v -
Buenas gente. Hoy estaba discutiendo con @venadHD sobre quien es la persona más odiada de la comunidad hispana de MTA. Voten con total sinceridad, esta encuesta es solo para averiguar quien de los dos tenía razón. Gracias por vuestra participación. Voten gente, quien vote se llevara recompensa >:v ( La libertad de expresión ).
-
You can get the right offsets for you need by trying different values to see where it's the attached element being placed.
-
Faster development, but performance sucks.
-
APPENDIX DATA SYNCHRONIZATION. What is it? MTA's synchronization methods. Optimization tips. DATA SYNCHRONIZATION 1. What is it? Since unmemorable times humanity have faced problems caused mainly due to the storage of different ideas in almost each human. But thank God, machines storage methods are different and they have the possibility of having stored the same values in more than 100 machines. Well this is great, but those values must be set by someone, and here's where the server-side and client-side can be used as example of data synchronization. The server-side store's all the values given by each client-side and give's back those values to the all the client-sides ending up into something like this ( Figure 1 ). This is a way to get the same data in all the client-side, but there's also other methods well known like P2P. Figure 1. 2. MTA's synchronization methods. Since data sync it's a base element of every multiplayer game or mod, MTA is not an exception. That's why MTA scripting interface gives us two core ways to sync the server data with the client data or client data with server data. Well this two methods are the following one's. Element Data, it consists of assigning values to an element that are being stored under a key ( the key usually being a string like "health" ). This way is being used by a great amount of scripters in MTA because it's easy to use. But there are also negative points if this way is not being used properly like saving small amount of data in just one key and syncing it with the server or client's. An example of it would be: [[--CLIENT.LUA--]] local value = 0 local function handleStart() value = getTickCount() -- WE GET THE TIME THE SERVER HAS BEEN WORKING WHEN THE RESOURCE START setElementData( localPlayer, "start_tick", value, true ) -- WE SAVE THE 'value' VARIABLE INTO THE 'localPlayer' ELEMENT WITHIN THE KEY 'start_tick' AND WE SYNC IT TO GET THIS DATA TO THE SERVER. end addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), handleStart ) [[--SERVER.LUA--]] local function handleCMD( thePlayer ) local mineTick = getElementData( thePlayer, "start_tick" ) -- WE RETRIEVE THE DATA, THAT HAS BEEN SAVED INTO 'thePlayer' DATA. local resultTick = getTickCount() - mineTick -- GET HOW MUCH TIME HAS PASSED SINCE THE RESOURCE STARTED FOR THE PLAYER outputChatBox( resultTick, thePlayer ) -- PRINT INTO THE CHAT THE RESULT end addCommandHandler( "mytime", handleCMD ) -- IN CASE YOU WANT TO TRY IT SAVE THE CODE WITH THE NAME MARKED ABOVE THEM. [[--META.XML--]] <meta> <script src="server.lua" type="server"/> <script src="client.lua" type="client"/> </meta> Events, this method is the one that elementData's one bases on, which means this is a 'rawer' method which can also be faster than elementData if it's being used efficiently. An event is just a message that's being send to one or various systems, if these systems handle the message then when the message is sent to the system there's a trigger which calls the functions that are defined like a reaction to that message that has been sent. It's pretty easy to understand, just think of this. You say hello to someone, the message in this case is 'Hello' and the system where is pointed to mainly is the person, the person gets the message and handles it by calling some cognitive functions, these functions at their time trigger another message as result which in the most common case would be 'Hello' or just a strange face motion because he or she doesn't know you. Maybe you will ask yourself about what does a hello to someone have to do with Events in MTA. Well let's convert the situation above into script. We've got to define first the message by using addEvent( "Hello" ), good we have defined our message, but if we stop here then we have made some useless stuff that's not going to be used ever, that's why we have to use this message somewhere and here is when we simulate the action of saying something the message by using triggerEvent( "Hello" ) but... wait who's supposed to say the message? Let's make it look like the localPlayer was saying the message so it would be like triggerEvent( "Hello", localPlayer ), okay we have said the message but do we talk alone? Maybe but it's not pretty normal, so we must find a receptor which in this case will be a ped so we add the a ped to the game by using createPed( 0, 105, 20, 5.5 ) supposing we are located in the position 104, 20, 5.5. Okay we have the receptor now but it won't answer to our message so let's obligate him to answer us by adding a handler for the message to the ped like this addEventHandler( "Hello", thePed ), okay but this way it will do the same as we wouldn't have used addEventHandler that's why we need to pass also a function to call like an argument which in this case is going to be called 'answerToHello' and we would finish up with addEventHandler( "Hello", thePed, answerToHello ). All this and little bit more of code below for simulating an answer to hello from a person in a non-realistic way. [[--CLIENT--]] -- EVENTS addEvent( "Hello", false ) -- LET'S MAKE IT LIKE JUST THE CLIENT CAN TRIGGER IT SO WE MAKE SURE JUST WE ARE GOING TO TALK TO THE PED -- VARIABLES local thePed = createPed( 0, 105, 20, 5.5 ) -- WE ADD THE PED SO WE DON'T FEEL LONELY -- FUNCTIONS -- SAY HELLO local function sayHello() -- THIS FUNCTION WILL BE USED TO SEND UP THE MESSAGE TO THE PED triggerEvent( "Hello", thePed ) -- WE SAY HELLO TO THE PED end -- ANSWER local function answerToHello() -- WE DEFINE THE MESSAGE HANDLER SO WE MAKE SURE THE PED ANSWERS TO US outputChatBox( "Hello to you too!" ) -- THE PED GET'S THE MESSAGE AND GIVES US BACK A MESSAGE THAT WE CAN CHECK INTO THE CHAT. end -- COMMANDS addCommandHandler( "sayit", sayHello ) -- WE'VE GOT TO SAY SOMEHOW HELLO TO THE PED SO LET'S USE A COMMAND -- EVENT HANDLERS addEventHandler( "Hello", thePed, answerToHello ) 3. Optimization tips. Well both methods can be used in large development but there are some tips you can follow to make sure your script will run in an efficient way. Pack reasonable amount of data into one's element data key, don't save values like ( health, armor, money ) into different keys, compress them into an only one by using tables, by using this method we pass 3 values packed in one sync meanwhile separating each value with one key creates upon 3 different syncs which would end up in a greater amount of packets sent between the server and the client. This tip can be used for both methods [ elementData, Events ]. local basic_data = { health = 100, armor = 100, money = 100 } -- COMPRESSED PLAYER INFO setElementData( thePlayer, "main", basic_data, true ) -- WE GIVE 3 DIFFERENT VALUES TO 'main' KEY BY USING JUST A VARIABLE THAT'S A TABLE 'basic_data' triggerClientEvent( thePlayer, "onSync", thePlayer, basic_data ) -- WE SEND A MESSAGE TO THE CLIENT IN ORDER TO MAKE IT SYNC THE DATA OF THE PLAYER TO THE ONE THAT IS BEING STORED IN THE SERVER Lua is a garbage collection language so the reduce the amount of global variables as much as possible in order to make it run faster. Hope you enjoyed the tutorial, if you have any question just feel free to ask it in this post or by PM, Skype ( killer.68x ) or Email ( [email protected] ) or Discord ( Simple01#1106 ).
- 8 replies
-
- 8
-
-
- elementdata
- events
-
(and 1 more)
Tagged with:
-
Could you make a table with the Objects ID's you would not mind to replace? If you would do it I could do this replacement on the most optimized way, I just need to have a table like this one with the Objects ID's you don't mind to replace. local replace_ids = { 16105, 12801, 7580, 9123 }
-
It looks like it doesn't connect to the server maybe due to wrong connection details. Could you send the PHP connection code to me via PM so I check it out and look for solutions?
-
In order to fix the problem I need you to post the client side too. Meanwhile take a little upgrade of this serverside part. https://pastebin.com/MssCKwy8
-
The user interface will never be on server side. It's always made in the client side with the possibility of being edited by the server side. If you want a custom UI then you are looking for dxDraw based GUI's. These are the functions you will need to use for getting done a dxDraw basic based GUI. DxDrawRectangle DxDrawText OnClientRender OnClientCursorClick OnClientCursorMove
-
I can help you with it in some hours, add me on skype: killer.68x If you cant I'll send you a solution by PM.
-
[QUESTION] Does 'onResourceStart' cover 'onClientResourceStart' ?
Simple0x47 replied to koragg's topic in Scripting
onResourceStart doesnt cover entirely onClientResource but the other way yes. Because onClientResourceStart gets triggered whenever the resource starts for the client ( join and start ). Meanwhile server just starts when its triggered on the server. Answering to your question no. -
Siesta turca, no me combine idioma >:v
-
Daca vrei ajuti, da daca ajuti comportamente astfel generezi un val de mesaje pe medile de comunicare de cum naiba se monteaza gamemode cu vG. ( Zic din propia experienta ).
-
Nunca estaría global según tu dices. Para llevar a cabo lo que estas buscando tienes que encontrar la manera de enlazar dichas funciones a una función núcleo para llevar a cabo estas acciones. Una idea es almacenar al jugador como llave de una tabla y asignarle el valor deseado.
-
local variable = nil function Funcion () variable = valor end function OtraFuncion () print( variable ) end Si estás en un archivo server pero si el problema no se encuentra con interactuar en el mismo archivo entonces usa esto.
-
Post can be closed, figured out an answer. ( Body duplication with positioning )-
-
Another person that uses :v, >:v
-
Hello people. Today I've got a question because I couldn't find any answer to it for ZModeler so here I'm. The thing is that I want to make a vinyl system, for which thing I need a material which would cover all the vehicle parts except the wheels and the exhaust, the thing is if I make a material selecting those parts and assigning the material to them the vehicle becames transparent when the material has any transparency ( I know it's normal ) and the answer I'm looking for is the way which could give me the possibility of having that material covering all the vehicle without affecting it's 'solid status'. Thanks.
-
Es fácil, sumas la pantalla con la que obtuviste esa font size, generando así un valor relativo. Ese valor relativo lo multiplicas por el valor absoluto que surge de la suma de la anchura y altura y ahí lo tienes. De forma resumida es una escala obtenida a traves de una regla de 3.
-
[RPG/CnR/RP] Limitless RPG v3.0 [ENGLISH]
Simple0x47 replied to Lampard1's topic in Servers to play on
The server is the hosting itself, so the server shows up support for developers without being scared of having 'rivals'... -
[RPG/CnR/RP] Limitless RPG v3.0 [ENGLISH]
Simple0x47 replied to Lampard1's topic in Servers to play on
I like this server because it offers help to other developers giving them free hosting with slots just for some posts in their forum. Respect! -
Donald Trump detected!? About the image, it looks like a marker not a wall.
-
[OFFERING] High Quality Scripting Service [PAID]
Simple0x47 replied to Simple0x47's topic in Looking for staff
Status changed: Working on a project until summer 2018. ( The status might change faster or slower depending on how the project development goes ).- 18 replies
-
- paid
- optimization
-
(and 1 more)
Tagged with: