Jump to content

Ab-47

Members
  • Posts

    367
  • Joined

  • Last visited

Posts posted by Ab-47

  1. "scoreboard" is an old resource, check to see if scoreboard even exists in your resource folder. The new one is dxscoreboard, same syntax I guess.

    Also, I would advise you to remove your code and just leave the exports, as far as I could see your code should work fine. Just the exports that aren't being called properly. Syntax looks correct, no typos spotted either.

    If you do have the old scoreboard, try updating to dxscoreboard and running the code again, let me know if there's any errors.

  2. To answer your question, just use "takeWeapon" at the else. Also, it'd be more convenient using tables for these sorts of things. Element data is not the wisest choice.

    For example:

    local using_phone = {}

    function togglePhone(player)

         if (not using_phone[player]) then

               using_phone[player] = true

               --You could also add giveWeapon here (to continue your script)

               --Animation here

         else

              using_phone[player] = false

               --And here you could add takeWeapon here.

               --End animation here

         end

    end

    addCommandHandler("phone", togglePhone)

     

    Furthermore, I suggest you rethink your code, it doesn't look that great and you'll encounter issues in the future. For example, calling root to set a walking style.. First of, there's no need for the walking style as when the phone is enabled I assume you have a cursor enabled too, so the player couldn't move either way (unless you're using it as an idling position). Secondly, you're calling the root element of everything, not really efficient. You have "playerSource" defined, so just call it for "playerSource". Personal advice, remove that whole server function and client trigger for walking style. In addition to all this, I would add a triggerClientEvent to toggle the phone from this function and change the commandHandler to a bindKey. Drop a message if you need any help, we'll be of assistance. Good-luck.

  3. 4 hours ago, pa3ck said:

    Can you not use getRealTime timestamp and calculate the time that way? 

     

    You might need to adjust it a bit for local time, since client side it will return the client's PC time rather than the server time, but you can adjust that before a race begins. 

    I was just thinking about this, getRealTime could actually work. I assume getRealTime would use the servers local time otherwise you could create a custom script where you could use fetchRemote to return a specific time using PHP. It's not that difficult either, PHP is somewhat similar to Lua. However you would need an online website for that. I wouldn't really recommend fetchRemote, just the standard MTA getRealTime should do the trick.

  4. Or you could just do this..

    addCommandHandler("easr",
    	function()
    		local sx, sy, sz = getElementPosition(source)
    		for i, v in pairs(getElementsByType("player")) do
    			setElementPosition(v, sx + math.random(5, 10), sy, sz)
    		end
    	end
    )

     

  5. You're creating a GUI in your code, I just modified the code you sent above including the variables you mentioned in your code. Try this

    isHolding = false
    
    addEventHandler( "onClientGUIMouseDown", getRootElement( ),
        function ( btn, x, y )
    		if (source ~= inventoryGridlist["inventory"]) then return end
            if btn == "left" and getElementType(source) == "gui-gridlist" then
                clickedElement = source
                local elementPos = { guiGetPosition( source, false ) }
                offsetPos = { x - elementPos[ 1 ], y - elementPos[ 2 ] }
    			isHolding = true
            end
        end
    )
    
    addEventHandler( "onClientGUIMouseUp", getRootElement( ),
        function ( btn, x, y )
            if btn == "left" then
    			if isHolding then
    				isHolding = false
    				clickedElement = nil
    			end
            end
        end
    )
    
    addEventHandler( "onClientCursorMove", getRootElement( ),
        function ( _, _, x, y )
            if clickedElement and isHolding then
                guiSetPosition( clickedElement, x - offsetPos[ 1 ], y - offsetPos[ 2 ], false )
            end
        end
    )

     

    • Like 1
  6. 17 hours ago, XLEGENDX said:

    @Ab-47

     

    Thank you for your answer !

      Here, I also wanted to save multiple objects. Accordingly, I had to save multiple IDs on accountData. As I know, setAccountData can't store tables on account. If I want to save IDs 11, 12 and 13, what should I do here ?

    Sorry for the late reply, in simple terms you can just call the setAccountData function again and again for as many variables as you like but the name must change

    setAccountData(account, "objectID1", id1)
    
    setAccountData(account, "objectID2", id2)
    
    setAccountData(account, "objectID3", id3)

    But to retrieve it you must call each piece of data, objectID1, objectID2, objectID3 and so on. But that's all time consuming and pointless

    A better way to do that is by setting the toJSON converted table to the account data and use fromJSON to retrieve it as stPatrick mentioned above.

    8 hours ago, stPatrick said:

    You can store a table, if you convert it to a string before save.

     

    https://wiki.multitheftauto.com/wiki/ToJSON

    https://wiki.multitheftauto.com/wiki/FromJSON

     

    
    local table = { "dogs", cat = "hungry", mouse = "food", birds = 4 }
    local table_string = toJSON(table) -- result: [ { "1": "dogs", "mouse": "food", "cat": "hungry", "birds": 4 } ]
    local table_again_from_string = fromJSON(table_string) -- table == table_again_from_string
    

     

    If you need any additional help, do let us know.

    • Thanks 1
  7. Your code is a bit messy, I fixed a few typos that you had. Not gonna suggest SQL, it may be a bit more complex for you so for now just use accountData to save the ID. Player has to be logged in for this to work. Also added an extra function for when the player logs in, if the data was saved to their account it'll respawn on login.

    [[ Client ]]
    
    function finel ()
    
      local item = guiGridListGetSelectedItem (myGirld)
        ID = guiGridListGetItemText (myGirld, item,3)
        body = guiGridListGetItemText (myGirld, item,4)
        rot = guiGridListGetItemText (myGirld, item,5)
        prices = guiGridListGetItemText (myGirld, item,2)
        triggerServerEvent( "give",localPlayer, localPlayer, prices,ID,body,rot) 
        showCursor(false)
        destroyElement(window)
        
    end
    addEventHandler("onClientGUIClick", buying, finel)
    
    [[ Server ]]
    
    local obj = {}
    
    function maske_kaldir2(plr,pay,id,bdy,rot)
    local money = getPlayerMoney(plr)                            
        if (money > tonumber (pay)) then     
            local account = getPlayerAccount(plr)
    		if (not account) then return end
    		setAccountData(account, "objectID", id)
    		takePlayerMoney (plr,(pay))
            obj[plr] = createObject ( id, 0, 0, 0, 0, 0, 0 )
            exports.bone_attach:attachElementToBone(obj[plr],plr,1,0,0,-0.61,0,0,90)
        else
            outputChatBox ("You dont have Money" ,plr ,255,0,0)
        end
    end
    addEvent("give",true) 
    addEventHandler("give", root, maske_kaldir2)
    
    addEventHandler("onPlayerLogin", root,
    	function()
    		if (isElement(source) and getElementType(source) == "player") then
    			if (getPlayerAccount(source)) then
    				local account = getPlayerAccount(source)
    				local object = getAccountData(account, "objectID")
    				if (object) then
    					obj[source] = createObject ( object, 0, 0, 0, 0, 0, 0 )
    					exports.bone_attach:attachElementToBone(obj[source],source,1,0,0,-0.61,0,0,90)
    					outputChatBox("Object given", source, 255, 0, 0)
    				end
    			end
    		end
    	end
    )

     

    • Thanks 1
  8. You could use the following functions/events >

    (Event) -> onClientClick -> Returns: you'll need to identify the clickedElement as the type of GUI you want to move

    button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement

    Instead of the above you could use:

    (Event) -> onClientGUIClick -> which returns the clicked GUI element rather than an element clicked -> returns: 

    button, state, absoluteX, absoluteY

    (Event) -> onClientCursorMove -> Returns: use absoluteX, absoluteY as your X / Y params needed to move.

    cursorX, cursorY, absoluteX, absoluteY, worldX, worldY, worldZ

    (Function) -> guiSetPosition() -> usage: 

     guiSetPosition(clickedElement, absoluteX, absoluteY, false)

    Use onClientRender/onClientPreRender to render the moving transition of the element you're moving. Not sure if this is the best way, but most simple. Goodluck

    • Thanks 1
  9. On 18/03/2019 at 14:21, Rubberband Earl said:

    ANOTHER UPDATE, apparently, if I unplug the headphones WHILE I am on a server on MTA, I have sound for the game, if I plug in the headphones again, the sound still comes from the monitor I have

    I did mention above to remove your headphones lol, but anyways, I guess you have your sound/devices default as your monitor.

    Open your control panel > click "Hardware and Sound" > click "Sound" > a box should appear, try select the device you want to use to output your sound and click on "Set Default".

    Maybe that would help, maybe your default device is set to the wrong thing. If that doesn't work, right click your sound icon and click "Troubleshoot sound problems" and run the troubleshooter, it should fix your issue. If after changing your default device and your sound doesn't work, try reboot your PC and it should be fine.

  10. 13 hours ago, Rubberband Earl said:

    Another Update, I uninstalled GTA San Andreas and installed it again, as intstructed, I did not start the game up, I went to Documents and deleted the gta_sa.set file, I also checked in my installation folder and I did not find D3D9.dll. I then installed MTA and immediately after it I installed the latest patch, after that I started MTA and clicked on Host Server, it had no sound after it loaded fully, I exit MTA then open up GTA San Andreas to see if it would freeze again, to my surprise, it didn't freeze this time and runs nice, so MTA is still muted

     

    Well at-least you're getting somewhere now. Does MTA run fluently as-well, just without sound? Just double check that your sound drivers are updated and your sound is enabled in MTA settings > Audio tab.

  11. On 16/03/2019 at 20:55, Rubberband Earl said:

    It is allowed man, it just seems that whatever the issue is, it's from MTA most likely, because if I uninstall MTA and reinstall GTA San Andreas it works nice again! Another strange thing is that I do select for every setting and files to be deleted so nothing remains from both games, yet MTA still has the configuration with Space being jump and usually it should've been space run you know what I mean? Even San Andreas has the save files even tho I did select to uninstall EVERYTHING

    Honestly I don't know what the issue could be, so I'm sorry. Don't give up yet, try do the following: 

    • Delete the gta_sa.set file located in the GTA San Andreas User Files in your Documents folder.
    • Check in your GTA San Andreas installation directory for a D3D9.dll. If one is present, delete it.

    Then install MTA SA's latest version without starting up GTA SA. Then install the latest patch: https://nightly.multitheftauto.com/?mtasa-1.5-rc-latest

    After all of that, try run MTA SA and click "Host Server", just enter your own local server to see if you could actually load the game without issues. If that works, try join a server preferably without mods or such, or if you could launch your local server through MTA / Server / MTA Server application and join your server in the locals tab. 

    Let me know your findings/outcome of this, if you're able to join a local server fine, if you're able to connect to a random server etc. I'll keep on looking for solutions to help you.  

  12. 18 hours ago, TheThe said:

    Yes I have a router but my internet is good and there are no problems so its weird..do you have a tips what to do?

    Well to test if the issue is actually there, try playing directly through your modem rather than the router and see for yourself.

    I'm not sure if there's a way around this as it's nothing to do with the configuration, rather the gateway between the 2 devices causing the jitter which is enough to take you offline for a few seconds. 

    Maybe do a little google search to see if other gamers had this issue, I'm guessing your best bet would be to buy a better router lol

  13. 17 hours ago, Rubberband Earl said:

    Update, I uninstalled both games, I then instaleld GTA San Andreas, started it up, it worked mighty fine, no problems, I wait a bit to see if something changes these days, nothing, I proceed to install MTA, I start MTA, connect to a random server, no sound at all, I disconnect and exit the game, I start up GTA San Andreas, load game, it froze and I have to restart the PC

    I really don't know what the issue could be.. Have you tried double checking to see if MTA is allowed through your firewall or if windows defender sees it as a threat? Or another antivirus program interfering? 

    After all you've tried I believe the issue relates to access (Can't access D:\jocuri instalate\MTA\mods\deathmatch\resources\benchmark\output\bench.log) for example.. 

  14. 14 hours ago, TheThe said:

    yes but i said its not only 1 server , its whole mta servers , whole..but do you know aobut this problem or no?

    Oh okay, now you've made that clear it's not just one specific server, it's your internet.

    I remember a while back allot of people had issues to do with connection timeouts even whilst their internet had quite a good speed, and that was because they were using a router to boost their WiFi signals through a modem. Do you have a setup as such? Router connected to modem?

  15. 2 hours ago, Rubberband Earl said:

    Thanks for taking a moment from your time to help me out with this, I will try to do the stuff you told me about right now, I'll keep you updated with the end results, also, MTA is installed in another directory, in Drive D, don't know why it shows that it's in C

     

    No no, it does show as D drive I never saw that. You could try re-install it into the C drive maybe the D drive has some restrictions? 

  16. 9 hours ago, TheThe said:

    its not about my internet or the server , its Happens for me in the whole mta servers.. i dont know how to fix it , so what to do? 

    Then you haven't explained your situation clear enough because lag can either be from you or the server, if it's neither where would the lag come from? :o 

    You mentioned above, 

    On 10/03/2019 at 18:45, TheThe said:

    hi , since something like 2 months ago , i have a problem that every 20-30min i am getting timed out during i am playing Clan Wars , i dont have something wrong in the folder and i dont know how to fix it , when i am getting timed out It shows me: disconnected: connection to the server was lost.

    and i can back to the servers after few seconds.

    That it's on this one server.

    Then karts asked: 

    On 11/03/2019 at 01:24, karts said:

    Maybe you have some troubles in your internet provider? Do you have same problem in other games and servers?

    And you replied: 

    On 11/03/2019 at 10:08, TheThe said:

    no..and no

    So if you're not having issues yourself and you're not having issues with "other" servers, then where do you think the issue is? Right. Read my post again:

    On 12/03/2019 at 00:58, Ab-47 said:

    it could be that the server you're connecting to has either host issues or inefficient scripts using up too much of the servers CPU, if you're not experiencing the same issues on other servers, then it's not you. The best thing you could do is talk to the developers/staff of that server and let them know of the issue.

    I'm talking about the "server" you're connecting to, nothing to do with you or your connection.

  17. That way is more sophisticated and onClientRender will use a lot of memory, easiest and best way to do it is use create a table of positions then use createObject in a loop through the data in the table (positions), set a perimeter using any object you like, then create a loop that runs 1 time to setElementAlpha(object, 0) of all objects in the table.

    Easiest way to create the objects is literally map editor, create all of them then convert the .map file to .lua

    Whichever solution you find best, you can go with. XasKel's way seems better in the sense of reversing the position if it's out of bounds, with maps they're fixed objects and only obstruct a player, not stop them. So if an element is fast enough, it could warp through the map object but you'd need to be at a ridiculous speed to do that. I guess it's to do with the rendering of the model, so all depends on the clients CPU honestly.

  18. 7 hours ago, queenshe said:

     

    http://prntscr.com/mwx0eq

    http://prntscr.com/mwx0rf

    how to problem fix? 

    @Ab-47 @Mr.Loki

     

    
    elseif source == can then
            if getPlayerMoney() >= 5000 then
                if getElementHealth(localPlayer) ~= 100 then
                    if (limit_health) and (getTickCount()-limit_health < 300000) then outputChatBox("You need to wait 5 minutes before using this again...", 255, 0, 0) return end
                    limit_health = getTickCount()
                    setElementHealth(localPlayer,100)
                    triggerServerEvent("TakeMoney",localPlayer)
                    outputChatBox("#888888 5000$ #FFFFFFkarşılığında canın dolduruldu!",0,255,0,true)
                else
                    outputChatBox("Canın zaten dolu!",255,0,0,true)
                end
            else
                outputChatBox("Paran yetmiyor!",255,0,0,true)
            end
            setTimer(guiSetPosition,50,5,canimg,g-132,2,false)
            setTimer(guiSetPosition,60,5,canimg,g-128,1,false)
    elseif source == zirh then
            if getPlayerMoney() >= 5000 then
                if getPedArmor(localPlayer) ~= 100 then
                    if (limit_armor) and (getTickCount()-limit_armor < 300000) then outputChatBox("You need to wait 5 minutes before using this again...", 255, 0, 0) return end
                    limit_armor = getTickCount()
                    triggerServerEvent("setPlayerArmor",localPlayer)
                    outputChatBox("#888888 5000$ #FFFFFFkarşılığında çelik yelek giydin!",0,255,0,true)
                else
                    outputChatBox("Çelik yeleğin zaten sağlam!",255,0,0,true)
                end
            else
                outputChatBox("Paran yetmiyor!",255,0,0,true)
            end
            setTimer(guiSetPosition,50,5,zirhimg,g-132,2,false)
            setTimer(guiSetPosition,60,5,zirhimg,g-128,1,false)
    

     

    I just figured out the illegal character thing as XasKel pointed out lol "then" is not actually "then", it has an invisible illegal character that the system can identify but not you, leading it to not be a correct statement.

    I've created a workaround for your code for testing purposes and removed all the illegal characters, take the code from what I've pasted below and make sure you eliminate all the illegal characters. 

    function checkWhatever(cmd, string)
        if string == "can" then
            if getPlayerMoney(localPlayer) >= 5000 then
                if getElementHealth(localPlayer) ~= 100 then
                    if (limit_health) and (getTickCount()-limit_health < 300000) then outputChatBox("You need to wait 5 minutes before using this again...", 255, 0, 0) return end
                    limit_health = getTickCount()
                    setElementHealth(localPlayer,100)
                    triggerServerEvent("TakeMoney",localPlayer)
                    outputChatBox("#888888 5000$ #FFFFFFkarşılığında canın dolduruldu!",0,255,0,true)
                else
                    outputChatBox("Canın zaten dolu!",255,0,0,true)
                end
            else
                outputChatBox("Paran yetmiyor!",255,0,0,true)
            end
            setTimer(guiSetPosition,50,5,canimg,g-132,2,false)
            setTimer(guiSetPosition,60,5,canimg,g-128,1,false)
        elseif string == "zrich" then
            if getPlayerMoney(localPlayer) >= 5000 then
                if getPedArmor(localPlayer) ~= 100 then
                    if (limit_armor) and (getTickCount()-limit_armor < 300000) then outputChatBox("You need to wait 5 minutes before using this again...", 255, 0, 0) return end
                    limit_armor = getTickCount()
                    triggerServerEvent("setPlayerArmor",localPlayer)
                    outputChatBox("#888888 5000$ #FFFFFFkarşılığında çelik yelek giydin!",0,255,0,true)
                else
                    outputChatBox("Çelik yeleğin zaten sağlam!",255,0,0,true)
                end
            else
                outputChatBox("Paran yetmiyor!",255,0,0,true)
            end
            setTimer(guiSetPosition,50,5,zirhimg,g-132,2,false)
            setTimer(guiSetPosition,60,5,zirhimg,g-128,1,false)
        end
    end
    addCommandHandler("hello", checkWhatever)

    Command: hello can or hello zrich, didn't know what either were so converted them to string to enter on the cmd. Make sure you change that back and the if to elseif to put back into your code. 

     

     

  19. 14 hours ago, Rubberband Earl said:

    I reinstalled GTA San Andreas first and I started it up after it, the game worked but when I reinstalled MTA, I still had it muted and the Single Player froze again when I tried loading a game file or start a new game, and the only thing I can do to get ANY response from my PC is to restart it

     

    Are you using headphones? If you are, try not inserting them, reinstall GTA again, then try install MTA in a separate destination then reboot your PC but DO not insert your headphones. Give the game a run and see if it works, if you have issues after you plug your headphones in it could be a driver issue. Try the following below, worth a try. If none of the following work, I could try suggest a few more but we'll just have to wait for the mods/admins to read through your MTAdiag to diagnose the issue. I've tried finding the issue and it looks like it's from here:

    Quote
    1. ------------------------------------------------------------------------------------------------------------------------
    2. timings.log:
    3. Can't access D:\jocuri instalate\MTA\timings.log
    4.  
    5. ------------------------------------------------------------------------------------------------------------------------
    6. bench.log:
    7. Can't access D:\jocuri instalate\MTA\mods\deathmatch\resources\benchmark\output\bench.log
    8.  
    9. ------------------------------------------------------------------------------------------------------------------------
    10. report.log:
    11.  
    12. 7411: 2019-01-10 20:15:08 [9.16068.3.000 6.2(10.0)] [00084-10756] - CClientGame::SetFileCacheRoot - Is shared 'D:\jocuri instalate\MTA\mods\deathmatch'
    13. 6211: 2019-01-10 20:16:42 [9.16068.3.000 6.2(10.0)] [00084-10756] - WaitForSingleObject timed out with 00000364 and 4000ms
    14. 7110: 2019-01-10 21:32:35 [9.16068.3.000 6.2(10.0)] [00084-10756] - Game - COMMAND_Disconnect
    15. 7045: 2019-01-10 21:32:38 [9.16068.3.000 6.2(10.0)] [00084-10756] - Disconnect from 217.114.197.177:22003 []
    16. 7101: 2019-01-10 21:32:58 [9.16068.3.000 6.2(10.0)] [00084-10756] - Core - Quit
    17. 7104: 2019-01-10 21:33:02 [9.16068.3.000 6.2(10.0)] [00084] - Loader - Finishing
    18. 8070: 2019-01-10 21:33:02 [9.16068.3.000 6.2(10.0)] [00084] - CheckService 5 result: 1
    19. 1044: 2019-01-10 21:33:02 [9.16068.3.000 6.2(10.0)] [00084] - * End (0x0)* pid:84
    20. 6404: 2019-01-10 21:33:02 [] [01392] - [app64] Client gone
    21. 6405: 2019-01-10 21:33:02 [] [01392] - [app64] Stopping
    22.  
    23. -----------------------------------------------------------------------------------------------------------------------

    You may want to try identify whether timings.log and bench.log exist, make sure you're showing system files in the file settings. If they're there, try delete them and let MTA re-create them itself. Otherwise continue reading below, as I've noticed you had headphones inserted whilst you run the diagnostic. And it could more or less be a sound issue.

    I have a few options you could try to get it working,

    1) Have you got any sound mods? If yes, remove them all.

    2) Did you re-install MTA in another directory or the same one? If it's the same one, try install MTA in another directory rather than the one you used.

    3) Have you updated all of your drivers (mainly your sound driver)? If not, try diagnose sound issues first then try manually updating : - 

     - Press and hold the windows key and press X, release both at the same time; (This is to open quick navigation)

     - From the menu, select "Device Manager", navigate through to find "Sound, Video and Game Controllers";

     - Right click each item and select "Update Driver", it'll then prompt you to an interface, proceed to "Search automatically for updated driver software"

     - If it finds an update, do try updating and tell us your outcome.

    4) Have you got the latest DirectX driver? (https://download.microsoft.com/download/5/F/F/5FF1D7F6-C5FA-4D89-91FE-0A259056F97E/DirectX_11_Technology_Update_US.zip - Direct download) or Visit the download page and do it manually.

    5) Try uninstalling MTA and remove ALL files related in the installation path and then install it in another drive rather than your C drive. (Be sure to backup your important files first).

    Let me know if you have any updates regarding the solution or if it still did not work.

×
×
  • Create New...