Jump to content

myonlake

Members
  • Posts

    2,312
  • Joined

  • Days Won

    40

Everything posted by myonlake

  1. myonlake

    Another Q

    What's the point in refreshing it if you don't have to refresh it in the first place? You can refresh it as you use it, instead.
  2. You can use Eir to do whatever you want. Main branch still has that limit.
  3. myonlake

    Another Q

    Why do you have to refresh it constantly?
  4. You can use setElementStreamable to toggle streaming. This might fix the issue. I also suggest you wrap the spawns inside a onClientResourceStart event, that might have an effect on the issue.
  5. If you're not nearby the area where they are spawned, the vehicles are automatically teleported under the map since no one is streaming the vehicles. It's just a big problem sometimes to create entities client-side as they require a streamer. You can make your own streamer system and create all entities from a resource and use it to synchronize elements. I can't see a problem in using the server to make the vehicles. It's not too trustworthy to make them client-side.
  6. Well, it won't lag that much really. With MTA:Eir you can have nearly unlimited (or just unlimited) objects as much as you want, but the streamer will handle the pressure and render nearby elements to you. There is an introduction video for Eir, and it's made inside a super-huge map.
  7. That's most likely because you're creating the vehicles client-side. I suggest switching to server-side and doing whatever you have to client-side. Client-side vehicles have limited features as well, just so you know.
  8. As far as I know, MTA:BLUE has a maximum entity limit of 65,536 and you can have a maximum of 750 entities streamed in. MTA:Eir on the other hand probably has a higher limit on both, not sure about the numbers on Eir; might even be unlimited.
  9. myonlake

    Another Q

    No, there isn't, you misunderstood me. You have to switch it to 'source' in order for it to work. There is no player parameter anywhere, so you can't return the player element by that name neither.
  10. myonlake

    Another Q

    Because there is no element "player". local ranks1 = getElementData(player, "Rank")
  11. That's because the array value contains the key, that's why it duplicates itself. The function automatically sets the key first and then the value after it. tableCreate.X = "X: "..X -- Should be tableCreate.X = X EDIT: Ah, I understand what went wrong there. It's because it sorts it by the value (max > min). Try this. The only problem with this is that it formats the array alphabetically, which causes lx-lz to become the first ones in the output. local array = { x = 1, y = 2, z = 3, lx = 1, ly = 2, lz = 3 } function splitArrayIntoLines( _array ) if ( type( _array ) ~= "table" ) then return "" end local splitted = "" local formed = { } for i,v in pairs( _array ) do formed[ #formed + 1 ] = i .. ": " .. v end table.sort( formed, function( a, b ) return a < b end ) for i,v in pairs( formed ) do splitted = splitted .. "\r\n" .. v end return splitted end addCommandHandler( "clipboard", function( ) if ( array ) and ( type( array ) == "table" ) then local theReturn = splitArrayIntoLines( array ) setClipboard( theReturn ) outputConsole( theReturn ) end end )
  12. This is what you need, pretty much. local array = { hi = "hello", water = "drink", "123456", 1833 } function splitArrayIntoLines( _array ) if ( type( _array ) ~= "table" ) then return "" end local splitted = "" for i,v in pairs( _array ) do splitted = splitted .. "\r\n" .. i .. ": " .. v end return splitted end addCommandHandler( "clipboard", function( ) if ( array ) and ( type( array ) == "table" ) then local theReturn = splitArrayIntoLines( array ) setClipboard( theReturn ) outputConsole( theReturn ) end end ) This returns the following: 1: 123456 2: 1833 water: drink hi: hello
  13. You can use SQLite, MySQL or XML to store such data. There are some community resources made by other people, which do the same thing: https://community.multitheftauto.com/in ... ils&id=252 https://community.multitheftauto.com/in ... ils&id=699 https://community.multitheftauto.com/in ... ls&id=1559 https://community.multitheftauto.com/in ... ls&id=5004 https://community.multitheftauto.com/in ... ls&id=7455 https://community.multitheftauto.com/in ... ls&id=8184
  14. External connections are not only a security risk, but also a big loss for the hosting company. Also, regarding 000webhost's stand on external connections... http://puu.sh/6R4fo.png
  15. Amazing shiet, can't wait to see us hit 30,000
  16. myonlake

    Countdown

    I'd like to refer you to read the following material to learn more about Lua and Lua in MTA: Lua: Lua Manuals and Tutorials Lua & MTA: Introduction to Resources Lua & MTA: Scripting Introduction Lua & MTA: Introduction to Scripting the GUI The "Scripting Introduction" is essential for you to learn the difference between client-/server-side scripting.
  17. myonlake

    Countdown

    You will have to make an event for when a player enters the marker. That event will trigger the next function, which will calculate the countdown client-side, and while it does that it will also render countdown text on the screen. When the countdown is over, it will use the moveObject function server-side to move the gate.
  18. It's because that isn't the full file. It's never ended properly. As you can see, it ends with a dot, that's not how it's supposed to end. You have to close the tag and put in the end.
  19. I made you a list of the main things I made in the script, these are the following: Screen width and height: I defined two variables for the screen width and height. I need those to center the text and draw the rectangle right on top of the absolute resolution of the client's window. Transparency, transparency step and fade speed: I defined the default transparency, step and speed in order for the fader part to work, otherwise it will throw indefinite errors because of undefined variables. Tick count: I defined a variable for the default tick. The default tick count is used to measure the milliseconds that the resource has been running, this is used because I want to change the text over time. Text to display: I defined the variable because again, it will throw errors otherwise. The variable is changed over time to the values defined in the text array. Tick texts: These text phrases are defined for the over time changing part. Rendering event: I initialized the render event in order to draw the stuff. If I didn't define the render event, it would display for one frame only, which means you'd see the whole thing popping up, and then closing very fast. This is why I use the render function, to draw it correspondingly to the client's frames per second count. Fader: I use the fader to fade the text in and out corresponding to the fader speed defined in the top of the script. When the transparency goes lower than the lowest amount you can have, then it will set the step to the opposite, and then continues fading in until it goes to the top (255) and then repeating the same again. This causes the fading animation on the texts. Ticks: The ticks are used as "timers" if you want to say so. This allows timing events without the need to use hardcoded timers, which aren't too efficient when there are a lot of timers around. Drawing: I use the draw functions to draw the background rectangle and texts on the screen, this is the display part of the code. The rest is simply just the magic behind the scenes. The texts are drawn in the middle of the screen with some simple calculations (screen width minus text width, divided by two; same thing for the height). The rendering functions are surprisingly efficient and very useful. I've used them in many applications, not just drawing stuff, but also calculations and other algorithms that need constant updates. Render events are only available client-side, because only clients are able to render graphics. Server is just the machine that provides clients with updated data. If you make all your scripts client-side, it means the server doesn't know anything about the client.
  20. I had some spare time and made you a small example script on drawing. It's nothing too fancy, but it's something that you can understand and learn, hopefully. Read the comments I made, those explain what's happening on each step. Feel free to change and test the script as much as you want, that's the only way you can learn what something does and how it does it and such. local screenWidth, screenHeight = guiGetScreenSize( ) -- Get the client's screen width and height (absolute resolution) local transparency, transparencyStep, fadeSpeed = 255, true, 2 -- Define the default transparency, transparency step and fade speed local tick = getTickCount( ) -- Define the script's start tick count local textToDisplay = "nil" -- Define a default text to display local postGUI = false -- Define if the drawings should be drawn on top of GUI elements local tickTexts = { -- An array containing texts for the text drawings "This is a small test script for drawings.", "And this is an amazing tick count test.", "This is pretty fancy right?", "And the current transparency level is " } addEventHandler( "onClientRender", root, -- Initialize a renderer event function( ) if ( transparencyStep ) then -- If the transparency step is set to 'true' (fade out), then fade out with the speed we defined above transparency = transparency - math.min( 10, fadeSpeed ) -- Decrease transparency level and make a limit at 10 (so you can't make the speed 999999, which doesn't work) if ( transparency <= 0 ) then -- If the transparency level is equal to, or lower than 0, then set the transparency step to 'false' (fade in) transparencyStep = false end else -- If the transparency step is set to 'false' (fade in), then fade in with the speed we defined above transparency = transparency + math.min( 10, fadeSpeed ) -- Decrease transparency level and make a limit at 10 (so you can't make the speed 999999, which doesn't work) if ( transparency >= 255 ) then -- If the transparency level is equal to, or lower than 255, then set the transparency step to 'true' (fade out) transparencyStep = true end end if ( getTickCount( ) - tick >= 1500 ) and ( getTickCount( ) - tick < 4500 ) then -- If the ticks are equal to, or higher than 1500, but lower than 4500, then set the text to the array key 2 textToDisplay = tickTexts[ 2 ] elseif ( getTickCount( ) - tick >= 4500 ) and ( getTickCount( ) - tick < 6500 ) then -- If the ticks are equal to, or higher than 4500, but lower than 6500, then set the text to the array key 3 textToDisplay = tickTexts[ 3 ] elseif ( getTickCount( ) - tick >= 6500 ) then -- If the ticks are equal to, or higher than 6500, then set the text to the array key 4 textToDisplay = tickTexts[ 4 ] .. transparency else -- If the ticks are something else, then display the first key of the array textToDisplay = tickTexts[ 1 ] end -- Define the background color local backgroundColor = tocolor( 0, 0, 0, 100 ) -- Define the text's font size, family and color local textFontSize, textFontFamily, textColor = 1.5, "default-bold", tocolor( 238, 238, 238, transparency ) -- Transparency is fading in and out above local textWidth, textHeight = dxGetTextWidth( textToDisplay, textFontSize, textFontFamily ), dxGetFontHeight( textFontSize, textFontFamily ) -- Define the text width and height we're currently reading dxDrawRectangle( 0, 0, screenWidth, screenHeight, backgroundColor, postGUI ) -- Draw a rectangle on the whole screen with the transparency of 100 dxDrawText( textToDisplay, ( screenWidth - textWidth ) / 2 + 1, ( screenHeight - textHeight ) / 2 + 1, textWidth, textHeight, tocolor( 13, 13, 13, transparency ), textFontSize, textFontFamily, "center", "center", false, false, postGUI, false, false ) -- Draw a light shadow under the main text, which is drawn next dxDrawText( textToDisplay, ( screenWidth - textWidth ) / 2, ( screenHeight - textHeight ) / 2, textWidth, textHeight, textColor, textFontSize, textFontFamily, "center", "center", false, false, postGUI, false, false ) -- Draw the text we defined above end )
  21. Because the code doesn't make any sense, really. Try the following code. Server-side local safecol = createColCuboid( 95.974617004395, 1751.3895263672, 17.640625, 255, 255, 255 ) setElementData( safecol, "zombieProof", true ) local safeZoneRadar = createRadarArea( 95.974617004395, 1751.3895263672, 255, 255, 255, 255, 255 ) setElementData( safeZoneRadar, "zombieProof", true ) addEventHandler( "onColShapeHit", root, function( hitElement, matchingDimension ) if ( getElementType( hitElement ) == "player" ) and ( matchingDimension ) and ( getElementData( source, "zombieProof" ) ) then setElementData( hitElement, "player:safezone", true ) outputChatBox( "You entered the safe area.", hitElement, 0, 255, 0, false ) end end ) addEventHandler( "onColShapeLeave", root, function( leaveElement, matchingDimension ) if ( getElementType( leaveElement ) == "player" ) and ( matchingDimension ) and ( getElementData( source, "zombieProof" ) ) then if ( getElementData( leaveElement, "player:safezone" ) ) then removeElementData( leaveElement, "player:safezone" ) end outputChatBox( "You left the safe area.", leaveElement, 255, 0, 0, false ) end end ) Client-side addEventHandler( "onClientPedDamage", root, function( ) if ( getElementData( source, "player:safezone" ) ) then cancelEvent( ) end end )
  22. myonlake

    Doesn't work

    It cannot be explained any more easier, that's plain English and you should be able to understand that. All functions have to be ended, your function is never ending and so you have to add an additional "end" there. There is no "account" variable, so you need to define one. There is no rank defined neither, so you need to do that. "thePlayer" is not a function, so you can take the brackets off of them, mind as well removing the first closing brackets on the setElementData functions. You're also mixing getAccountData with getElementData. You also didn't open an if statement on the getAccountData part, so you have to do that. Keep in mind that you have to define the variable before the statement, in Lua you're not able to define varibles in statements (as far as I've tried).
×
×
  • Create New...