Search the Community
Showing results for tags 'id'.
-
This id generating login panel connects to various systems such as inventory. However, I'm unable to resolve the error in this login panel. https://hizliresim.com/etik01d function getIDFromPlayer(id) if id then local theid idTablo = getElementsByType("id") for id,p in pairs(idTablo) do if id == p then theid = i end end return theid else return false end end function getPlayerFromID(id) if id then id = tonumber(id) local theplayer idTablo = getElementsByType("id") for id,p in pairs(idTablo) do if theID == id then theplayer = p end end return theplayer else return false end end addEventHandler("onPlayerLogin", root, function(_,hesap) setElementData(source, "loggedin", true) setElementData(source,"TuningMenuTrue",false) local hesapID = getAccountID(hesap) if idTablo[hesapID] then -- The line where the error is indicated is here. ozelID = idTablo[hesapID] setElementID(source,ozelID) else setElementID(source,hesapID) end local oyuncu = (string.gsub(getPlayerName(source),"#%x%x%x%x%x%x","")) local id = getElementID(source) or "-1" end) addEventHandler("onResourceStart", resourceRoot, function() if id then id = tonumber(id) local theplayer idTablo = getElementsByType("id") for id,p in ipairs(getElementsByType("player")) do setElementData(player, "loggedin", not isGuestAccount(getPlayerAccount(player))) setElementData(player, "TuningMenuTrue", isGuestAccount(getPlayerAccount(player))) if getPlayerAccount(player) then local hesapID = getAccountID(getPlayerAccount(player)) if idTablo[hesapID] then ozelID = idTablo[hesapID] setElementID(player,ozelID) end end end end end)
- 7 replies
-
- help
- loginpanel
-
(and 1 more)
Tagged with:
-
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 replies
-
- concessionária
- mala
-
(and 4 more)
Tagged with:
-
Hello everybody! I'd like to introduce you my own-made systems based on internal.db for small gamemodes or simple servers. I was thinking about how good it'd be if we'd have an abillity to work with account's saved data better and faster only using standard MTA database. I've been looking for an information that could help me to put a lot of data (as player's position, skin, money and so on) in 1 key to internal.db account's data. As for me - this is the best way of using saveAccountData() for non-global servers because it reduces the amount of trash-files in database. I made some researches on that and found out that it doesn't affect the perfomance. Download: https://community.multitheftauto.com/index.php?p=resources&s=details&id=18786 Preview: ------------------------------- ----ACCOUNT ID SYSTEM UTILS---- ------------------------------- function getAccountDatabaseID( account ) if account and not isGuestAccount( account ) then accID = 0 -- Set account ID to default if getAccountData( account, "data" ) and getAccountData( account, "data" ) ~= nil then -- Check out for account's data table local data = fromJSON( getAccountData( account, "data" ) ) -- Get account's data table if data[ "ID" ] == nil then accID = 0 -- Set account ID to default in cause of ID == nil else accID = data[ "ID" ] -- Set account ID to account's data table ID end else accID = 0 -- Set account ID to default in cause of account's data table == nil end return accID -- Return account's ID end end function getFreeDatabaseID() local accounts = getAccounts() missedID = false -- Set an ID to default for operation for i, v in pairs( accounts ) do -- Start a loop for all server accounts if i ~= getAccountDatabaseID( v ) then missedID = i break end end if missedID ~= false then return missedID --[[ ETC: There were 5 accounts. The 3rd one have been deleted. To avoid dissolution of an ID after deleting account we look for the gap and fill it with new account. It means that new account, created afther the 5th, would get 3rd ID of deleted account. --]] else return #accounts + 1 -- There were no gaps in ID row, so we return ID as a count of all accounts + created one. end end ----------------------------------------- ----ACCOUNT ID SYSTEM UTILS ENDS HERE---- ----------------------------------------- -------------------------- ----ACCOUNT DATA TABLE---- -------------------------- function getAccountDataTable( account ) if account and not isGuestAccount( account ) then if getAccountData( account, "data" ) and getAccountData( account, "data" ) ~= nil then local data = fromJSON( getAccountData( account, "data" ) ) -- Get account data table local id = data[ "ID" ] -- Get account ID from data table local position = data[ "Position" ] -- Get account position from data table local skin = data[ "Skin" ] -- Get account skin from data table local money = data[ "Money" ] -- Get account money from data table return id, position, skin, money -- Return all collected data end end end function saveAccountDataTable( account, data ) if account and not isGuestAccount( account ) then setAccountData( account, "data", data ) end end addEvent( "saveAccountDataTable", true ) addEventHandler( "saveAccountDataTable", getRootElement(), saveAccountDataTable ) function getPlayerDataTable( player ) local x, y, z = getElementPosition( player ) -- Get player's position local rotx, roty, rotz = getElementRotation( player ) -- Get player's rotation local interior = getElementInterior( player ) -- Get player's current interior local dimension = getElementDimension( player ) -- Get player's current dimension local skin = getElementModel( player ) -- Get player's skin local money = getPlayerMoney( player ) -- Get player's money local accID = getElementData( player, "ID" ) or 0 -- Get player's account ID ---- local data = toJSON( { [ "ID" ] = accID, -- Prepare account ID to save [ "Position" ] = { x, y, z, rotz, interior, dimension }, -- Prepare player's position to save [ "Skin" ] = skin, -- Prepare skin to save [ "Money" ] = money, -- Prepare money to save } ) ---- return data -- Return all data that we've collected from the player end ------------------------------------ ----ACCOUNT DATA TABLE ENDS HERE---- ------------------------------------ ---------------------------------------- ----IMPLEMENT ALL STUFF THAT WE HAVE---- ---------------------------------------- addEventHandler( "onPlayerLogin", getRootElement(), function( _, account ) if account and not isGuestAccount( account ) then if getAccountData( account, "data" ) and getAccountData( account, "data" ) ~= nil then ---------------------------------------------------- ----Spawn player from saved account's data table---- ---------------------------------------------------- local ID, position, skin, money = getAccountDataTable( account ) spawnPlayer( source, position[ 1 ], position[ 2 ], position[ 3 ], position[ 4 ], skin, position[ 5 ], position[ 6 ] ) fadeCamera( source, true, 3 ) setCameraTarget( source, source ) setPlayerMoney( source, money, true ) setElementData( source, "ID", ID ) -- Apply player's ID outputChatBox( "Welcome back, "..getPlayerName( source ).."!", source, 255, 255, 255, true ) -- Output a welcome message outputChatBox( "Your ID: "..ID, source, 255, 255, 255, true ) -- Output a message to chat for logged player to make a sure that we've got the right ID else ------------------------------------------------------------------------------- ----Spawn player for the first time or in cause of data table reading error---- ------------------------------------------------------------------------------- local ID = getFreeDatabaseID() -- Get free ID for our player to apply it later spawnPlayer( source, 0, 0, 0, 0, 0, 0, 0 ) fadeCamera( source, true, 3 ) setCameraTarget( source, source ) setPlayerMoney( source, 0, true ) setElementData( source, "ID", ID ) -- Apply player's ID outputChatBox( "First time, "..getPlayerName( source ).."? Welcome!", source, 255, 255, 255, true ) -- Output a welcome message outputChatBox( "Your ID: "..ID, source, 255, 255, 255, true ) -- Output a message to chat for logged player to make a sure that we've got the right ID end end end) addEventHandler( "onPlayerLogout", getRootElement(), function( account, _ ) local data = getPlayerDataTable( source ) -- Get player's data to save it saveAccountDataTable( account, data ) -- Save player's data table on log out end) addEventHandler( "onPlayerQuit", getRootElement(), function() local account = getPlayerAccount( source ) local data = getPlayerDataTable( source ) -- Get player's data to save it saveAccountDataTable( account, data ) -- Save player's data table on exit end) P.S: I appreciate any opinion and advice, thank you!? You can use this script for any purpose - the code is opened! I've also tried to explain the whole script. I hope it'd help! Download: https://community.multitheftauto.com/index.php?p=resources&s=details&id=18786
-
Hi, I want to remove this fence in Map Editor, but I can not. I do not know how to remove it. Please show me a way. (I do not know the Id of this object). https://file.io/aG2uJK2KYaAR https://www.file.io/Xsl3/download/aG2uJK2KYaAR
-
Olá pessoal, estou com um problema aqui com esse código, basicamente é um Painel da Policia, só que só funciona se o policia clicar com o rato no jogador, porem assim não funciona bem eu queria adicionar um comando por id, por exemplo: /policial (id) e abrir o painel desse jeito Alguém pode me ajudar to quebrando a cabeça com isso... Lembrando esse painel peguei na net não é meu! addEvent("N3xT.onClickPolicial", true) addEvent("N3xT.onAlgemar", true) addEvent("N3xT.onViatura", true) addEvent("N3xT.onAgarrar", true) addEvent("N3xT.onMultar", true) addEvent("N3xT.ItensPM", true) addEvent("N3xT.takeWeaponPM", true) addEventHandler("N3xT.onClickPolicial", root, function(click) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Policial")) then triggerClientEvent(source, "N3xT.onPainelPolicial", resourceRoot, click) end end ) addEventHandler("N3xT.onAlgemar", root, function() local receiver = getElementData(source, "ReceiverPM") if (receiver) and not isPedInVehicle(receiver) then if not getElementData(receiver, "Algemado") then setElementData(receiver, "Algemado", true) message(source, "O jogador foi algemado.", "success") message(receiver, "Você foi algemado!", "info") else setElementData(receiver, "Algemado", nil) setPedAnimation(receiver, false) message(source, "O jogador foi desalgemado.", "success") message(receiver, "Você foi desalgemado.", "info") end end end ) local carros = {} function salvacarro(vei, assento, vitima) carros[source] = vei end addEventHandler("onPlayerVehicleEnter", root, salvacarro) addEventHandler("N3xT.onViatura", root, function() local receiver = getElementData(source, "ReceiverPM") local vtr = carros[source] if (receiver) and (vtr) then local vrx, vry, vrz = getElementRotation(vtr) local px, py, pz = getElementPosition(vtr) if not getElementData(receiver, "NaViatura") then if not isPedInVehicle(receiver) then setElementData(receiver, "NaViatura", true) message(source, "O jogador foi colocado na viatura.", "success") message(receiver, "Você foi colocado na viatura!", "info") attachElements(receiver, vtr, 0.2, -1.5, 0, 0,0,90) setPedAnimation(receiver, 'ped','CAR_dead_LHS') setElementRotation(receiver, vrx, vry, vrz + 83) end else setElementData(receiver, "NaViatura", nil) message(source, "O jogador foi retirado da viatura.", "success") message(receiver, "Você foi retirado da viatura!", "info") detachElements(receiver, getElementAttachedTo(receiver)) setElementPosition(receiver, px + 2, py + 2, pz) setPedAnimation(receiver) end end end ) addEventHandler("N3xT.onAgarrar", root, function() local receiver = getElementData(source, "ReceiverPM") if (receiver) and not isPedInVehicle(receiver) then if not (getElementData(receiver, "Agarrado") == true) then setElementData(receiver, "Agarrado", true) message(source, "O jogador foi agarrado.", "success") message(receiver, "Você foi agarrado!", "info") attachElements(receiver, source, 0, 1, 0) else setElementData(receiver, "Agarrado", nil) message(source, "O jogador foi desagarrado.", "success") message(receiver, "Você foi desagarrado!", "info") detachElements(receiver, source) end end end ) addEventHandler("N3xT.onMultar", root, function(motivo, valor) local receiver = getElementData(source, "ReceiverPM") if (receiver) and not isPedInVehicle(receiver) then local money = getPlayerMoney(receiver) if (money >= tonumber(valor)) then message(source, "A multa foi aplicada com sucesso.", "success") message(receiver, "Você foi multado no valor de #00ff7fR$"..valor.." #ffffffpelo motivo: #a9a9a9"..motivo.."#ffffff.", "info") takePlayerMoney(receiver, tonumber(valor)) else message(source, "O jogador não possuí o valor da multa!", "error") end end end ) addEventHandler("N3xT.ItensPM", root, function(value, item, quantia) local receiver = getElementData(source, "ReceiverPM") if (receiver) then local next = exports.n3xt_inventario if (value == 1) then local itemTable = next:getAllItens(receiver) triggerClientEvent(source, "N3xT.refreshGridItemPM", resourceRoot, itemTable) elseif (value == 2) then next:takeItemS(source, receiver, item, tonumber(quantia)) triggerClientEvent(source, "N3xT.setWindowPM", resourceRoot, 1) end end end ) addEventHandler("N3xT.takeWeaponPM", root, function(arma) local receiver = getElementData(source, "ReceiverPM") if (receiver) then local id = getWeaponIDFromName(arma) takeWeapon(receiver, id) triggerClientEvent(source, "N3xT.setWindowPM", resourceRoot, 1) message(source, "A arma foi retirada com sucesso.", "success") message(receiver, "Foi retirado de você a arma #00ff7f"..arma.."#ffffff.", "info") end end ) function message(player, message, type) triggerClientEvent(player, "N3xT.dxNotification", resourceRoot, message, type) end
-
Olá, queria ajuda com um script que estou modificando, a única dúvida que tenho é: como posso bota pra aparecer o nome da acl que o usuario está junto com as outras informações? Fiz um exemplo > dxDrawText("Bandana: #ff0000Konoha", x - 1 - w / 1, y - 15 - h - 12, w, h, CorTag, 1.0, "default-bold", "left", "top", false, false, false, true, false) dxDrawText(""..nome.. " ("..ID..")", x - 1 - w / 1, y - 1 - h - 12, w, h, CorTag, 1.0, "default-bold", "left", "top", false, false, false, false, false) CorTag = tocolor(255, 255, 255) Assim ficou dessa forma na imagem: https://prnt.sc/15t62p5 Assim como " Konoha " queria outros nomes também por acl, tipo " Kiri, Iwa, Kumo "... Resumo: nome da acl que o usuario está aparecer como uma informação
-
então esse script deixa o id invisível para todo mundo, e queria colocar que somente membros da acl staff consiga ver o id, normalmente, já procurei tutorial e não entendi muito bem como fazer isso, alguém poderia me ajudar nessa questão? local drawDistance = 7 g_StreamedInPlayers = {} function onClientRender() local cx, cy, cz, lx, ly, lz = getCameraMatrix() for k, player in pairs(g_StreamedInPlayers) do if isElement(player) and isElementStreamedIn(player) then local vx, vy, vz = getPedBonePosition(player, 4) local dist = getDistanceBetweenPoints3D(cx, cy, cz, vx, vy, vz) if dist < drawDistance and isLineOfSightClear(cx, cy, cz, vx, vy, vz, true, false, false) then local x, y = getScreenFromWorldPosition(vx, vy, vz + 0.3) if x and y then if getElementAlpha(player) > 0 then -- se o alpha do player for maior que 0 mostra o ID local ID = getElementData(player, "ID") or "N/A" local w = dxGetTextWidth(ID, 0.1, "default-bold") local h = dxGetFontHeight(1, "default-bold") dxDrawText(""..ID.."", x - 1 - w / 1, y - 1 - h - 12, w, h, CorTag, 1.20, "default-bold", "left", "top", false, false, false, false, false) CorTag = tocolor(255, 255, 255) if getElementData(player, "Cor", true) then CorTag = tocolor(0, 255, 0) end end end end end else table.remove(g_StreamedInPlayers, k) end end addEventHandler("onClientRender", root, onClientRender) function CorTagid () if getElementData(localPlayer, "Cor", true) then setElementData(localPlayer, "Cor", false) else setElementData(localPlayer, "Cor", true) end end bindKey ( "z", "both", CorTagid ) function onClientElementStreamIn() if getElementType(source) == "player" and source ~= getLocalPlayer() then setPlayerNametagShowing(source, false) table.insert(g_StreamedInPlayers, source) end end addEventHandler("onClientElementStreamIn", root, onClientElementStreamIn) function onClientResourceStart() local players = getElementsByType("player") for k, v in pairs(players) do if isElementStreamedIn(v) and v ~= getLocalPlayer() then setPlayerNametagShowing(v, false) table.insert(g_StreamedInPlayers, v) end end end addEventHandler("onClientResourceStart", resourceRoot, onClientResourceStart)
-
Boa noite. Eu queria "excluir" todos os IDs registrados no servidor sem precisar desligar o servidor !! retornando os números de IDs para voltar a contar os IDs do 1 !! preciso de ajuda com isso URGENTE !!
-
Map files Table of contents: Introduction How to read a map file? Broken map file, what to do? Editor bugged, what to do? Modify your maps outside of MTA Extra links Introduction A map-file! What is that? The name already gives away the definition. It is a file which contains a MTA map. The format makes maps portable, so that you can send them over to your friends. You can recognize map-files by the extension: .map Here is an example of a map: Syntax highlight When you open a map file in your text editor. The syntax highlight you should use is XML (HTML will work as well, but the semantic is different and could cause issues with auto complete features, that is if you have enabled those). Changing syntax highlight in for example Visual Studio Code. How to read a map file? Before we start, this is what we call a node: <tagName></tagName> If we take a closer look to the following map file: <map> <object id="object (bevgrnd03b_law) (1)" interior="0" collisions="true" alpha="255" doublesided="false" model="6094" scale="1" dimension="0" posX="635.234375" posY="-3827.2275390625" posZ="5" rotX="0" rotY="0" rotZ="0"></object> <object id="object (gaz9_law) (1)" interior="0" collisions="true" alpha="255" doublesided="false" model="6133" scale="1" dimension="0" posX="625.49114990234" posY="-3771.6955566406" posZ="11.479743003845" rotX="0" rotY="0" rotZ="0"></object> <object id="object (CE_grndPALCST03) (1)" interior="0" collisions="true" alpha="255" doublesided="false" model="13120" scale="1" dimension="0" posX="573.09802246094" posY="-3847.013671875" posZ="3.6442375183105" rotX="0" rotY="22" rotZ="352"></object> <object id="object (CE_grndPALCST03) (2)" interior="0" collisions="true" alpha="255" doublesided="false" model="13120" scale="1" dimension="0" posX="572.64624023438" posY="-3769.0698242188" posZ="4.9519920349121" rotX="0" rotY="21.99462890625" rotZ="343.24649047852"></object> <object id="object (CE_grndPALCST03) (3)" interior="0" collisions="true" alpha="255" doublesided="false" model="13120" scale="1" dimension="0" posX="669.66534423828" posY="-3856.0627441406" posZ="3.6442375183105" rotX="0" rotY="63.99462890625" rotZ="175.99389648438"></object> </map> > we see in there the map node: <map></map> When the map is loaded <map></map> will become our map element. And inside of the map node we see more nodes: <object id="object (bevgrnd03b_law) (1)" interior="0" collisions="true" alpha="255" doublesided="false" model="6094" scale="1" dimension="0" posX="635.234375" posY="-3827.2275390625" posZ="5" rotX="0" rotY="0" rotZ="0"></object> <object id="object (gaz9_law) (1)" interior="0" collisions="true" alpha="255" doublesided="false" model="6133" scale="1" dimension="0" posX="625.49114990234" posY="-3771.6955566406" posZ="11.479743003845" rotX="0" rotY="0" rotZ="0"></object> In this case these two nodes will become two in-game objects. Tagname <tagName></tagName> Each node in the map file will become an element in game. !important A node has a tag name. In this case I gave it the name: "tagName" This tag name specifies in MTA the element type. For example: If it has the name <object></object>, the element-type is an object. If it has the name <ped></ped>, the element-type is a ped. What if the tag name is not matching with one of these entities? (The list is not complete, the rest can be found in this class list, only if the XML syntax is implemented) Then the elements are considered custom elements. They are not visible in game. Custom elements Custom elements have their own purposes. You often see those custom elements used in game modes, for example stealth: <mercenaryspawn id="mercenaryspawn (1)" posX="635.58117675781" posY="-3770.458984375" posZ="18.97974395752" rotX="0" rotY="0" rotZ="0"></mercenaryspawn> The tagname for this node is "mercenaryspawn". The element that is produced after loading the map, is used as a spawnpoint for in a stealth map. Custom elements are invisible. Custom elements do have an orientation. The getElementsByType function can be used to get custom elements. Attributes Attributes are properties applied to a node. They are used to attach data to an element. Example: <entity name="IIYAMA" age="5" type="device" resolutionX="1920" resolutionY="1080" displaySize="31"></entity> An attribute exist out of two parts: <entity name="value"></entity> Name Value The name specifies if the node has the attribute. <entity name></entity> <entity age></entity> If the name is "name", then the node has the attribute "name". And if the name is "age", then the node has the attribute "age". The value will be used for the data for each attribute. <entity name="IIYAMA" age="5"></entity> Identifiers (ID) Every elements can have an identifier attribute, which is used to make it accessible for scripting functions. <tagName id="identifier"></tagName> The identifier of an element can be used in getElementByID to grant access to it. Even though identifiers normally should be unique for each individual, it is not the end of the world if they are not in MTA. They might also be considered as unnecessary for map files without scripts. Element specific attributes There are some attributes that do more than just applying properties. They will change the element appearance and orientation. For example this object: <object interior="0" collisions="true" alpha="255" doublesided="false" model="6094" scale="1" dimension="0" posX="635.234375" posY="-3827.2275390625" posZ="5" rotX="0" rotY="0" rotZ="0"></object> It will be created in interior 0. It will have collisions. (You can walk on it) Alpha. It's opacity is 100%. It is not doublesided. (When you stand inside of the object you can look through it. If doublesided is enabled the same colors/paint from the other side will be applied.) It's model is 6094. It is scaled 100%. (0.5 = 50%, 2 = 200%) Etc. If you want to know which attributes do have influence on the elements appearance and orientation, you have to look that up on the wiki. Here a small list of some those attributes: Broken map file, what to do? If your map file is broken. Step 1 Make a backup. + Always make a backup when re-editing your map. Settings can get lost! Step 2 The first thing you want to do, is just open it in a text-editor. Just give it a quick look and check for anything strange. The file could be empty or some strange values could be used. Do you want to know all the syntax rules (XML)? You can find a list right here: http://www.adobepress.com/articles/article.asp?p=1179145 Step 3 Remove the editor definition. This definition could cause problems in case of invalid characters. From: <map edf:definitions="COBDEF,editor_main"> <!-- Map elements --> </map> To: <map> <!-- Map elements --> </map> Step 4 If you can't find the problem, then you could validate the file. There are services out there that validate XML files. They can help you to find out where your file is broken. Validation tool by W3C: https://validator.w3.org/#validate_by_input Note: You need to do step 3 first. Else you can't parse the file. Step 5 In case of re-opening map files in the editor, but doesn't want to get open. Make a backup. Remove custom elements. See chapter How to read? Retry to open the file. Editor is bugged, what to do? Your editor could be bugged and you are not able to save the map or open a new one. The first thing you want to do is backup the editor_dump folder in your server. This folder is located between all your resources. server\mods\deathmatch\resources\editor_dump Rename the folder name. editor_dump > my_broken_map Stop the map editor. Check if there is a new editor_dump folder. If there is, rename that one as well. Start the map editor again. Modify your maps outside of MTA Sometimes you want to modify your maps without going back in to the editor. Your text-editor is in most cases the way to go. For example you want to move all objects to a new dimension. In Notepad++: Make a backup! (if you are new to this) Select in your file the part you want to replace: dimension="0" Commando: ctrl + H (replacement overlay) Fill in the replace field: dimension="1" Click on: replace ALL. Moving your map? There is a nice online tool that can help you with that: https://mtaclub.eu/converters Edit your map with the DOM (Document Object Model) Knowing JavaScript? Your browser inspector can be used to modify your maps at a higher level. (If you so desire) Extra links: Parent, child and how this is reflected in MTA https://wiki.multitheftauto.com/wiki/XML https://wiki.multitheftauto.com/wiki/Element_tree Elementdata <sync_map_element_data /> https://wiki.multitheftauto.com/wiki/Meta.xml Load maps (manually + including in meta.xml) https://wiki.multitheftauto.com/wiki/Meta.xml https://wiki.multitheftauto.com/wiki/LoadMapData Save maps https://wiki.multitheftauto.com/wiki/SaveMapData
-
Esse sistema e de id permanente ( link censurado ) mais ele nao ta permanente. ta ficando por ordem de entrada quem entrou primeiro fca com os primeiros ids (1,2,3,4,5) alguem pode me ajudar a fazer ele fica permanente (fixo) Danilin_S.Lua: function Start_Id ( _, acc ) if eventName == "onPlayerLogin" then setElementData ( source, "ID", getAccountID(acc) or "N/A" ) outputChatBox ( "#00ff00✘ #ffffffLOGIN #00ff00✘➺ #ffffffNick: #00ff00 ( ".. getPlayerName(source) .." #00ff00) #ffffffID: #00ff00( "..(getAccountID(acc) or "N/A") .." )", root, 255,255,255,true) elseif eventName == "onPlayerLogout" then removeElementData( source, "ID" ) outputChatBox ( "#00ff00✘ #ffffffLOGIN #00ff00✘➺ #ffffffNick: #00ff00 ( ".. getPlayerName(source) .." #00ff00) #ffffffDeslogou.", root, 255,255,255,true) elseif eventName == "onResourceStart" then for _, player in pairs(getElementsByType("player")) do local acc = getPlayerAccount(player) if not isGuestAccount(acc) then setElementData( source, "ID", getAccountID(acc) or "N/A" ) end end end end addEventHandler("onResourceStart", resourceRoot, Start_Id) addEventHandler("onPlayerLogout", root, Start_Id) addEventHandler("onPlayerLogin", root, Start_Id) function getPlayerID(id) v = false for i, player in ipairs (getElementsByType("player")) do if getElementData(player, "ID") == id then v = player break end end return v end --============================================================================================================================-- --=============================-- ----------- ID PLAYER ------------ --=============================-- function getnick(player, command, id, ...) if(id) then local playerID = tonumber(id) if(playerID) then local Player2 = getPlayerID(playerID) if(Player2) then outputChatBox ( "#00ff00✘ #ffffffINFO #00ff00✘➺ #ffffff Nome do Jogador #00ff00" .. getPlayerName(Player2) .."", player, 255,255,255,true) else outputChatBox ( "#00ff00✘ #ffffffERRO #00ff00✘➺ #ffffff O Jogador(a) de ID: #00ff00( " .. id .. " ) #ffffffNão Foi Encontrado!", player, 255,255,255,true) end else outputChatBox ( "#00ff00✘ #ffffffERRO #00ff00✘➺ #ffffff ID: #00ff00( " .. id .. " ) #ffffffInválido!", player, 255,255,255,true) end else outputChatBox ( "#00ff00✘ #ffffffERRO #00ff00✘➺ #ffffffUse /id #00ff00[#ffffffID#00ff00]", player, 255,255,255,true) end end addCommandHandler("id", getnick) IDTag: local drawDistance = 7 g_StreamedInPlayers = {} function onClientRender() local cx, cy, cz, lx, ly, lz = getCameraMatrix() for k, player in pairs(g_StreamedInPlayers) do if isElement(player) and isElementStreamedIn(player) then do local vx, vy, vz = getPedBonePosition(player, 4) local dist = getDistanceBetweenPoints3D(cx, cy, cz, vx, vy, vz) if dist < drawDistance and isLineOfSightClear(cx, cy, cz, vx, vy, vz, true, false, false) then local x, y = getScreenFromWorldPosition(vx, vy, vz + 0.3) if x and y then local ID = getElementData(player, "ID") or "N/A" local w = dxGetTextWidth(ID, 0.1, "default-bold") local h = dxGetFontHeight(1, "default-bold") dxDrawText(""..ID.."", x - 1 - w / 1, y - 1 - h - 12, w, h, CorTag, 1.20, "default-bold", "left", "top", false, false, false, false, false) CorTag = tocolor(255, 255, 255) if getElementData(player, "Cor", true) then CorTag = tocolor(0, 255, 0) end end end end else table.remove(g_StreamedInPlayers, k) end end end addEventHandler("onClientRender", root, onClientRender) function CorTagid () if getElementData(localPlayer, "Cor", true) then setElementData(localPlayer, "Cor", false) else setElementData(localPlayer, "Cor", true) end end bindKey ( "z", "both", CorTagid ) function onClientElementStreamIn() if getElementType(source) == "player" and source ~= getLocalPlayer() then setPlayerNametagShowing(source, false) table.insert(g_StreamedInPlayers, source) end end addEventHandler("onClientElementStreamIn", root, onClientElementStreamIn) function onClientResourceStart(startedResource) visibleTick = getTickCount() counter = 0 local players = getElementsByType("player") for k, v in pairs(players) do if isElementStreamedIn(v) and v ~= getLocalPlayer() then setPlayerNametagShowing(v, false) table.insert(g_StreamedInPlayers, v) end end end addEventHandler("onClientResourceStart", resourceRoot, onClientResourceStart)
-
Editei um script de Prender o jogador que baixei da internet, ele obtém o jogador através do getPlayerFromPartialName. Gostaria de obter o jogador pelo script de ID, assim como no FiveM, aquele ID que aparece na cabeça do Player. Segue o código do script do ID e a função onde gostaria de obter o player pelo ID: function Start_Id ( _, acc ) if eventName == "onPlayerLogin" then setElementData ( source, "ID", getAccountID(acc) or "N/A" ) outputChatBox ( "#00ff00✘ #ffffffLOGIN #00ff00✘➺ #ffffffNick: #00ff00 ( ".. getPlayerName(source) .." #00ff00) #ffffffID: #00ff00( "..(getAccountID(acc) or "N/A") .." )", root, 255,255,255,true) elseif eventName == "onPlayerLogout" then removeElementData( source, "ID" ) outputChatBox ( "#00ff00✘ #ffffffLOGIN #00ff00✘➺ #ffffffNick: #00ff00 ( ".. getPlayerName(source) .." #00ff00) #ffffffDeslogou.", root, 255,255,255,true) elseif eventName == "onResourceStart" then for _, player in pairs(getElementsByType("player")) do local acc = getPlayerAccount(player) if not isGuestAccount(acc) then setElementData( source, "ID", getAccountID(acc) or "N/A" ) end end end end addEventHandler("onResourceStart", resourceRoot, Start_Id) addEventHandler("onPlayerLogout", root, Start_Id) addEventHandler("onPlayerLogin", root, Start_Id) function getPlayerID(id) v = false for i, player in ipairs (getElementsByType("player")) do if getElementData(player, "ID") == id then v = player break end end return v end --============================================================================================================================-- --=============================-- ----------- ID PLAYER ------------ --=============================-- function getnick(player, command, id, ...) if(id) then local playerID = tonumber(id) if(playerID) then local Player2 = getPlayerID(playerID) if(Player2) then outputChatBox ( "#00ff00✘ #ffffffINFO #00ff00✘➺ #ffffff Nome do Jogador #00ff00" .. getPlayerName(Player2) .."", player, 255,255,255,true) else outputChatBox ( "#00ff00✘ #ffffffERRO #00ff00✘➺ #ffffff O Jogador(a) de ID: #00ff00( " .. id .. " ) #ffffffNão Foi Encontrado!", player, 255,255,255,true) end else outputChatBox ( "#00ff00✘ #ffffffERRO #00ff00✘➺ #ffffff ID: #00ff00( " .. id .. " ) #ffffffInválido!", player, 255,255,255,true) end else outputChatBox ( "#00ff00✘ #ffffffERRO #00ff00✘➺ #ffffffUse /id #00ff00[#ffffffID#00ff00]", player, 255,255,255,true) end end addCommandHandler("id", getnick) Função onde gostaria de obter o nome do player por ID: function colocanavtr (police, _, name) if hasObjectPermissionTo(police, "function.Prender") then local preso = getPlayerFromPartialName(name) -- Penso que tenha que alterar neste local. local px, py, pz = getElementPosition (police) local bx, by, bz = getElementPosition (preso) local dist = getDistanceBetweenPoints3D (px, py, pz, bx, by, bz) if not preso then return outputChatBox('#bebebe Jogador invalido.', police, 255, 255, 255, true) end if preso == police then return outputChatBox('#bebebe Você não pode prender a si mesmo.', police, 255, 255, 255, true) end if getPlayerWantedLevel(preso) == 0 then return outputChatBox('#bebebe Este jogador não está sendo procurado.', police, 255, 255, 255, true) end if getPedOccupiedVehicle(police) then return outputChatBox('#bebebe Você não pode prender de dentro da viatura.', police, 255, 255, 255, true) end if getPedOccupiedVehicle(preso) then return outputChatBox('#bebebe Você não pode prender um bandido enquanto ele estiver dentro de um veículo.', police, 255, 255, 255, true) end if dist >= 2 then return outputChatBox('#bebebe Você precisa chegar mais perto para prender.', police, 255, 255, 255, true) end setElementData (preso, 'navtr', true) addEventHandler('onPlayerCommand', preso, onCommand) local vtr = carros[police] setElementData (vtr, 'compreso', true) attachElements (preso, vtr, 0.2, -1.5, 0, 0,0,90) setElementFrozen (preso, true) toggleAllControls (preso, false) takeAllWeapons (preso) setPedAnimation (preso, 'ped','CAR_dead_LHS') vrx, vry, vrz = getElementRotation(vtr) setElementRotation(preso, vrx, vry, vrz+83) warpPedIntoVehicle (police, vtr) outputChatBox('#bebebeLeve o preso para a delegacia mais próxima #00ffff(sirenes azuis).', police, 255, 255, 255,true) end end addCommandHandler ('prender', colocanavtr) Se puderem me ajudar, agradeço!
-
Ajuda para mexer com SaveData ou algo do tipo
biscoitoimproprio posted a topic in Programação em Lua
local drawDistance = 15 g_StreamedInPlayers = {} function onClientRender() local cx, cy, cz, lx, ly, lz = getCameraMatrix() for k, player in pairs(g_StreamedInPlayers) do if isElement(player) and isElementStreamedIn(player) then do local vx, vy, vz = getPedBonePosition(player, 4) local dist = getDistanceBetweenPoints3D(cx, cy, cz, vx, vy, vz) if dist < drawDistance and isLineOfSightClear(cx, cy, cz, vx, vy, vz, true, false, false) then local x, y = getScreenFromWorldPosition(vx, vy, vz + 0.3) if x and y then local ID = getPlayerID(player) local w = dxGetTextWidth(ID, 0.1, "default-bold") local h = dxGetFontHeight(1, "default-bold") dxDrawText("#ffffff"..ID.."", x - 1 - w / 1, y - 1 - h - 12, w, h, tocolor(0, 0, 0), 1.20, "default-bold", "left", "top", false, false, false, true, false) end end end else table.remove(g_StreamedInPlayers, k) end end end addEventHandler("onClientRender", root, onClientRender) function onClientElementStreamIn() if getElementType(source) == "player" and source ~= getLocalPlayer() then setPlayerNametagShowing(source, false) table.insert(g_StreamedInPlayers, source) end end addEventHandler("onClientElementStreamIn", root, onClientElementStreamIn) function onClientResourceStart(startedResource) visibleTick = getTickCount() counter = 0 local players = getElementsByType("player") for k, v in pairs(players) do if isElementStreamedIn(v) and v ~= getLocalPlayer() then setPlayerNametagShowing(v, false) table.insert(g_StreamedInPlayers, v) end end end addEventHandler("onClientResourceStart", resourceRoot, onClientResourceStart) function getPlayerFromID(ID) return call(getResourceFromName("ID_System"), "getPlayerFromID", tonumber(ID)) end function getPlayerID(player) return getElementData(player,"ID") end Preciso muito de ajuda, irei abrir um servidor de Role-Play e fiz esse script de id, mas gostaria de saber se alguem poderia me ajudar, a duvida seria como deixar o id fixo, tipo quando alguem sair do servidor com exemplo ID 1, quando ela voltar esteja com o mesmo id. Alguem me ajuda? -
English Hello. Hello, I'm sorry for my English. Well I made this script to change the nick of the player to an ID, and it was not duplicated, it's not working as it should. Could you help with this or see something similar? OBS: I've started to script. Português (Brazil) Olá já venho desculpar meu inglês, Bom eu fiz este script para que trocasse o nick do player para um ID, E não fosse Duplicado, ele não está funcionando como deveria, Poderia ajudar com este ou ver algo semelhante ? OBS: Começei ontém a fazer script local ids = {} function assignID() for i=1,getMaxPlayers() do if not ids[i] then ids[i] = source setElementData(source,"id",i) break end end end addEventHandler("onPlayerJoin",root,assignID) function startup() ids = {} for k, v in ipairs(getElementsByType("player")) do local id = setElementData(v,"id",k) ids[k] = v end end addEventHandler("onResourceStart",resourceRoot,startup) function freeID() local id = getElementData(source,"id") if not id then return end ids[id] = nil end addEventHandler("onPlayerQuit",root,freeID) function getPlayerID ( player ) return getElementData( player, "id") end function getPlayerFromId ( theID ) if theID then local theID = tonumber(theID) local theplayer for index,player in ipairs(getElementsByType("player")) do if getElementData(player ,"id") == theID then theplayer = player end end return theplayer else return false end end
-
Boton8 = guiCreateLabel(137, 142, 111, 25, "LEGAJO2", false, Ventana);guiSetProperty(Boton8, "NormalTextColour", "FF27F512") addCommandHandler("p", function() local team = getPlayerTeam(localPlayer) if team then local teamName = getTeamName(team) if teamName == "MOBSA" then local getGui = guiGetVisible(Ventana) if not getGui then guiSetVisible(Ventana, true) guiSetText(Boton10, getPlayerMoney(localplayer)) guiSetText(Boton2, teamName) guiSetText(Boton4, getPlayerName(localPlayer)) guiSetText(Boton8, ID ) --<<Aca necesitaria poner la id del jugador, digamos que aparesca su id showCursor(true) else guiSetVisible(Ventana, false) showCursor(false) print ("Tu trabajas de chofer actualmente") end else print ("Tu trabajas de chofer actualmente") end end end ) Buenas, mi duda es como sacar la id de los jugadores? Veo cual son porque quedan guardadas pero como hago para volcar esos datos en estos textos? Gracias!
-
Hi! I have a faction panel, and I want to do that I have a list of faction vehicles with label, and when I click one of these, give me informations of the clicked vehicle. With the members(players) I can do it, because there is a getPlayerFromName. But with vehicles how can I do this?