Jump to content

Search the Community

Showing results for tags 'scripting'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • 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


Last Updated

  • Start


Filter by number of...


  • Start



About Me

Member Title





  1. Hello guys, does anyone have an idea how to send Lua values to JavaScript to display them in the game, or for example, to show a list of players or run a JavaScript function?
  2. https://github.com/OwlGamingCommunity/MTA i wanted to learn scripting to make an rp server i downloaded this server but the login panel didnt work plz help me
  3. Xwaw

    Ped scripting

    Ok so recently I was thinking of reworking the police from gta san andreas to mta san andreas and making a police waves style minigame you have to survive. I have an idea how to do it but I don't know if the engine will allow me to do it. So my question is, if I want to program a ped to get to the player's position avoiding obstacles (without jumping over them) with the a* algorithm, am I able to do that? Because the last time I did this type of thing, one such npc could crash my entire game. As for the respawn of such bots, it would work more or less in the same way as in the original version of gta sa
  4. The problem is that there is a ped that runs straight, and there are also drawn lines that show how the ped is looking. And I would like to make this ped when it notices an obstacle with a given line "processOfLineSight" to paint it red from the green line. But unfortunately when the ped runs and sees an obstacle on the right side, the middle line lights up instead of the one on the right side. It's the same with the rest, the middle line, when it notices something, the left line lights up and so on. Can someone help me with this? local direction = 0 local testPed = createPed(0,2480.52344, -1649.07202, 103.77657, direction) local lineLength = -10 local distanceOfStart = 0 local color = {{255, 0, 0},{0, 255, 0}} local colorSet = 2 function drawLineFromHead(ped, angle) if isElement(ped) and getElementType(ped) == "ped" then local pedX, pedY, pedZ = getElementPosition(ped) local pedRotation = getPedRotation(ped) + angle local pedRotationRad = math.rad(pedRotation) local lineEndX = pedX + lineLength * math.sin(pedRotationRad) local lineEndY = pedY - lineLength * math.cos(pedRotationRad) dxDrawLine3D(pedX, pedY, pedZ + distanceOfStart, lineEndX, lineEndY, pedZ+ distanceOfStart, tocolor(color[colorSet][1], color[colorSet][2], color[colorSet][3]), 2) local hit = processLineOfSight(pedX, pedY, pedZ + distanceOfStart, lineEndX, lineEndY, pedZ+ distanceOfStart, true, false, false) if hit then colorSet = 1 else colorSet = 2 end end end function drawLinesForPerspective(ped) drawLineFromHead(ped, -45) drawLineFromHead(ped, 0) drawLineFromHead(ped, 45) end setPedControlState(testPed, "forwards", true) -- Main Loop addEventHandler("onClientRender", root, function() drawLinesForPerspective(testPed) local x, y, z = getElementPosition(getLocalPlayer()) end)
  5. Hey guys, I'm doing freelance on MTA. Prices are very cheap, I accept almost any pay method. Can do: Lua scripting, web development (React/Vue) + Backend (express.js), UI/UX design, simple low poly GTA SA style models, shaders Portfolio: https://imgur.com/a/39PFt56 (click see more) Shaders portfolio: I don't respond on forum, text me on discord borsuk#1102
  6. Welcome back In general, I'm currently making a scoreboard under Tab with a list of players, so I have a few questions... 1. How to make a list that shows elements that are outside the image under the scroll, e.g. when scrolling html or guiCreateGridList function but with more elements than its scale offers (Using dxDraw family functions) 2. Or is there a possibility to blur something like placing a gradient so that some dxDraw elements line up in a shape other than a square or rectangle. If you still don't know what I mean, here's an example of what I want to do: I have a plan how the list of players (scoreboard TAB) will look like after pressing the [TAB] key and in general, if there are too many of these players, it is known that 1920x1080x monitor screen will not accommodate, for example, 400 players in the index so that it is visible, so you will need to add some scrolling system and here is my problem because I've never done anything like that and I don't know if it's possible to create a dxDraw function that simulates a guiGridList or add a gradient that will freeze most of the list so that it is visible for the computer screen, but not for us. Please give me an example with a detailed explanation
  7. Xwaw

    Nitro value

    Hello Is it possible to somehow check the value of how much NOS you have in the vehicle because I am looking for but not which do not seem to work as if they were not at all. I need this value to make a bar that will show how much nitro the vehicle has.
  8. Hi I wanted to learn how to create my own shaders for this game from lighting starting to moving texture on the wall. I would really like someone to give me a link to a page where I can find all the functions or if someone wants to explain to me what it is all about
  9. How to check the recoil of a weapon. Notice that when you shoot, for example, with an ak47, it starts with a slight recoil and after 3 seconds when you hold it, you have a large recoil and it stops at this recoil, then the bullets fly in all directions when you are, for example, on poor level. Therefore, is there something to check the recoil of a given weapon so that the int changes at the time of the initial recoil and the final recoil? Maybe the getWeaponProperty function but I don't see anything that could check it because "spread" for example stops on the same recoil.
  10. Hello, I recently returned to making a server after a year and I wanted to remind myself how the "source", "root", "this", "sourceResource", "sourceResourceRoot", "client" etc. Elements worked. Unfortunately, when I checked the MTA wiki, I didn't understand any of these elements. In general, the best help would be if someone explained to me how these elements work on examples for AddEventHandler because in mta wiki there is only one example for a "source" and I guess "root"? element
  11. Hello MTA... Sorry for asking rookie questions so frequently. So, I am trying to make NPC's on the map walk around. I know I will have to give them a path to walk (Which I don't know how to do, but I'll get there). Right now I am finding it hard to get my NPC to even move. This is the very basic coding I have so far. Pedestrians.lua function pedLoad() local thePed = createPed ( 106, 2492, -1673, 13.25, 200) setPedAnimation(thePed, "ped", "walk_gang1", -1, true, true, false, true) outputChatBox("This command did something", player, 100, 255, 100) end addEventHandler ( "onResourceStart", getResourceRootElement(), pedLoad ) Now this works properly: local thePed = createPed ( 106, 2492, -1673, 13.25, 200) It creates my NPC and rotates him 200 degrees... But the rest of the coding doesn't do anything. I have tried setControlState: function pedLoad() local thePed = createPed ( 106, 2492, -1673, 13.25, 200) setControlState(thePed, "walk", true) setControlState(thePed, "forwards", true) outputChatBox("This command did something", player, 100, 255, 100) end addEventHandler ( "onResourceStart", getResourceRootElement(), pedLoad ) And nothing happened... I know with setControlState I also have to change his camera to move in different directions but I can't get him to move at all... So, if someone could help me I would appreciate it. Thank You.
  12. Eu tenho um pequeno problema, na hora de entrar no veículo depois de pegar o personagem, o veículo começa a voar, eu preciso de ajuda e se eu sou novo nesse Scripting. Preciso de sua ajuda. function AgarrarSoltar(source, target) local ID = getElementData(target , config['serverInfo']['id']) or 0 local rotpX = 90 local rotpY = 0 local rotpZ = getElementRotation(target) local rotvX,rotvY,rotvZ = getElementRotation(source) local rotX = rotpX - rotvX local rotY = rotpY - rotvY local rotZ = rotpZ - rotvZ local Agarrado = getElementData(target, "SS:Agarrado") or false if Agarrado == false then attachElementToElement(target, source, 0, 0.4 , 0.3 , rotX, rotY, rotZ) setElementData(target,"SS:Agarrado",true) setPedAnimation(source, "CARRY", "crry_prtial", 0, false, false, false, false) setPedAnimation(target, "ped", "CAR_dead_LHS", false, false) exports["CzInventory"]:sendNotification(source, "info", "Agarraste "..removeHex(getPlayerName(target)).." ["..(getElementData(target, config['serverInfo']['id']) or 0).."].") else detachElementFromElement(target, source, 0, 0.4 , 0.3 , rotX, rotY, rotZ) setElementData(target,"SS:Agarrado",false) setPedAnimation(target) exports["CzInventory"]:sendNotification(source, "info", "Soltaste"..removeHex(getPlayerName(target)).." ["..(getElementData(target, config['serverInfo']['id']) or 0).."].") end end addEvent ( "SS:Agarrar", true ) addEventHandler ( "SS:Agarrar", root, AgarrarSoltar)
  13. fikasS

    mysql error

    Hi, I have a little problem! dbPoll failed; The "character names" field has no default value First of all, what is its default value? because this is an outdated mysql that was perfected 5 years ago. dbquery, db_free db_pool functions. Thank you in advance for your help. CODE: local hostname = "" local username = "...username" local password = ".....pass" local database = "databasename" local results = {} addEventHandler("onResourceStart", resourceRoot, function() dbHandler = dbConnect("mysql","dbname=".. database ..";host="..hostname, username, password, "autoreconnect=1") if not dbHandler then outputDebugString("#1 failed connect") cancelEvent(true) else outputDebugString("#2 succesful connect") end end) function query_free(q,poll) local this = #results + 1 results[this] = dbQuery(dbHandler, q) if poll then local result, num_affected_rows, last_insert_id = dbPoll(results[this], -1) if result == nil then dbFree(results[this]) return this, nil elseif result == false then dbFree(results[this]) return this, nil else dbFree(results[this]) return this, tonumber(last_insert_id) end end dbFree(results[this]) return this end function getConnection() return dbHandler end
  14. Galera to fazendo um sistema de painel q vc digita no painel tipo 255, 0, 0 dentro de um carro e seta a cor vermelha no carro q e do rgb 255, 0, 0 e etc. mas da forma que achei que era possivel ao abrir o painel e digitar a cor em rgb eu fiz uma função que na teoria era pra pegar oq foi digitado na editbox e setar oq foi digitado na editbox como cor do carro usando setVehicleColor so q n aparece nada e n seta cor no carro mais se o carro ta vermelho e coloca tipo 255, 0, 0 na editbox e da ok a cor sempre muda pra preto espero q de para entender function SetarCor (playerSource, getMsg) --local mensagem = tonumber(getMsg) local uVehicle = getPedOccupiedVehicle( playerSource ) if isPedInVehicle( playerSource ) then if uVehicle then -- if mensagem == "Vermelho" then setVehicleColor( uVehicle, tonumber(getMsg)) end end --end end addEvent("SetarCor", true) addEventHandler("SetarCor", getRootElement(), SetarCor) PARTE DO CLIENT function rgbtrigger (button, state) if painel == true then if button == "left" and state == "down" then if isCursorOnElement(screenW * 0.6384, screenH * 0.5885, screenW * 0.7379, screenH * 0.6185) then local getMsg = tostring(getElementData(msgstaff, "CMT_Txt")) removeEventHandler("onClientRender", root, dx) triggerServerEvent("SetarCor", getLocalPlayer(), localPlayer, getMsg) painel = false showCursor(false) end end end end addEventHandler("onClientClick", root, rgbtrigger)
  15. Hello, this is my problem: I made a cigarette system for my server but I've been testing it and I found only 1 problem, when the player "spams" the command "/smoke" the part where the object it's deleted doesn't work corectly and DO NOT delete the object. How could I solve this? The part where the system deletes the object: setPedAnimation(thePlayer, "-", "-",false,false,false,false) local cancelsmoke = setTimer(function() exports.pAttach:detach(smoking,thePlayer) destroyElement(smoking) iprint("Destroyed") end, 2500, 1) If the player puts the command it works, the bug only happens when the player spam the command
  16. I've been trying to save the position of the player's character and it saves... but in a new table, not in the main one where its the account's name, the character's name and the rest. -> This is what happens<- This is the code I'm using for the "character money, position, and health" // i translated some concepts to english so you can understand easly what I'm trying to make: (server-side) function saveDataCharacter() local x, y, z = getElementPosition(source) local money = getPlayerMoney(source) local health = getElementHealth(source) local sendInfo = exports.mysql:_Exec("INSERT INTO characters (x,y,z, money, health) VALUES (?,?,?,?,?)", x, y, z, money, health) if (sendInfo) then iprint("Data saved") else iprint("Error saving") end end end addEventHandler("onPlayerQuit", getRootElement(), saveDataCharacter)
  17. Well, it's too late to delete it, so if a mod or admin see this, please delete this or move it, I solved the problem
  18. I made a login menu for my server, I wanted to put some buildings as a background so I used setCameraMatrix, all works perfectly, but when I try to cancel the camera position and the music (I added playSound too) it doesn't work and the camera keeps far from the player, and the music keeps playing Client-Side function fondoLogin(thePlayer) local cancion = playSound("loginSoundtrack.mp3") setSoundVolume(cancion, 0.5) setElementPosition(thePlayer, -1400.2099609375,106.88999938965,1032.2734375) setElementInterior(thePlayer, 1) setCameraMatrix ( 1709.7098388672,-1449.96484375,151.87727355957, 1537.9990234375,-1276.736328125,238.57434082031, 0, 100 ) triggerServerEvent(source, "parartodo", source) end addEvent("posicionar", true) addEventHandler("posicionar", getLocalPlayer(), fondoLogin) ---------Suposed to stops the music and cameraMatrix---------------- function parartodo(thePlayer, cancion) setCameraTarget (thePlayer) stopSound(cancion) end addEvent("pararmusicaycamara", true) addEventHandler("pararmusicaycamara", getLocalPlayer(), parartodo) Server-Side function registroHRP(user, clavecreada) if(addAccount(user, clavecreada))then outputChatBox("Bienvenido") triggerClientEvent(source, "cerrar", source) logIn(source, getAccount(user, clavecreada), clavecreada) setElementPosition(source, 209.41818237305,-33.872188568115,1001.9296875) setElementInterior(source, 1) setElementDimension(source, 1) setPedRotation(source, 180) triggerClientEvent(source, "pararmusicaycamara", source) else outputChatBox("La cuenta ya existe.") end end -----------"triggerClientEvent(source, "pararmusicaycamara", source)" doesn't work--------------
  19. I have been editing a vehicle script to make it work in a RP but I have a problem when executing the command to lock the vehicle, it locks perfectly from the outside, nobody can enter unless the owner unlocks the vehicle, but the problem is that if the owner locks inside, you can still go out. I did some research and found that something could be done with cancelEvent and "onClientVehicleStartExit", I've tried everything but nothing seems to work for me with that command, any advice? This is the code: function setPlayerVehicleLocked(player, vehicle) local vehname = vehicle:getName() if (vehicle:getData("vehicles:locked") == 1) then vehicle:setData("vehicles:locked", 0) vehicle:setLocked(false) player:outputChat("Desbloqueaste tu "..vehname..".", 214, 37, 37) connection:exec("UPDATE vehicles SET locked=? WHERE id=? AND owner=?", 0, vehicle:getData("vehicles:id"), vehicle:getData("vehicles:owner")) elseif (vehicle:getData("vehicles:locked") == 0) then vehicle:setData("vehicles:locked", 1) vehicle:setLocked(true) player:outputChat("Bloqueaste tu "..vehname..".", 141, 229, 22) connection:exec("UPDATE vehicles SET locked=? WHERE id=? AND owner=?", 1, vehicle:getData("vehicles:id"), vehicle:getData("vehicles:owner")) end end function onclientVehicleStartExit() if (vehicle:getData("vehicles:locked") == 0) then cancelEvent(onVehicleStartExit) end end ("onclientVehicleStartExit", root, onVehicleStartExit)
  20. Hello guys I recently had ideas for setting up a server in MTA. I heard a bit about lua and its characteristics. I wanted to know what programming languages are needed to set up a game server in MTA and manage it from beginner to professional. thank you.?
  21. I'm having trouble creating a gun shop But when I press b4 (buy m4) on GUI I face a problem And he says to me Client triggered server side event, but event is not added servers Client triggered server side event givem4, but event is not added serverside GUIEditor = { button = {}, staticimage = {}, label = {} } yoyoWnd = guiCreateWindow(114, 139, 575, 311, "gun panel ~~~ by Yoyo", false) guiWindowSetSizable(yoyoWnd, false) guiSetProperty(yoyoWnd, "CaptionColour", "FFFE0505") guiSetVisible(yoyoWnd,false) GUIEditor.staticimage[1] = guiCreateStaticImage(10, 21, 67, 62, ":metaa/img/32.png", false, yoyoWnd) GUIEditor.staticimage[2] = guiCreateStaticImage(254, 21, 69, 62, ":metaa/img/29.png", false, yoyoWnd) GUIEditor.staticimage[3] = guiCreateStaticImage(-241, 0, 70, 59, ":metaa/img/30.png", false, GUIEditor.staticimage[2]) GUIEditor.staticimage[4] = guiCreateStaticImage(496, 21, 69, 62, ":metaa/img/27.png", false, yoyoWnd) GUIEditor.staticimage[5] = guiCreateStaticImage(10, 125, 67, 61, ":metaa/img/30.png", false, yoyoWnd) GUIEditor.staticimage[6] = guiCreateStaticImage(256, 125, 67, 61, ":metaa/img/31.png", false, yoyoWnd) GUIEditor.staticimage[7] = guiCreateStaticImage(10, 240, 67, 61, ":metaa/img/22.png", false, yoyoWnd) GUIEditor.staticimage[8] = guiCreateStaticImage(496, 240, 69, 60, ":metaa/img/23.png", false, yoyoWnd) GUIEditor.staticimage[9] = guiCreateStaticImage(496, 125, 65, 61, ":metaa/img/33.png", false, yoyoWnd) b1 = guiCreateButton(10, 83, 67, 21, "uzi", false, yoyoWnd) guiSetProperty(b1, "NormalTextColour", "FF6CFE00") b2 = guiCreateButton(257, 83, 67, 21, "mp5", false, yoyoWnd) guiSetProperty(b2, "NormalTextColour", "FF6CFE00") b3 = guiCreateButton(498, 83, 67, 21, "spas", false, yoyoWnd) guiSetProperty(b3, "NormalTextColour", "FF6CFE00") b4 = guiCreateButton(256, 186, 67, 21, "m4", false, yoyoWnd) guiSetProperty(b4, "NormalTextColour", "FF6CFE00") b5 = guiCreateButton(10, 186, 67, 21, "ak-47", false, yoyoWnd) guiSetProperty(b5, "NormalTextColour", "FF6CFE00") b6 = guiCreateButton(496, 186, 67, 21, "lancher", false, yoyoWnd) guiSetProperty(b6, "NormalTextColour", "FF6CFE00") GUIEditor.button[1] = guiCreateButton(77, 261, 71, 23, "", false, yoyoWnd) b8 = guiCreateButton(77, 261, 71, 23, "pistole", false, yoyoWnd) guiSetProperty(b8, "NormalTextColour", "FF6CFE00") b10 = guiCreateButton(425, 260, 71, 23, "Silenced", false, yoyoWnd) guiSetProperty(b10, "NormalTextColour", "FF6CFE00") GUIEditor.label[1] = guiCreateLabel(151, -51, 46, 35, "", false, yoyoWnd) cl = guiCreateButton(240, 258, 98, 35, "close", false, yoyoWnd) guiSetProperty(cl, "NormalTextColour", "FFFF0000") function yoyo () guiSetVisible (yoyoWnd,true) showCursor (true) end bindKey ( "F6","down",yoyo) addEventHandler ("onClientGUIClick",root, function() if ( source == cl ) then guiSetVisible ( yoyoWnd , false) showCursor ( false ) end end ) function buym4() if ( source == b4) then showCursor(false) guiSetVisible(window1,false) triggerServerEvent("givem4", localPlayer) end end addEventHandler("onClientGUIClick", root, buym4) function buym4() local playerMoney = getPlayerMoney(source) if (playerMoney >= 40000) then takePlayerMoney(source,40000) giveWeapon(source,31,200) end end addEvent("givem4",true) addEventHandler("givem4", root, buym4) function buym4() if ( source == b4) then showCursor(false) guiSetVisible(window1,false) triggerServerEvent("givem4", localPlayer) end end addEventHandler("onClientGUIClick", root, buym4) HELP PLSSS
  22. Hi, im trying to prevent player from putting off crate, please help me if you know how to fix it. thats how crate is attached to fork: [lua] skrzynieGraczy[client] = createObject(obiekty[praca].idObiektu, 0, 0, 0) setElementCollisionsEnabled(skrzynieGraczy[client],false) setElementFrozen(skrzynieGraczy[client],true) stopObject(skrzynieGraczy[client]) attachElements(skrzynieGraczy[client],wozkiGraczy[client],0,0.5,0.3,0,0,0) [/lua] Here is video that showing my problem: https://gyazo.com/ff5ab17194ce5a99b0c8f972ce20c5fc
  23. Mas não consigo, algo da errado no 'isElementInRange', alguém poderia me ajudar? addCommandHandler("car", function(thePlayer,veh) local x, y, z = getElementPosition (thePlayer) local veh = getElementsByType('vehicle') if isElementInRange(veh, x, y, z, 25) then outputChatBox("teste",thePlayer,255,255,255,true) end end end ) Print do erro: https://prnt.sc/12bhy03
  24. Anyone can send me a working yt mp3 converter API? Or how to create one, to play music from youtube on my server?
  25. Map loader This is a map loader, which can let specific players download a map of choice. Maps will be generated clientside and the resource is capable of loading extreme large maps. Loading the map will be done with a speed the pc can handle. The code execution time will be reduced to circa 10 ms. Which is the frame time of a player with 100 fps. So technically when you have 100 fps you still have 98/100 fps when this resource is loading a map. But this is based on running only this resource and based on predictions/knowledge. Which you can't trust... The .map files are unloaded afterwards reading them. But the resource will keep a buffer of the processed data until no more players are using that map. This will speed up the resource when it is used for multiply players. The resource can be managed with the following functions (serverside): loadMapForTarget() Require: element player/root, string mapName Returns: boolean success, string message unloadMapForTarget() Require: element player/root, string mapName Returns: boolean success, string message getPlayerDownloadProgress() Require: element player Returns: int percentages or boolean false Version 1.0.1 or higher getPlayerMapStatus() Require: element player, string mapName Returns: string status or boolean false Status list: string "DOWNLOADING" -- Player is downloading the map. string "LOADING" -- Player is generating/loading the map string "LOADED" -- Player has loaded the map. boolean false -- Player value is invalid or the player hasn't started downloading this map. Events(serverside): "onPlayerLoadedMap" Source: element player Parameters: string mapName int loadTime "onPlayerUnloadedMap" Source: element player Arguments: string mapName Version 1.0.1 or higher "onPlayerCancelMapDownload" Source: element player Arguments: string mapName Events(clientside): "onClientPlayerLoadedMap" Source: element localPlayer Arguments: string mapName, int loadTime "onClientPlayerUnloadedMap" Source: element localPlayer Arguments: string mapName The same information about the functions and the events can be found inside the meta.xml Element types that are supported: objects, peds, vehicles, markers and pickups If you found any bugs, which might be in there. Don't be shy and let me know, I will exterminate them. And don't forget, this resource require some rights in order to read map files from other resources: DOWNLOAD 1.0.2 For developers a quick source code preview: Server Client
  • Create New...