Jump to content

Search the Community

Showing results for tags 'elementdata'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Multi Theft Auto: San Andreas 1.x
    • Support for MTA:SA 1.x
    • User Guides
    • Open Source Contributors
    • Suggestions
    • Ban appeals
  • General MTA
    • News
    • Media
    • Site/Forum/Discord/Mantis/Wiki related
    • MTA Chat
    • Other languages
  • MTA Community
    • Scripting
    • Maps
    • Resources
    • Other Creations & GTA modding
    • Competitive gameplay
    • Servers
  • Other
    • General
    • Multi Theft Auto 0.5r2
    • Third party GTA mods
  • Archive
    • Archived Items
    • Trash

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Gang


Location


Occupation


Interests

Found 9 results

  1. function updateVeh(vehicle) local id = getElementData (vehicle, "TS:VehicleID") --element data que ira setar no veiculo ao ser spawnado pela concessionaria if id then local result = dbPoll(dbQuery (db, "SELECT * FROM Inventario WHERE Vehicle = ?", id), -1) --database do porta malas local data = dbPoll(dbQuery (db, "SELECT * FROM Veiculo WHERE Vehicle = ?", id), -1) --database do porta malas if type (result) == "table" and type (data) == "table" then setElementData(vehicle, "TS:VehicleItens", result) --irá setar os itens q tem no porta malas do carro setElementData(vehicle, "TS:VehiclePeso", data) --irá setar o peso q o veiculo tem isso aq tá dando erro ao clicar no end --carro por isso preciso da ajuda de vcs end end createEventHandler("TS:updateVeh", getRootElement(), updateVeh) queria um event q verificasse se o carro foi spawnado no servidor e que no momento q o carro for spawnado executasse a função ai em cima
  2. opa tudo bom ? , gostaria de saber como posso tar fazendo para pegar o tanto de player em uma elementData para colocar em um dxDrawText , exemplo : abrir tab e mostrar em numero tanto de player na elementData
  3. Gostaria de verificar se nome que o jogador escrever no painel , é igual a outro nome definido no elementData de outro jogador. No client-side esta assim : local Nick = guiGetText(NickBoxText) setElementData(localPlayer, "checknick", Nick) local check = getElementData(localPlayer, "checknick") if check then triggerServerEvent("checkNick", getLocalPlayer()) end function successNick() CloseDxPanelCreate () triggerServerEvent ("changename", getLocalPlayer()) end addEvent("successNick", true) addEventHandler("successNick", getRootElement(), successNick) E no server-side assim : function haveOtherNick (myName) for i, player in ipairs (getElementsByType("player")) do if (getElementData (player, "checknick") and getElementData (player, "checknick") == myName) then return true end end return false end function checkNick() local nome = getElementData (source, "checknick") if (nome) then if (haveOtherNick(nome)) then outputChatBox ("Já tem alguém com esse nome online.") else triggerClientEvent("successNick", getRootElement()) setElementData(source, "playername", nome) end end end addEvent("checkNick", true) addEventHandler("checkNick", getRootElement(), checkNick) O erro e que sempre retorna o outputChatBox, mesmo colocando outro nome diferente. Tive ajuda de alguns membros do forum , mas não consegui solucionar .
  4. Вообщем, у меня все работает, НО, когда задаю элементу ключ, и потом использую getElementData выходит ошибка в консоле "attemp to compare number with string", и соответственно скрипт не работает. Вот скрипт которым я задаю ключ: function giveadm (source, command, ident, lvl) if(getElementData(source,"admlvl") > 8) then if (ident) then for id, player in ipairs ( getElementsByType ( "player" ) ) do if ( tonumber(getElementData ( player, "ID" )) == tonumber(ident) ) then local thePlayer = getAccountName (getPlayerAccount(player)) if lvl then if((tonumber(lvl) > -1) and (tonumber(lvl) < 11))then local RootNode = xmlLoadFile ( "Accounts/"..thePlayer..".xml" ) local playeradmlvl = xmlFindChild ( RootNode, "admlvl", 0 ) local valueadmlvl = xmlNodeSetValue ( playeradmlvl, lvl.."" ) local serial = xmlNodeGetValue ( xmlFindChild (RootNode, "serial", 0) ) xmlSaveFile(RootNode) xmlUnloadFile(RootNode) outputChatBox("* Вы выдали "..lvl.." уровень администратирования игроку "..thePlayer..".", source, 255, 215, 0, true) setElementData ( player, "admlvl", lvl ) else outputChatBox("* неверный уровень администратирования", source, 255, 215, 0, true) end else outputChatBox("* /makeadmin [id] [0-10]", source, 255, 215, 0, true) end end end else outputChatBox ("* /makeadmin [id] [0-10]", source, 255, 215, 0, true) end else outputChatBox ("* У Вас нет доступа.", source, 255, 215, 0, true) end end addCommandHandler ("makeadmin", giveadm) Дальше, если я буду использовать скрипты, у меня будет ошибка в строчке: " if(getElementData(source,"admlvl") > 8 then ". Заранее спасибо!
  5. Olá gostaria de saber se tem como fazer uma verificação do getElementData para saber quantos jogadors/policiais tem dela e se tiver + 5 vai fazer a função de assaltar o banco. Eu sei que pelo Team da para fazer mas queria muda pois fica o nome no Team do scoreboard acho muito feio. Aqui está Server-side function Verifica_Roubo(source) if isElementWithinMarker( source, Atendente) then --guarda1 = exports.slothbot:spawnBot (865.3115234375, -1368.9912109375, 14.996451377869, 270, 113, 0, 0, policial, 31, "waiting", true ) local theTeam = getTeamFromName("PM") if theTeam then if countPlayersInTeam(theTeam) >= 0 then --if getElementModel( element ,theElement ) setElementPosition( Atendente, 854.6572265625, -1372.029296875, 14.996742248535 -5 ) setPedAnimation(source, "SHOP", "ROB_Loop_Threat", 10000, true, false, false, false) setPedRotation(source, 360 ) setPedAnimation( ped, "SHOP", "SHP_Rob_HandsUp") BancoRoubado = createBlipAttachedTo(Atendente, 36) setTimer (function() outputChatBox("#000000[#FF0000ATENÇÃO#000000]#FFFFFFO Portão abrira em #FF000030 segundos#FFFFFF!!!", source, 0, 255, 0, true) setTimer(function() outputChatBox("#000000[#FF0000ATENÇÃO#000000]#FFFFFFO Portão abrira em #FF000020 segundos#FFFFFF!!!", source, 0, 255, 0, true) setTimer(function() outputChatBox("#000000[#FF0000ATENÇÃO#000000]#FFFFFFO Portão abrira em #FF000010 segundos#FFFFFF!!!", source, 0, 255, 0, true) moveObject( Porta1, 2930, 854.40002441406, -1368.5, 16.60000038147) moveObject( Porta2, 2930, 870.09997558594, -1368.5, 16.60000038147) outputChatBox("#000000[#FF0000ATENÇÃO#000000]#FFFFFFO Portão abriu!!!", source, 0, 255, 0, true) Cofre = createObject(2634, 850.2998046875, -1375, 23, 0, 0, 90) Marker_Cofre = createMarker(849.7685546875, -1375, 22.9964427948 -1, "cylinder", 2, 255 ,0 ,0, 255) triggerClientEvent ( root, "roubar", root) end, 30000, 1) end, 20000, 1) end, 10000, 1) else exports.dxmessages:outputDx(source,"#FF0000[ATENÇÃO] #FFFFFFPrecisa ter 5 PM online para roubar!!!", source, 255, 255, 255, true) end end end end addCommandHandler("assaltar", Verifica_Roubo)
  6. Bem três topicos em um dia ;-; devo se burro para fica quase toda hora aqui mas vamos direto para a explicação. Seguinte to tentando Salvar data do Item mas toda vez que eu reconnect servidor/restart o script o valor volta padrão e não o salvo. Digamos gastei uma água ai do painel ia fica 4/5 como não salvar quando eu saio do servidor e volta para o 5/5. Espero que tenham entendidos. Queria pedir desculpas por fazer topicos quase toda hora Server_side
  7. 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. Hello, I have been writing gamemode for a long time, everything that is important (information about the vehicle, player, object) is stored on the server side in the table. My question is: what is safer and more optimal? Variables saved on the server side in the table and called to the client by events or elementData?
  9. Eae pessoal. Estou com uma dúvida rápida aqui. Estou fazendo um sistema de level, nesse sistema existe um verificador server-side que verifica todos os jogadores a cada 1 segundo procurando por players AFK para pausar o Up do level. Até então sem problemas, mas estou querendo colocar o tempo do up de cada jogador aparecer na tela deles, qual procedimento a seguir é MAIS LEVE para fazer isso? cria uma variável, salva o tempo nela e triggerClientEvent a cada 1 segundo, para enviar essa variável atualizada ao cliente. setElementData no jogador a cada 1 segundo, então o client irá sempre mostrar essa data na tela dele. setAccountData no jogador a cada 1 segundo. [Já vi que é inviável fazer assim, até porque não há como receber esse valor client-side] fazer o próprio client calcular o tempo de up? A propósito, o timer em si é este: (server-side) No script client, deverá ter um onClientRender que deverá mostrar o playerLapsed ao jogador. (só que no client, irá formatar os milisegundos em minutos/segundos.)
×
×
  • Create New...