Jump to content

tosfera

Members
  • Posts

    1,193
  • Joined

  • Last visited

Posts posted by tosfera

  1. If I'm looping through the saveData, it's already returning 6 things. which is actually incorrect since it should return 3 collections. Looping through the saveData like this also returns the wrong collection:

    for i, p in ipairs ( saveData ) do
    	outputChatBox ( i .."--".. tostring ( p ) );
    end

     

    I'll just do it the ugly way since the function isn't going deep enough.

  2. Alright, I've got the following JSON saved in my mysql:

     

    [ [ { "lastPlayed": 0, "experience": 0, "money": 20 }, { "lastPlayed": 0, "experience": 0, "money": 20 }, { "lastPlayed": 0, "experience": 0, "money": 20 }, { "lastPlayed": 0, "experience": 0, "money": 20 }, { "lastPlayed": 0, "experience": 0, "money": 20 }, { "lastPlayed": 0, "experience": 0, "money": 20 } ], [ { "lastPlayed": 0, "experience": 0, "money": 20 }, { "lastPlayed": 0, "experience": 0, "money": 20 }, { "lastPlayed": 0, "experience": 0, "money": 20 }, { "lastPlayed": 0, "experience": 0, "money": 20 }, { "lastPlayed": 0, "experience": 0, "money": 20 }, { "lastPlayed": 0, "experience": 0, "money": 20 } ] , [ { "lastPlayed": 0, "experience": 0, "money": 20 }, { "lastPlayed": 0, "experience": 0, "money": 20 }, { "lastPlayed": 0, "experience": 0, "money": 20 }, { "lastPlayed": 0, "experience": 0, "money": 20 }, { "lastPlayed": 0, "experience": 0, "money": 20 }, { "lastPlayed": 0, "experience": 0, "money": 20 } ] ]

    It are 6 elements inside 3 elements. Each of these 3 elements holds 6x the { "lastPlayed": 0, "experience": 0, "money": 20 }.

    Whenever I'm using fromJSON, it's returning the wrong information when I'm trying to access the first element out of the second collection. The code I'm using is as following:

    local saveData = fromJSON ( data [ 1 ].saves );
    outputChatBox ( #saveData ); -- returns 6 elements (incorrect)
    outputChatBox ( #saveData [ 2 ] ); -- returns 3 properties (correct)
    outputChatBox ( tostring ( saveData [ 2 ] [ 1 ] ) ); -- returns nil

     

    The JSON is valid, I can use it in different languages too and every parser says it's correct. I'm starting to think that fromJSON is returning just the first collection instead of all 3. Has anyone encountered this problem? I'm not really a fan of putting it all into 1 collection, it's preventing me from adding more and more data later on.

  3. First of all, in your server's side:

    local text = guiGetText(Edit)

    'Edit' is nothing, you haven't declared it anywhere.

     

    Second of all, in your server's side you're expecting a playersource as first variable which you called 'plr'. In your client side, you're sending a function:

    triggerServerEvent( "myEvent", localPlayer, guiGetText )

     

    If you would've put on debugscript 3, you would've gotten an error. Go to your server, turn on /debugscript 3 and read the errors.

  4. guiCreateBrowser should be used for interactive websites, where people can use the website theirself. If you still want to have the dxRender for your browser then simply draw the render over the guiCreateBrowser. the browser will do the functionality while the render does the overlay of it. No idea why you would want that but oh well, you never know!

  5. Neither does your input or hover work because you've used CreateBrowser which the wiki states as, and highlighted the part which is your problem:

    Quote

    This example shows you how to create a fullscreen web browser (showing a local html file) without input-handling.

     

    You're looking for input-handled functions, which can be done with GuiCreateBrowser. This would do:

    local browser = guiCreateBrowser ( ( x / 2 ) - 200, ( y / 2 ) - 100, x, y, true, true, false );
    local theBrowser = guiGetBrowser ( browser );
    addEventHandler ( "onClientBrowserCreated", theBrowser, 
    	function ()
    		loadBrowserURL ( source, "http://mta/local/login.html" );
    	end
    );

     

    Also, you know that you can position the div with css itself and create the browser with '0, 0, x, y'. right? simply add this to your body element as a class:

    top: calc(50% - 100px);
    left: calc(50% - 200px);
    position: absolute;

     

    • Like 1
  6. If you think about it.. it's actually quite easy to do pathfinding. You got the GPS resource which has all the nodes, if you simply modify the distances it stays away from nodes, you got the basics laid out. Then simply create a colshape around the player to see if there are any objects in their way. if so, move around them. it would be pretty hard to do since turns will mix them up, but if you're really interested in getting a basic pathfinding.. that would be the way to get started.

  7. What he's trying to say is that you could turn off the cache from your client sided files in your meta.xml. This will prevent the system keeping the files on your computer. Another thing you can do is compile your scripts, they won't be able to change anything in them.

    If you really want to give them a pain in the ass; create a function/trigger to the server, on the server's side check for an IP. if that ip mismatches, stop the entire functionality of the entire script. Simply break the functions everywhere. They can change this theirself too if they got the server sided files, for that.. you can't protect yourself. just make sure no one has access to your files.

  8. You're almost trying to kill the client there, seriously.. don't work like that. Better use these steps;

    1. player logs in/joins the server
    2. set their data (their acl group OR a default group), something like: 'rank'
    3. in the onClientRender, loop through the players, get their rank
    4. once you got their rank, get the correct render name (make it an array/table and read it from there for ease)
    5. you're done.
  9. Without reading anything in this topic, are you sure you're running the latest client and server version? Is the file set as a client sided file in your meta?

    (reading the post now)

     

    The function you're using is a useful function, which means you have to include the function from the wiki in your file.

    function dxDrawTextOnElement(TheElement,text,height,distance,R,G,B,alpha,size,font,checkBuildings,checkVehicles,checkPeds,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement)
    				local x, y, z = getElementPosition(TheElement)
    				local x2, y2, z2 = getElementPosition(localPlayer)
    				local distance = distance or 20
    				local height = height or 1
                                    local checkBuildings = checkBuildings or true
                                    local checkVehicles = checkVehicles or false
                                    local checkPeds = checkPeds or false
                                    local checkObjects = checkObjects or true
                                    local checkDummies = checkDummies or true
                                    local seeThroughStuff = seeThroughStuff or false
                                    local ignoreSomeObjectsForCamera = ignoreSomeObjectsForCamera or false
                                    local ignoredElement = ignoredElement or nil
    				if (isLineOfSightClear(x, y, z, x2, y2, z2, checkBuildings, checkVehicles, checkPeds , checkObjects,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement)) 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

    add that at the bottom or top from your file, I would go for top.

  10. That's not working, might want to attach an ID to the object/colshape and do the part where you delete everything on the server. This does mean that only 1 player can get the actual object from that colshape. If you want every client to be able to do so.. you should create the colshapes and objects on the client's side. ^_^

  11. You want to remove the attached element and the colshape? You could try something like this then:

    function destroyObject ( theElement, matchingDimension )
        if ( theElement == getLocalPlayer() ) then
            local tmpObject = getElementAttachedTo ( source );
            if ( tmpObject ) then
                -- detach everything from both elements
                detachElements ( tmpObject );
                detachElements ( source );
    
                -- destroy both elements
                destroyElement ( tmpObject );
                destroyElement ( source );
            end
        end
    end
    addEventHandler ( "onClientColShapeHit", getRootElement(), destroyObject );

     

  12. Only way that it can be nil is when the colshape gets deleted before the onClientKey (which should be onClientClick, my bad) gets called. We're assigning the value to tmpColshape on line 5 already so it shouldn't be nil. What other code can be found in your file?

  13. You're unable to reposition an element when it's attached. If you're attaching an object to another element, or any element to another element. it becomes a child element from the attached to element. Which means; if the parent (the attached to element) gets removed, they get detatched. If you're trying to destroy the element you're attaching, you should first make it an element of it's own again. Else the parent will have trouble seeking it's child.

    The attachment functions in MTA have a higher priority than any destroy function on the attached element.

  14. I'm currently working with some pretty complex things on work in angular but that did give me an idea. Try it like;

    theFunctions = { };
    
    theFunctions.checkStars = function ( thePlayer )
        return getPlayerWantedLevel ( thePlayer );
    end
    
    return theFunctions

     

×
×
  • Create New...