Jump to content

Dealman

Members
  • Posts

    1,421
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Dealman

  1. No, using a timer would be much more efficient. onClientRender and onClientPreRender both trigger their attached function with every frame. So unless you need the function to be run 30-60 times per second, don't use those. Should read the Warning I added to those events in the wiki, to prevent wrong usage of those
  2. Dealman

    Blocking

    Could store the blocked players in an XML file, which is stored within the resource folder client-side. Load it and store the names in a table client-side. For efficiency you could have it only update when the player; A) Blocks a new player. B) Unblocks a player. C) Resource is started.
  3. Dealman

    DX HUD

    Simple and sleek design, however I think it would look better if you aligned the money along with the bars instead of having it in the center. Also, you'll probably want to post this in the Resources forum - since this is for scripting help.
  4. Dealman

    oki solved

    onMarkerHit is a server-side event. And you can't use localPlayer server-side, it's client-side only.
  5. I would assume force only applies to some projectiles, such as grenades and molotovs. Have you tried it with those?
  6. Dealman

    solved

    That's besides the point, though. I'm here to help, but I'm not gonna read through it all and try to spot mistakes when simply providing the errors and/or warnings would make it easier for us all
  7. Dealman

    solved

    If it has many errors, it would indeed help us if you could post said errors.
  8. Now I'm confused as to what you want. You want that when the mouse hovers over an icon, it'll change the picture to a highlighted state? And do you want it to be clickable or what? Then you could make something like this; local imageHighlighted = false function onMouseHover_Handler() if(source == missionimage) then if(imageHighlighted == false) then guiStaticImageLoadImage(missionimage, "YourHighlightImage.png") imageHighlighted = true elseif(imageHighlighted == true) then guiStaticImageLoadImage(missionimage, "YourDefaultImage.png") imageHighlighted = false end end if((source ~= missionimage) and (imageHighlighted == true)) then guiStaticImageLoadImage(missionimage, "YourDefaultImage.png") imageHighlighted = false end end addEventHandler("onClientMouseEnter", getRootElement(), onMouseHover_Handler) Do note however, that I have not tested it. So it may not behave as I think it would. It's very possible that it might flicker like crazy if hovering above it. There are quite a few ways you could do this.
  9. You'll also want to use guiStaticImageLoadImage to change the image upon mouse hover. Instead of creating a new image.
  10. function mamoney (thePlayer, cmd) local money = getPlayerMoney(thePlayer) if(money < 0) then outputChatBox("Your current money is -$"..tostring(money), thePlayer, 250, 0, 0) elseif(money >= 0) then outputChatBox("Your current money is $"..tostring(money), thePlayer, 0, 250, 0) end end addCommandHandler("money", mamoney, false) Try something like that. You don't need to specify a player element if you're using this client-side. However, it is suggested to set a player's money server-side or it won't be synced. The false inside the command handler simply makes it non-case-sensitive. Tostring converts any type into a string. You were trying to concatenate an integer, which is probably why it didn't work. Remember to use Debugscript when coding for MTA, it will make your life a whole lot easier.
  11. You can't. You'd either have to make your own editbox or come up with some other workaround. One workaround I can think of would be to put a label at the same location as the editbox, but have the editbox's alpha set to 0. Then use the event onClientGUIChanged and make the label text the same as the editbox. You might have to fiddle around with guiBringToFront as well.
  12. For future reference, make sure you read the functions and events thoroughly. onClientRender and onClientPreRender will run the function it's assigned to once with every frame - so depending on what the server's maximum FPS is, and your computer's current FPS - you might be triggering the function 30-60 times per second. This is why you'll get massive lag and/or crashes.
  13. Why are you using server-side events and functions in your client script?
  14. Example from my Radio resource; if((getKeyState("lshift") == true) and (getKeyState("r") == true)) and (isChatBoxInputActive() == false) and (isConsoleActive() == false) then
  15. You could just get the ColShape Editor if you're having trouble with the calculations to get a visual feedback on the size of the ColShape. The ColShape Editor is however extremely awkward to use.
  16. Dealman

    Sirens

    Unless someone does it before me, I'll try to provide you with an example sometime after work tomorrow(Tuesday).
  17. Dealman

    Sirens

    You could do it in quite a few ways, however this is the kind of direction I'd go with; Use the event onClientKey to detect when the horn key is pressed. (You can also use getBoundKeys to retrieve all the keys bound to horn and store them in a table for better compatibility) Then check if the player is in a vehicle, and if in a defined vehicle. You can define the IDs in whatever way you want - but I would recommend using a table. Run a basic for check to see if the current vehicle model exists in the table - if it does, disable the horn using toggleControl. If it doesn't exist in the table - do nothing(Unless you want a different default horn). Then you can use these to play the sound and attach it to the vehicle; getElementPosition -- The vehicle's position, send this data to the server using triggerServerEvent. triggerServerEvent -- Trigger a server event which in return triggers an event for all clients, which triggerClientEvent -- Trigger a client-side event for all clients playSound3D -- Play the sound at the vehicle's position attachElements -- Attach the sound to the vehicle.
  18. The safezone you mentioned reminds me a whole lot of DayZ Epoch - which I very much do like. If you provide me with code so I know how zombies are spawned, I might look into making a safezone script. Also a screenshot of the location would be helpful in case I end up having to use col shapes(I despise colshapes ). I don't promise anything though as I've got plenty on my hands at the moment. As for the commands - as stated by Anubhav, already exists. What purpose would /do serve? I'd assume it be similar to /me...?
  19. Dealman

    Cry Slothbot

    Not too sure, might be something else in your code causing it - though I doubt it. You could try to convert the integer to a string, like this; local number = math.random(1,6) local sound = playSound3D("sounds/cry"..tostring(number)..".wav",pedX,pedY,pedZ,false) setSoundMaxDistance(sound, 20) If that fails, are there any warnings and/or errors? Edit: As for it running every second is most definitely caused by something else in your code. Make sure you post ALL of the relevant code - or we can't help you. If you're using timers, make sure they're not looping unless you want them to.
  20. Dealman

    is this nice?

    How about you stop comparing the length of your e-penises, and instead get back on topic...? We're here to help, not argue nor provide feedback on ideas. If you've got something WIP and you want to show it to people and get feedback, use the Resources forum.
  21. Dealman

    is this nice?

    Making a 3D Model with 3D software such as 3ds Max or Blender and following a guide on how to export it into MTA isn't really rocket science. Neither is making a texture for it. You don't really have to script much to get a 'planet' ingame. As for the idea itself, I am greatly confused as to what purpose it would serve, it just seems like a weird thing to earn money and doesn't make much sense. @KRZO: There's no defining what a 'medium scripter' is. It could mean anything, as it's not any sort of properly defined terminology within scripting. There's no 'need' to know how to work with Element Data either, sure, they're extremely useful, but you can make do without them - but it's not recommended.
  22. And he answered. You'll have to use something like onClientKey and/or onClientMouseWheel, check if the key was the mouse wheel(This only applies to onClientKey). Then you'll have to make all sorts of checks if the mouse is hovering above the scoreboard(if you want that) and such things. There are no specific pre-made functions for scrolling DX-based interfaces. For dxscoreboard specific exported functions; read this.
  23. Any errors or warnings? Also, you don't need to define root as getRootElement, root is already defined as that. You can also use resourceRoot for the resource element.
  24. For dXGUI change this; addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), openGUI) to this; addEventHandler("onClientRender", getRootElement(), openGUI) onClientResourceStart will only be triggered once. That means your DX GUI will render for one frame. onClientRender is run with every frame so 30-60 times per second.
  25. Because DX Drawings only render for one frame. Thus you need to attach it to either onClientRender or onClientPreRender. Remove the event handler to stop rendering it.
×
×
  • Create New...