Jump to content

Dealman

Members
  • Posts

    1,421
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Dealman

  1. Why are people so against setTimer? It really isn't as bad as most people think, unless you create hundreds or thousands of them with onClientRender and it also depends on what you do with the timer. As for restarting the resource, you can use startResource and stopResource to restart it with a timer, or by other means if you so desire. Just keep in mind that they will require ACL Permission to do this.
  2. Then I'm not sure, haven't worked with fetchRemote. I'll let Solidsnake14 work his magic
  3. Then you'll have to use getScreenFromWorldPosition.
  4. I believe it means if you're trying to use it client-side, you can only download files that are server-side. So, you'd need to put the image in the server-side version of the resource.
  5. So, do you want the text on the actual screen? Or do you want it in-game, like above the ground? I am greatly confused.
  6. So, I don't even know what I am thinking anymore. I was writing some examples for you, then I realized it's not even necessary. The problem you have, is that you're using the event onClientPreRender. So whenever a client loads that script, it will draw that. This is why everyone saw it. You can go ahead and try this, I haven't tested it - and you'll also have to create a proper ColShape. I just provided an example, you fill in the rest. Also, do try to read and understand it, instead of just copying and pasting. Note: onClientRender and onClientPreRender repeats the entire function for every frame. That means it will repeat the one same function 30-60 times per second. Thus, you need to be very careful when working with it. In this case, you were getting the client's screen resolution with every frame. Not very efficient and might cause instability depending on what you're doing with it.
  7. Dealman

    GUI Problem

    You do realize that LUA is very case-sensitive right? GuiSetEnabled is not the same as guiSetEnabled. And as TAPL mentioned, you're not using parents. Thus when you click anywhere else, anything that is not a child of that parent - will be put behind the clicked GUI Element. Therefore, you will need an image to work as a window. And assign it as parent to everything else. test = guiCreateStaticImage(0, 300, 413, 150, "bg1.png", false, parentHere) You'll then have to isolate onClientGUIClick, so it doesn't run the function every time you click some element. An example would be; function exampleCode() if(source == exampleButton1) then -- Do your stuff here. end if(source == exampleButton2) then -- Do your other stuff here end end addEventHandler("onClientGUIClick", getRootElement(), exampleCode) You'll also need to use onClientRenderto draw DX Drawings. Be careful with this, since it runs the function it's assigned for with every frame. So if not careful, you could end up re-creating hundreds and even thousands of unwanted things, such as timers or whatever you use.
  8. Would be useful if you post the code you use to render it. What you could do would be to do it server-side(with ColShape), and then use triggerClientEventto pass the player element as an argument. As for the rendering, make an if statement to check if the local player's element/name is the same as the one passed down with triggerClientEvent. If true, render it. If false, don't render it. Hope I made it understandable
  9. You can use ColShapes to see when a player is inside a ColShape and when one leaves.
  10. Do you mean sort of like a marker? You walk onto a marker, and the text appears on the screen. And if you leave it, it disappears?
  11. Dealman

    Help script

    I think what Solidsnake14 said is that you use cancelEvent. You then output the messages with the rules at the bottom. So yes, in that part.
  12. As I said, what event are you using for your server-side function? 'Cause you didn't post the entire part of that function. Are you sure that source is returning a player element and not something else? Edit: Forgot to refresh tab Solidsnake14 strikes as always
  13. bool triggerClientEvent ( [element sendTo=getRootElement()], string name, element theElement, [arguments...] ) First argument is the element to send it to.
  14. What event handler are you using for the server-side code you pasted? Are you sure source is returned as a player element?
  15. Ah, I mis-read the wiki. Try this; triggerClientEvent (source, "onUpgradeText", getRootElement(), message) Source being the element you want to send the message to. Make sure there actually is a source for the function you're working with. Also if there are errors and/or warnings - post them.
  16. function someFucntion () message = "Barrel" triggerClientEvent ("onUpgradeText",source,message) end You don't have any event handler attached to this function, so as far as I can see - source would be nil. Also I believe you would have to construct your triggerClientEvent like this; triggerClientEvent (source, "onUpgradeText", message)
  17. You can read this post for an example - it's from client to server. But should work the other way.
  18. No offence, but are you even trying to understand what it means? It is really obvious. MTA has the nicest debugging I've ever seen, it doesn't get much more foolproof than this. 1) It shows you the line where the error/warning was encountered. In this case, Line 18. (Use a program like Notepad++ to see Line Numbers) 2) It tells you what is wrong. In this case, it expected a vehicle pointer - a vehicle element, but received something else or nothing(nil). Thus, it does not know what to do. See setTrainSpeed for information.
  19. Not entirely sure how trailers work, but it might be that it's detached properly but not moved away enough to stay detached - thus it automatically re-attaches again. So one thing you could try would be to change the trailer's position slightly after it is detached. If that doesn't work, then it's something with the code for sure.
  20. Dealman

    Map Music

    Not that I can think of. Someone more experienced such as 50p or Solidsnake14 might have some suggestions, I guess
  21. Dealman

    Map Music

    I remain confused as to what you really want. Do you want to stop the sound file from downloading at all? So the map sizes will be smaller? As far as I know, the only way to do this would be to manually remove the music from each and every map.
  22. Since you just want to trigger an event, and not actually transfer any data - any optional argument isn't required. triggerServerEvent("ontakeCash2", localPlayer) The same goes for triggerClientEvent, since the server has no idea what ammunationHandler actually is, it will try to transfer nil. What is defined client-side is not defined server-side automatically. Also, what you are trying to transfer is the name of your functions - the optional arguments are meant for transferring data - for example; Client; local sendThis = "7" function exampleFunction() triggerServerEvent("onClientPlayerGreetWorld", localPlayer, sendThis) end addCommandHandler("HelloWorld", exampleFunction, false) -- False indicates that the command is NOT case-sensitive. Server; function anotherExampleFunction(receivedData) local triggeringPlayer = getPlayerName(source) outputChatBox(triggeringPlayer.."#FFFFFF has greeted the world! Data: #CC0000"..receivedData, getRootElement(), 255, 255, 255, true) end addEvent("onClientPlayerGreetWorld", true) addEventHandler("onClientPlayerGreetWorld", getRootElement(), anotherExampleFunction) As you can see, in client-side I have a variable with the string "7". I am able to transfer this to the server via using triggerServerEvent and adding the variable as an optional argument. You then have to fetch it with the server-side function, in this particular example I decided to name it "receivedData" but you could name it whatever you want. Maybe this will help you get a basic understanding of how it works. I'd also still recommend you to construct your code a bit differently, as it is hard to understand what exactly it is you're trying to do - and quite frankly it is a mess. If you write it similarly to how I demonstrated in one of my earlier replies - I believe you yourself too would be able to understand it easier.
  23. Personally, I'd recommend you to write your code differently as it will be easier for yourself to understand the code if you are inexperienced. I too am pretty new to coding, but this is how I construct my code; Client Code; Server Code; And remember, in the end, people write code differently as a matter of personal preference. Maybe you prefer it the way I do it, or maybe you don't. Either way, I really enjoy working with interface related code. Should you need any further assistance, feel free to PM me
  24. Dealman

    Map Music

    There are several ways to achieve this. If you just took 1 minute to look at the MTA Wiki, you'd find this; onClientSoundStarted You could also use getElementsByType to find all sound elements and destroy them. I'm not entirely sure as to how to isolate it to only stop sound elements started by the map though.
×
×
  • Create New...