Jump to content

Search the Community

Showing results for tags 'scripting'.

  • 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

  1. Eae rapaziada, tava fazendo um painel de login aqui e ele ta todo funcional já, só que tem um probleminha que ta tenso, não to conseguindo achar onde está errado. ---------- client.lua ---------- local sW, sH = guiGetScreenSize() loadstring(exports.dgs:dgsImportFunction())() DGS = { e = {} } color = {} addEventHandler("onClientResourceStart", resourceRoot, function() DGS.e[1] = dgsCreateEdit(0.42, 0.47, 0.16, 0.04, "", true) dgsSetAlpha(DGS.e[1], 0.75) dgsSetProperty(DGS.e[1], "NormalTextColour", "FE000000") dgsSetProperty(DGS.e[1], "font", "default-bold") DGS.e[2] = dgsCreateEdit(0.42, 0.55, 0.16, 0.04, "", true) dgsSetAlpha(DGS.e[2], 0.75) dgsSetProperty(DGS.e[2], "NormalTextColour", "FE000000") dgsSetProperty(DGS.e[2], "font", "default-bold") end) function dxLogin() dxDrawRectangle(sW * 0.3806, sH * 0.2167, sW * 0.2396, sH * 0.5678, tocolor(25, 30, 40, 160), false) dxDrawRectangle(sW * 0.3806, sH * 0.2156, sW * 0.2396, sH * 0.0833, tocolor(25, 40, 100, 100), false) dxDrawText("ATLANTIC © 2021", sW * 0.3806, sH * 0.2156, sW * 0.6201, sH * 0.2978, tocolor(200, 200, 200, 255), 2.00, "default-bold", "center", "center", false, false, false, false, false) dxDrawRectangle(sW * 0.3806, sH * 0.2989, sW * 0.2396, sH * 0.0044, tocolor(0, 0, 0, 180), false) color[1] = tocolor(200, 200, 200, 255) if cursorOnPosition(sW * 0.3875, sH * 0.6778, sW * 0.1042, sH * 0.0956) then color[1] = tocolor(0, 255, 0, 255) end dxDrawRectangle(sW * 0.3875, sH * 0.6778, sW * 0.1042, sH * 0.0956, tocolor(70, 75, 83, 175), false) -- Botão login color[2] = tocolor(200, 200, 200, 255) if cursorOnPosition(sW * 0.5090, sH * 0.6778, sW * 0.1042, sH * 0.0956) then color[2] = tocolor(255, 0, 0, 255) end dxDrawRectangle(sW * 0.5090, sH * 0.6778, sW * 0.1042, sH * 0.0956, tocolor(70, 75, 83, 175), false) -- Botão register dxDrawText("USER :", sW * 0.4229, sH * 0.4267, sW * 0.5035, sH * 0.4611, tocolor(155, 155, 155, 200), 1.00, "default-bold", "left", "bottom", false, false, false, false, false) dxDrawText("REGISTER :", sW * 0.4229, sH * 0.5100, sW * 0.5035, sH * 0.5444, tocolor(155, 155, 155, 200), 1.00, "default-bold", "left", "bottom", false, false, false, false, false) dxDrawText("Login", sW * 0.3875, sH * 0.6778, sW * 0.4917, sH * 0.7733, color[1], 1.20, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("Create Account", sW * 0.5090, sH * 0.6778, sW * 0.6132, sH * 0.7733, color[2], 1.20, "default-bold", "center", "center", false, false, false, false, false) showCursor(true) addEventHandler('onClientClick', root, function(btn, state) if btn == 'left' and state == 'down' then if cursorOnPosition(sW * 0.3875, sH * 0.6778, sW * 0.1042, sH * 0.0956) then local g_user, g_pass = dgsGetText(DGS.e[1]), dgsGetText(DGS.e[2]) triggerServerEvent('playerRequestLog', getLocalPlayer(), g_user, g_pass) end end end) end addEventHandler('onClientRender', root, dxLogin) addEvent('playerLogged', true) function playerLogged() removeEventHandler('onClientRender', root, dxLogin) destroyElement(DGS.e[1]) destroyElement(DGS.e[2]) showCursor(false) end addEventHandler('playerLogged', getRootElement(), playerLogged) addEvent('playerRegisterSucess', true) function playerRegisterSucess() destroyElement(GUI.window[2]) end addEventHandler('playerRegisterSucess', getRootElement(), playerLogged) function cursorOnPosition(x, y, w, h) if (not isCursorShowing()) then return false end local mx, my = getCursorPosition() local sx, sy = guiGetScreenSize() local cx, cy = (mx*sx), (my*sy) if (cx > x and cx < x + w) and (cy > y and cy < y + h) then return true else return false end end Creio que seja no client mas, vou colocar aqui o lado server tbm: ---------- server.lua ---------- addEvent('playerRequestLog', true) function playerRequestLog(user, pass) if not(user == '') then if not(pass == '') then local account = getAccount(user, pass) if not account then outputChatBox('ERROR: Está conta não existe.', source, 255, 0, 0) else logIn(source, account, pass) triggerClientEvent(source, 'playerLogged', source) outputChatBox('Logado com sucesso. =)', source, 0, 255, 255) end else outputChatBox('Insira uma senha.', source, 255, 0, 0) end else outputChatBox('Insira um username.', source, 255, 0, 0) end end addEventHandler('playerRequestLog', getRootElement(), playerRequestLog) addEvent('playerRequestRegister', true) function playerRequestRegister(reguser, regpass) if not(reguser == '') then if not(regpass == '') then local account = getAccount(reguser, regpass) if (account) then outputChatBox('ERROR: Está conta já existe, insira outro username e senha.', source, 255, 0, 0) else addAccount(reguser, regpass) outputChatBox('Registrado com sucesso, faça o login agora.', source, 0, 255, 255) triggerClientEvent(source, 'playerRegisterSucess', source) end else outputChatBox('Insira uma senha.', source, 255, 0, 0) end else outputChatBox('Insira um username.', source, 255, 0, 0) end end addEventHandler('playerRequestRegister', getRootElement(), playerRequestRegister) O Erro é o seguinte, quando o player não digitar um campo, ou a não existir ele emite um texto no chat(futuramente farei menssagens, é só para teste), só que ta repetindo as frases e muito papo de floodar o chat da um ligo: https://imgur.com/a/S3qPhVk Se poderem me ajudar ai fico grato s2
  2. Server Name: [ENG/EU/HUN]Official Vice City Modded Playground [FUN/DM]OPENBETA TEST EVERY WEEKEND Server IP: 80.99.26.50:22003 It will be a fun game server in the making. There are a lot of community-created scripts on the server that I rewrote for optimization. Please give the server a chance and be a member of a start-up community! The Server is currently only available for testing on weekends, we are constantly developing it. On weekdays, the server is password protected for the time being. The official final opening of the Server is 20.02.2021 17:00 !! We are also looking for a developer with free time, contact us if you are interested! Video: Short clashed tutorial video
  3. I would like to ask if there is a way to make a second weapon, for example to have two M4s, but to shoot differently, e.g. to have a different one with a rate of fire and the other one to deal more hp. Is there a way to do something like this?
  4. Estou fazendo um sistema de Porte de Armas + Venda de Armas. E eu quero deixar assim, só quem pode comprar arma é quem tem o porte de armas. Quem não tem, não consegue comprar as armas. Alguém que possa me ajudar?
  5. I would like to know about two things: 1. Are the server-side and client-side timers dangerous and why? 2. Is it possible to do the function GetTickCount () timer?
  6. So I wanted to ask if someone would explain to me how to make my own shaders, I immediately say that I know there is an MTA page with examples but I don't understand anything of them so I prefer someone to explain it to me and what it is and how to create although the easiest script with shaders
  7. Is there a way to check for collisions where the player is looking without aiming the gun as if the getWorldFromScreenPosition and GetPedTargetCollision functions were combined?
  8. I have one question about client objects, if I use the "TriggerClientEvent" function on the server side script, whether the object that was saved on the client side and will be set with the triggerClientEvent function on the server side, will every player see it and will work in the same way as normally I would call it in the server side script "createObject (object, x, y, z)"? For example, such -- client addEvent("createObject", true) addEventHandler("createObject", root, function(object, x, y, z) createObject(x, y, z) end ) -- server triggerClientEvent(root, "createObject", root, 1372, 0, 0, 5) -- Would that be the same as this? -- server createObject(1372, 0, 0, 5)
  9. So the problem is that there is a function called "animate" https://wiki.multitheftauto.com/wiki/Animate and with this function we can animate the GUI etc ... but there is one problem, because I would like to stop this function at some point and stop animating at some point, there is a way to do that ?
  10. Lua ile ilgili her desteği ücretsiz olarak verebilirim. Piyasaya kopyala - yapıştır yöntemi veya editlenip sunulmuş eklentilerden çok Türkler tarafından kodlanmış eklentilerin bulunmasını istiyorum. Aklınıza takılan en ufak sorunda benimle iletişime geçebilir veya forumda konu açarsanız yardım etmekten memnun olurum. Bunun dışında 0'dan başlamak isteyen veya halihazırda birşeyler bilenler kendi kodladığım sunucuya yardım etmek ve geliştirmek isteyenler benimle iletişime geçebilir. Discord : Asokanta#9451
  11. I started scripting with GUI / dxDraw and would like to do some panning or alpha animation. And the question is how this animate works, I know it is shown on the MTA wiki, but I don't quite understand how, If someone would explain it to me, I would be grateful. By the way, I am sending the function I am talking about ... https://wiki.multitheftauto.com/wiki/Animate
  12. Any ideas how can I calculate the camera perspective's 4 corners into a flat 2D map? Here's what the camera should see: And here is what should it look like from the outside: I need to calculate the 4 points position
  13. My goal is simple, after using GetPedCollisionTarget, I want it to return 3 numbers that correspond to the coordinates of the target that has collision detection, but for this function to return something, you must first aim the weapon. And here is the problem because when the player is aiming, the crosshair is somewhere close but not in the center of the center, and I want to get the coordinates of the target in the center, not somewhere nearby. And here comes the question, is it possible to make GetPedCollisionTarget work but without aiming the weapon? PLEASE HELP
  14. A simple script of dressable characters and deformable faces. You can move every vertex of the head with a simple displacement shader. The script is in test state right now, I'll create a new editor later. Hope you like it.
  15. local SCREEN_X, SCREEN_Y = guiGetScreenSize() local resourceName = getResourceName( getThisResource( ) ) local ONE_HOUR = 3600 local SERVICES_SECTION = 1 --Places to offer services such as house cleaning or mechanics and whatnot local CARS_VEHICLES_SECTION = 2 --Offer to buy or sell a vehicle in this section local REAL_ESTATE_SECTION = 3 --Houses for sale go in this section local COMMUNITY_SECTION = 4 --Advertisements about communities can go here, for example, palomino creek. local JOBS_SECTION = 5 --Advertisements about hiring people or looking for work will go in this section local PERSONALS_SECTION = 6 --People looking for other people go in this section local sections = { "Servicii", "Vehicule", "Proprietăți", "Communitate", "Slujbe", "Personal" } local deleteAny = false local window = { } local viewad = {} local postad = {} function getTime( day, month, timestamp ) local months = { "Ianuarie", "Februarie", "Martie", "Aprile", "Mai", "Iunie", "Iulie", "August", "Septembrie", "Octobrie", "Niembrie", "Decembrie" } local days = { "Sâmbătă", "Luni", "Marți", "Miercuri", "Joi", "Vineri", "Duminică" } local time = nil local ts = nil if timestamp then time = getRealTime( timestamp ) else time = getRealTime( ) end ts = ( tonumber( time.hour ) >= 12 and tostring( tonumber( time.hour ) - 12 ) or time.hour ) .. ":"..("%02d"):format(time.minute)..( tonumber( time.hour ) >= 12 and " PM" or " AM" ) if month then ts = months[ time.month + 1 ] .. " ".. time.monthday .. ", " .. ts end if day then ts = days[ time.weekday + 1 ].. ", " .. ts end return ts end addEvent( resourceName .. ":ad_create_fail", true ) addEventHandler( resourceName .. ":ad_create_fail", root, function() local window = { } --Store all of our window elements local width = 230 -- The width of our window local height = 110 -- The height of our window local x = SCREEN_X / 2 - width / 2 --Where on the screen our window will be located local y = SCREEN_Y / 2 - height / 2 window.window = guiCreateWindow( x, y, width, height, "Eroare de creatie", false ) --Create the window. window.errorLabel = guiCreateLabel( 10, 30, width - 20, 20, "A fost o eroare la introducere.", false, window.window ) window.closeButton = guiCreateButton( 10, 60, width - 20, 40, "Ieși", false, window.window ) addEventHandler( "onClientGUIClick", window.closeButton, function () guiSetVisible( window.window, false ) destroyElement( window.window ) window = { } end ) end ) function createAdvertisement( ) closePostAd() if window and window.window and isElement(window.window) then guiSetEnabled(window.window, false) end guiSetInputEnabled ( true ) local window = { } -- Store all of our window elements local width = 400 -- The width of our window local height = 440 -- The height of our window local x = SCREEN_X / 2 - width / 2 --Where on the screen our window will be located local y = SCREEN_Y / 2 - height / 2 postad.window = guiCreateWindow( x, y, width, height, "Crează Reclamă", false ) --Create the postad. postad.label = { } --This will hold our label elements local labels = { "Telefon", "Nume", "Adresă", "Expiră", "Secțiune", "Reclamă" } --This holds all of the labels we will create here local y = 35 --We'll set y to 30, which is the y coordinate of where our first label will go. for label = 1, #labels do postad.label[ label ] = guiCreateLabel( 10, y * label, 100, 30, labels[ label ], false, postad.window ) end postad.input = { } -- Will hold all of our input elements. y = 30 -- We'll start y off at 25 here to stay even with the inputs. postad.input[ 1 ] = guiCreateEdit( 100, y, width - 120, 30, "", false, postad.window ) --Phone input y = y + 35 postad.input[ 2 ] = guiCreateEdit( 100, y, width - 120, 30, "", false, postad.window ) --Name Input y = y + 35 postad.input[ 3 ] = guiCreateEdit( 100, y, width - 120, 30, "", false, postad.window ) --Address input y = y + 40 postad.input[ 4 ] = guiCreateComboBox( 100, y, width - 120, 95, "", false, postad.window ) --Expiry guiComboBoxAddItem( postad.input[ 4 ], "1 oră" ) guiComboBoxAddItem( postad.input[ 4 ], "2 ore" ) guiComboBoxAddItem( postad.input[ 4 ], "6 ore" ) guiComboBoxAddItem( postad.input[ 4 ], "O zi" ) y = y + 34 postad.input[ 5 ] = guiCreateComboBox( 100, y, width - 120, 125, "", false, postad.window ) --Section for i = 1, #sections do --Loop through each of the 6 advertisement sections. guiComboBoxAddItem( postad.input[ 5 ], sections[ i ] ) end postad.input[ 6 ] = guiCreateMemo( 10, y + 60, width - 20, 90, "", false, postad.window ) --Advertisement for i = 1, 6 do addEventHandler(getElementType( postad.input[i] ) == 'gui-combobox' and 'onClientGUIComboBoxAccepted' or 'onClientGUIChanged', postad.input[i], function( ) for i = 1, 6 do if getElementType( postad.input[i] ) == 'gui-combobox' then if guiComboBoxGetSelected( postad.input[i] ) == -1 then guiSetEnabled( postad.postButton, false ) return end else local text = ( guiGetText( postad.input[i] ) or '' ):gsub("\n", ''):gsub("\r", '') if #text == 0 then guiSetEnabled( postad.postButton, false ) return end end end guiSetEnabled( postad.postButton, true ) end, false ) end postad.postButton = guiCreateButton( 10, height - 100, width - 20, 40, "Postează Reclamă", false, postad.window ) guiSetEnabled( postad.postButton, false ) addEventHandler( "onClientGUIClick", postad.postButton, function () local phone = guiGetText( postad.input[ 1 ] ) or "" local name = guiGetText( postad.input[ 2 ] ) or "" local address = guiGetText( postad.input[ 3 ] ) or "" local advertisement = guiGetText( postad.input[ 6 ] ) local expirySelected = guiComboBoxGetSelected( postad.input[ 4 ] ) local expires = nil if expirySelected == -1 or expirySelected == 0 then expires = ONE_HOUR elseif expirySelected == 1 then expires = ONE_HOUR * 2 elseif expirySelected == 2 then expires = ONE_HOUR * 6 else expires = ONE_HOUR * 24 end local section = tostring( guiComboBoxGetSelected( postad.input[ 5 ] ) + 1 ) closePostAd() triggerServerEvent( resourceName .. ":create_advertisement", getLocalPlayer(), phone, name, address, advertisement, expires, section ) end , false ) postad.closeButton = guiCreateButton( 10, height - 50, width - 20, 40, "Ieși", false, postad.window ) addEventHandler( "onClientGUIClick", postad.closeButton, function () if source == postad.closeButton then closePostAd() end end , false ) end addCommandHandler( "postad", createAdvertisement, false, false ) function closePostAd() if postad and postad.window and isElement(postad.window) then guiSetInputEnabled ( false ) destroyElement( postad.window ) postad = { } if window and window.window and isElement(window.window) then guiSetEnabled(window.window, true) else showCursor( false, false ) end end end function viewAdvertisement( advertisement ) closeViewAd() if window and window.window and isElement(window.window) then guiSetEnabled(window.window, false) end guiSetInputEnabled ( false ) local window = { } local width = 400 local height = 530 local x = SCREEN_X / 2 - width / 2 local y = SCREEN_Y / 2 - height / 2 viewad.window = guiCreateWindow( x, y, width, height, "Vezi reclamă", false ) viewad.label = { } local labels = { "Telefon", "Nume", "Adresă", "Start", "Expiră", "Secțiune", "Reclamă" } local y = 35 for label = 1, #labels do viewad.label[ label ] = guiCreateLabel( 10, y * label, 100, 30, labels[ label ], false, viewad.window ) end viewad.input = { } y = 30 viewad.input[ 1 ] = guiCreateEdit( 100, y, width - 120, 30, advertisement.phone, false, viewad.window ) guiEditSetReadOnly( viewad.input[ 1 ], true ) y = y + 35 viewad.input[ 2 ] = guiCreateEdit( 100, y, width - 120, 30, advertisement.name, false, viewad.window ) guiEditSetReadOnly( viewad.input[ 2 ], true ) y = y + 35 viewad.input[ 3 ] = guiCreateEdit( 100, y, width - 120, 30, advertisement.address, false, viewad.window ) guiEditSetReadOnly( viewad.input[ 3 ], true ) y = y + 35 viewad.input[ 4 ] = guiCreateEdit( 100, y, width - 120, 30, getTime( true, true, advertisement.start ), false, viewad.window ) guiEditSetReadOnly( viewad.input[ 4 ], true ) y = y + 35 viewad.input[ 5 ] = guiCreateEdit( 100, y, width - 120, 30, getTime( true, true, advertisement.expiry ), false, viewad.window ) guiEditSetReadOnly( viewad.input[ 5 ], true ) y = y + 35 viewad.input[ 6 ] = guiCreateEdit( 100, y, width - 120, 30, sections[ tonumber( advertisement.section ) ], false, viewad.window ) guiEditSetReadOnly( viewad.input[ 6 ], true ) viewad.input[ 7 ] = guiCreateMemo( 10, y + 60, width - 20, 90, advertisement.advertisement, false, viewad.window ) guiMemoSetReadOnly( viewad.input[ 7 ], true ) if tonumber( getElementData( localPlayer, "dbid" ) ) == tonumber( advertisement.created_by ) or deleteAny then guiCreateLabel( 100, 245, 200, 25, "Creat de: " .. advertisement.author:gsub("_", " "), false, viewad.window ) viewad.pushButton = guiCreateButton( 10, height - 150, width - 20, 40, "Trimite reclama ($100)", false, viewad.window ) if tonumber( getElementData( localPlayer, "dbid" ) ) ~= tonumber( advertisement.created_by ) then guiSetProperty( viewad.pushButton, 'NormalTextColour', 'FFFF0000' ) end addEventHandler( "onClientGUIClick", viewad.pushButton, function () triggerServerEvent( resourceName .. ":push_advertisement", localPlayer, advertisement.id ) end , false ) end if tonumber( getElementData( localPlayer, "dbid" ) ) == tonumber( advertisement.created_by ) or deleteAny then viewad.deleteButton = guiCreateButton( 10, height - 100, width - 20, 40, "Șterge Reclamă", false, viewad.window ) if tonumber( getElementData( localPlayer, "dbid" ) ) ~= tonumber( advertisement.created_by ) then guiSetProperty( viewad.deleteButton, 'NormalTextColour', 'FFFF0000' ) end addEventHandler( "onClientGUIClick", viewad.deleteButton, function () closeViewAd() triggerServerEvent( resourceName .. ":delete_advertisement", localPlayer, advertisement.id ) end , false ) end viewad.closeButton = guiCreateButton( 10, height - 50, width - 20, 40, "Ieși", false, viewad.window ) addEventHandler( "onClientGUIClick", viewad.closeButton, function () if source == viewad.closeButton then closeViewAd() end end , false ) end function closeViewAd() if viewad and viewad.window and isElement(viewad.window) then guiSetInputEnabled ( false ) guiSetVisible( viewad.window, false ) destroyElement( viewad.window ) viewad = { } if window and window.window and isElement(window.window) then guiSetEnabled(window.window, true) else showCursor( false, false ) end end end addEvent( resourceName .. ":display_all", true ) addEventHandler( resourceName .. ":display_all", root, function( advertisements, canDeleteAnyAd ) closeAds() deleteAny = canDeleteAnyAd showCursor( true, true ) local width = 500 local height = 500 local x = SCREEN_X / 2 - width / 2 local y = SCREEN_Y / 2 - height / 2 window.window = guiCreateWindow( x, y, width, height, "Reclame", false ) window.closeButton = guiCreateButton( 10, 30, width - 20, 40, "Creează Reclamă", false, window.window ) addEventHandler( "onClientGUIClick", window.closeButton, function () createAdvertisement( ) end , false ) window.mainPanel = guiCreateTabPanel ( 10, 90, width - 15, height - 150, false, window.window ) window.tab = { } window.table = { } window.colPhone = { } window.colName = { } window.colAd = { } for i = 1, #sections do window.tab[ i ] = guiCreateTab( sections[ i ], window.mainPanel ) window.table[ i ] = guiCreateGridList ( 10, 10, width - 35, height - 190, false, window.tab[ i ] ) window.colPhone[ i ]= guiGridListAddColumn( window.table[ i ], "Telefon", 0.2 ) window.colName[ i ] = guiGridListAddColumn( window.table[ i ], "Nume", 0.2 ) window.colAd[ i ] = guiGridListAddColumn( window.table[ i ], "Reclamă", 0.5 ) for ad = 1, #advertisements do if tonumber( advertisements[ ad ].section ) == i then local row = guiGridListAddRow ( window.table[ i ] ) guiGridListSetItemText( window.table[ i ], row, window.colPhone[ i ], advertisements[ ad ].phone, false, false ) guiGridListSetItemText( window.table[ i ], row, window.colName[ i ], advertisements[ ad ].name, false, false ) guiGridListSetItemText( window.table[ i ], row, window.colAd[ i ], advertisements[ ad ].advertisement, false, false ) guiGridListSetItemData( window.table[ i ], row, window.colPhone[ i ], ad ) addEventHandler( "onClientGUIDoubleClick", window.table[ i ], function ( button, state ) if button == 'left' and state == 'up' and window and window.table then local selectedRow, selectedCol = guiGridListGetSelectedItem( window.table[ i ] ) local key = guiGridListGetItemData( window.table[ i ], selectedRow, window.colPhone[ i ] ) if advertisements[ key ] then viewAdvertisement( advertisements[ key ] ) end end end , false ) end end if guiGridListGetRowCount( window.table[ i ] ) == 0 then local row = guiGridListAddRow ( window.table[ i ] ) guiGridListSetItemText ( window.table[ i ], row, window.colPhone[ i ], "Nici-o reclamă", false, false ) end end window.closeButton = guiCreateButton( 10, height - 50, width - 20, 40, "Ieși", false, window.window ) addEventHandler( "onClientGUIClick", window.closeButton, function () if source == window.closeButton then closeAds() end end , false ) end ) function closeAds() if window and window.window and isElement(window.window) then showCursor( false, false ) destroyElement( window.window ) window = { } closePostAd() end end local SERVICES_SECTION = 1 --Places to offer services such as house cleaning or mechanics and whatnot local CARS_VEHICLES_SECTION = 2 --Offer to buy or sell a vehicle in this section local REAL_ESTATE_SECTION = 3 --Houses for sale go in this section local COMMUNITY_SECTION = 4 --Advertisements about communities can go here, for example, palomino creek. local JOBS_SECTION = 5 --Advertisements about hiring people or looking for work will go in this section local PERSONALS_SECTION = 6 --People looking for other people go in this section local COOLDOWN_MINUTES = 5 --Number of minutes between push alerts being sent by players local resourceName = getResourceName( getThisResource( ) ) local sections = { "Servicii", "Vehicule", "Proprietăți", "Communitate", "Slujbe", "Personal" } function escape( value ) return exports.mysql:escape_string( value ) end function now( ) return tonumber( getRealTime().timestamp ) end addEvent( resourceName .. ":create_advertisement", true ) addEventHandler( resourceName .. ":create_advertisement", root, function( phone, name, address, advertisement, expires, section ) --Check if all fields have been entered by the user. if not ( phone == nil or name == nil or address == nil or advertisement == nil ) then --Fetch the created by local createdBy = tostring( getElementData( source, "dbid" ) ) --Get the current server time to store as our start time local start = getRealTime().timestamp --Add the time until expiry to the start time to get the actual time it will expire. local expiry = start + expires --Check if our query went into the database successfully. if exports.mysql:insert( 'advertisements', { phone = phone, name = name, address = address, advertisement = advertisement, start = start, expiry = expiry, section = section, created_by = createdBy } ) then --We'll send something to the client side so they can close the add form and reopen the main advertisements form. --openAdvertisements( source, nil ) else --If the database query was unsucessful, alert the end user. outputChatBox( "SQL Error.", source ) triggerClientEvent( source, resourceName .. ":ad_create_fail", root ) end else --If all fields were not entered, alert the user. outputChatBox( "Field Error.", source ) triggerClientEvent( source, resourceName .. ":ad_create_fail", root ) end end ) local coolDown = {} addEvent( resourceName .. ":push_advertisement", true ) addEventHandler( resourceName .. ":push_advertisement", root, function( id ) local advertisement = exports.mysql:select_one( "advertisements", { id = id } ) advertisement.author = exports.mysql:select_one( "characters", { id = advertisement.created_by } ).charactername if not coolDown[ id ] or ( coolDown[ id ] < now() - ( 60 * COOLDOWN_MINUTES ) ) then if exports.bank:takeBankMoney( client, 100 ) then coolDown[ id ] = now() for i, k in pairs( getElementsByType( 'player' ) ) do if exports.integration:isPlayerTrialAdmin( k ) then outputChatBox( "ADVERT: " .. advertisement.advertisement .. " | Ph: " .. advertisement.phone .. " | Cat: " .. sections[ tonumber( advertisement.section ) ] .. " (( " .. advertisement.author:gsub("_", " ") .." )) .", k, 0, 255, 0 ) else outputChatBox( "ADVERT: " .. advertisement.advertisement .. " | Ph: " .. advertisement.phone .. " | Cat: " .. sections[ tonumber( advertisement.section ) ] .. ".", k, 0, 255, 0 ) end end else outputChatBox( "Nu ai destui bani în bancă să trimiți această reclamă.", client, 255, 155, 155 ) end else outputChatBox( "Poți trimite o reclamă o dată la " .. COOLDOWN_MINUTES .. " minute.", client, 255, 155, 155 ) end end ) function deleteAdvertisement( id ) return exports.mysql:delete('advertisements', {id = id}) end addEvent( "advertisements:delete_advertisement", true ) addEventHandler( "advertisements:delete_advertisement", getRootElement(), function( id ) if deleteAdvertisement( id ) then --openAdvertisements( source ) else outputChatBox( "An error occured with deleting that ad.", source, 255, 100, 100 ) end end ) function openAdvertisements( player, command ) local advertisements = { } --These will hold our advertisements to send to the client and populate our advertisement tables. if not player then player = source end for _, ad in ipairs( exports.mysql:select('advertisements') ) do if tonumber( ad.expiry ) >= tonumber( getRealTime().timestamp ) then --Check if the advertisement has expired, delete it if so. ad.author = exports.mysql:select_one( "characters", { id = ad.created_by } ).charactername table.insert( advertisements, ad ) else deleteAdvertisement( ad.id ) end end triggerClientEvent( player, resourceName .. ":display_all", root, advertisements, exports.integration:isPlayerAdmin( player ) ) --Send the advertisements to the client to create the GUI. end addCommandHandler( "advertisements", openAdvertisements, false, false ) addCommandHandler( "ads", openAdvertisements, false, false ) addCommandHandler( "classifieds", openAdvertisements, false, false ) addEvent( resourceName .. ":open_ads", true ) addEventHandler( resourceName .. ":open_ads", root, openAdvertisements ) Hello guys I just wanna know what I messed up in my script I'm facing this error for hours!! ERROR: advertisements\advertisements.Lua:187: call: failed to call 'mysql:select' [string "?"] ERROR: advertisements\advertisements.Lua:187: bad argument #1 to 'ipairs' (table expected, got boolean)
  16. function StandardWep() local x, y, z = getElementPosition(getLocalPlayer()) wep = createWeapon("m4", x+5, y, z) setWeaponFlags(wep, "shoot_if_blocked", false) setWeaponFiringRate(wep, 35) setWeaponProperty(wep, "damage", 25) setWeaponClipAmmo(wep, 35) setWeaponAmmo(wep, 100) end addCommandHandler("OnStandardWep", function(command, state) local s = string.upper(state) if s=="ON" then setWeaponState(wepM16, "firing") elseif s=="false" then setWeaponState(wepM16, "ready") else outputChatBox("There is no such condition of the weapon, you can only use 'ON / OFF'", 255, 50, 0) end end ) The point is that it does not hurt other players, what's more, other players do not even see the line of fire (I mean the yellow line which means how fast the bullets are moving and in which direction) and the weapon itself (M4), I know that you need to use triggerClientEvent but no I know how to apply it, please help me with an example ; -;
  17. Is it possible to change the model for one person so that this person has a different model visible to others? In the sense that I change the model of the M4 weapon and how I hold it, it is visible to others that I have this model, but when they pull out their M4, they do not have this model. It is possible?
  18. I have a problem with setElementTarget recently, because I would like to make a script in which when I aim at something, "CreateWeapon" will shoot in that direction, but no matter what I do, it shoots too close or crooked. Anyone got any idea for this?
  19. How to get the weapon position we are currently holding?
  20. setPedAnimation(getLocalPlayer(), "shop", "shp_gun_aim") I would like my character to move with this animation, which means that when I aim a normal weapon, e.g. M4, I can move, but I can't move with this animation. Please help!
  21. I have a question, I would like to know if it is possible to make a shot effect, it means that when I hold the M4, it shoots and you can see where these bullets are falling and at what speed, and I would like to recall these bullets. If it is not known what is going on, I did the "M1" weapon model and I would like to make this model as a new weapon, and if the player was holding this M1 then it would have to shoot and the bullets would fall out of the weapon. At the beginning I was thinking about the "CreateWeapon" function but it is possible that there is another option because on average I know this function and if there was any other option it would be great
  22. My goal is that when the player clicks on the first button, the function for this button is to change for each player in his team, but unfortunately the function changes only for the person who clicked. --client side local Button1 = guiCreateButton(--There are no valid arguments ) addEventHandler("onClientGUIClick", Button1, OnTeamPlayerClickLVL1) function OnTeamPlayerClickLVL1() for i, v in pairs(getPlayersInTeam(getPlayerTeam(getLocalPlayer()))) do outputChatBox("U bought level 1 for your TEAM ^^", 0, 255, 0) removeEventHandler("onClientGUIClick", Button1, OnTeamPlayerClickLVL1) addEventHandler("onClientGUIClick", Button1, OnTeamPlayerClickLVL2) end end function OnTeamPlayerClickLVL2() for i, v in pairs(getPlayersInTeam(getPlayerTeam(getLocalPlayer()))) do outputChatBox("U bought level 2 for your TEAM ^^", 0, 255, 0) removeEventHandler("onClientGUIClick", Button1, OnTeamPlayerClickLVL2) end end -- server side RED = createTeam("Red Team", 255, 0, 0) BLUE = createTeam("Blue Team", 0, 0, 255) Here is my code that works only for ONE person and I want for the current team
  23. I would like to know how I could get ElementData from server to client and vice versa -- server side marker = createMarker(0, 0, 1.5, "cylinder", 2, 255, 0, 0) setElementData(marker, "Item", 5) addEvent("GetItem", true) addEventHandler("GetItem", root, function() ClientMarker = marker ItemOfClientMarker = getElementData(marker, "Item") end) addEventHandler("onMarkerHit", marker, function(hp) triggerClientEvent("Element", resourceRoot) setElementData(hp, "ItemTwo", ElementVariable+getElementData(marker, "Item")) end) -- client side function dxDrawTextOnElement(TheElement,text,height,distance,R,G,B,alpha,size,font,...) local x, y, z = getElementPosition(TheElement) local x2, y2, z2 = getCameraMatrix() local distance = distance or 20 local height = height or 1 if (isLineOfSightClear(x, y, z+2, x2, y2, z2, ...)) then local sx, sy = getScreenFromWorldPosition(x, y, z+height) if(sx) and (sy) then local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) if(distanceBetweenPoints < distance) then dxDrawText(text, sx+2, sy+2, sx, sy, tocolor(R or 255, G or 255, B or 255, alpha or 255), (size or 1)-(distanceBetweenPoints / distance), font or "arial", "center", "center") end end end end setElementData(getLocalPlayer(), "ItemTwo", 0) addEvent("Element", true) addEventHandler("Element", root, function() ElementVariable = getElementData(getLocalPlayer() , "ItemTwo") end) addEventHandler("onClientRender", root, function() triggerServerEvent("GetItem", root) dxDrawTextOnElement(ClientMarker, tostring(ItemOfClientMarker), 2, 50, 255, 255, 0, 3, "arial") end) Does it have a chance to work? because that's something I imagine...
  24. -- server side cylinder = createMarker(-712.09100, 967.01917, 12.33547-1, "cylinder", 1.5, 255, 50, 0, 255) setElementData(cylinder, "BoxWithPoints", 0) function TIMER() if getElementData(cylinder, "BoxWithPoints") >= 8 then setElementData(cylinder, "BoxWithPoints", 8) else setElementData(cylinder, "BoxWithPoints", getElementData(cylinder, "BoxWithPoints")+1) end if isElementWithinMarker(source, cylinder) then triggerServerEvent("givePointsToServer", root) PointsServer = getElementData(source, "points") BoxPoints = getElementData(cylinder, "BoxWithPoints") setElementData(source, "points", PointsServer + BoxPoints) setElementData(cylinder, "BoxWithPoints", 0) end end setTimer(TIMER, 3000, 0) -- client side setElementData(getLocalPlayer(), "points", 0) addCommandHandler("ShowMyPoints", function() outputChatBox(tostring(getElementData(getLocalPlayer(), "points")), 255, 255, 0) end) addEvent("givePointsToServer", true) addEventHandler("givePointsToServer", root, function(player) local player = client setElementData(player, "points", getElementData(player, "points")) end) The problem is with the ruler where isElementWithinMarker (source, cylinder) shows me the error that argument 1 got nil, I don't know what to think about it because I checked meta.xml and server side and client side is the correct type, could someone explain why is this happening?
  25. what server-side getLocalPlayer looks like?
×
×
  • Create New...