Jump to content

Lpsd

Administrators
  • Posts

    319
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Lpsd

  1. function geturl(targetURL) guiSetText(addressBar,getBrowserURL(targetURL)) end addEventHandler("OnClientBrowserNavigate",resourceRoot, geturl) If that doesn't work, are you getting any errors in debugscript?
  2. Which zombie script are you using? Are there any errors in debugscript/console? What do you mean by 'vehicles sound starts bug'? Could you possibly provide some code, or any you've been editing which you think has caused this 'bug'? Please, for the love of god, we aren't mind readers.
  3. The '()' after a function is a parameter list. Parameters are basically variables, which are used when you need to pass data through to a function. You can have as many parameters as you like. Here's a small example. function add(x, y) --define your parameters, in this example they are "x" and "y" local sum = x + y return sum end local myVar = add(1, 3) --we pass through 2 arguments into the "x" and "y" slots of the add() function. x = 1, y = 3 In the example above, "myVar" would now contain the value "4". Once we have passed the arguments through to the add() function, we can refer to them as x and y thereon. In this example, it's useful because we can keep using the add() function, but passing new values through each time it is called. Hope this makes sense, anything else just ask.
  4. Lpsd

    hi all

    Huh? Looks fine to me. Can you explain further what the problem is?
  5. Won't this lose the key from the original table? Although saying that, my example assumes numerical key/indexes.
  6. Something like this should do function getMaxValue(table) local max_val, key = 0, 0 for i,v in pairs(table) do if v > max_val then max_val, key = v, i end end return max_val, key end Then use: value, key = getMaxValue(exampleTable[player].kill)
  7. Try using MTA's own MySQL functions, much easier https://wiki.multitheftauto.com/wiki/DbConnect Anyway, in the code you provided you haven't established a connection with the database, so it can't find the table.
  8. Serverside: local aw1 = {} local aw2 = {} local aw3 = {} local aw4 = {} function createAllWater() --x, y, z theWater = createWater(609, 151, -100, 609, -606, -100, 1527, 129, 4, 1527, -533, 4) setWaterLevel(1, theWater) if theWater then print("Water is work") print(theWater) end end addEventHandler( "onResourceStart", getRootElement(), createAllWater ) function helpwater() outputChatBox( "aw1 = bottom left" ) outputChatBox( "aw2 = bottom right" ) outputChatBox( "aw3 = top right" ) outputChatBox( "aw4 = top left" ) end addCommandHandler("helpmew", helpwater) function addwater1(player, cmd) local x, y, z = getElementPosition( player ) table.insert(aw1, x) table.insert(aw1, y) table.insert(aw1, z) print(x) print(y) print(z) outputChatBox( "Position 1 set" ) end addCommandHandler( "aw1", addwater1) function addwater2(player, cmd) if aw1[1] == nil then outputChatBox( "Use in order please. /aw1 /aw2 /aw3 [/aw4] optional." ) else local x, y, z = getElementPosition( player ) table.insert(aw2, x) table.insert(aw2, y) table.insert(aw2, z) print(x) print(y) print(z) outputChatBox( "Position 2 set" ) end end addCommandHandler( "aw2", addwater2) function addwater3(player, cmd) if aw2[1] == nil then print("/aw1 /aw2 /aw3 /aw4") else local x, y, z = getElementPosition( player ) table.insert(aw3, x) table.insert(aw3, y) table.insert(aw3, z) print(x) print(y) print(z) outputChatBox( "Position 3 set" ) end end addCommandHandler( "aw3", addwater3) function addwater4(player, cmd) local x, y, z = getElementPosition( player ) table.insert(aw4, x) table.insert(aw4, y) table.insert(aw4, z) print(x) print(y) print(z) outputChatBox( "Position 4 set" ) end addCommandHandler( "aw4", addwater4) function completeWater(player, cmd) if aw1[1] == nil then outputChatBox("Need to do first 3. /aw1 /aw2 /aw3 ") aw1 = {} aw2 = {} aw3 = {} aw4 = {} elseif aw4[1] == nil then outputChatBox("Triangle Maded.") local thisWater = createWater( aw1[1], aw1[2], aw1[3], aw2[1], aw2[2], aw2[3], aw3[1], aw3[2], aw3[3]) triggerClientEvent ( getRootElement(), "setWater", getRootElement(), thisWater ) aw1 = {} aw2 = {} aw3 = {} aw4 = {} else local thisWater = createWater( aw1[1], aw1[2], aw1[3], aw2[1], aw2[2], aw2[3], aw3[1], aw3[2], aw3[3], aw4[1], aw4[2], aw4[3]) triggerClientEvent ( getRootElement(), "setWater", getRootElement(), thisWater ) outputChatBox("Square Maded.") aw1 = {} aw2 = {} aw3 = {} aw4 = {} end end addCommandHandler("awc", completeWater) Clientside: function setWaterHeight(water) setWaterLevel(water, 20) end addEvent("setWater", true) addEventHandler("setWater", getRootElement(), setWaterHeight) Only works for the triangle water though. Square isn't working. I'll update if I find out why. Change '20' on the clientside script for the height you want.
  9. @Zango awesome mate, only just seen this. Thanks a bunch!
  10. @NeXuS™ that's great. However I wanted to provide a slightly more advanced solution and also clear up any confusion with the information posted by SuperCroz.
  11. This is pretty damn cool, great job so far. I'll be keeping a close eye on this.
  12. local x,y,z = 0,0,0 function spawnHandler(player) spawnPlayer(player, x, y, z) fadeCamera(player, true) setCameraTarget(player, player) end function start() local players = getElementsByType ( "player" ) for i, v in ipairs(players) do spawnHandler(v) end end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), start ) function join() spawnHandler(source) end addEventHandler("onPlayerJoin", getRootElement(), join) This will handle player spawning on join, and in the event that you restart the resource whilst people are in the server it will handle respawning too. Works fine as I use this for many resources of my own. Also this doesn't make any sense. "onPlayerJoin" is only being triggered because the resource IS loaded.
  13. Lpsd

    ScreenShot

    Only way I can think of is to use a custom chat-box in your server.
  14. Please don't use file upload sites to share your code, paste it into code blocks instead (using the "<>" formatting button in the topic editor). Provide us with the relevant piece of code and the error messages you're receiving with the code you've already tried, rather than the entire resource. Most people won't be as kind as @TheMOG; to write it for you, if you don't give us any relevant information.
  15. @Citrus, please open your own topic. This thread was created over a year ago. It would also be helpful for you to provide debug info, such as the error messages or problems you're receiving with the code. Also, you'll notice an icon in the topic editor: "<>", if you click this you'll be able to insert code there, which will make it easier for us to read.
  16. Lpsd

    help

    He's trying to teach you how to test your scripts, to work out what's going wrong. This way you'll learn more.
  17. In my meta.xml, core_c.lua was being loaded as a server script, not client as it should have been. Not sure how I missed that one, fixed it now and put the code into core_s.lua instead. However as it was being loaded as a server script, it shouldn't of made a difference with regards to the problem. One thing I didn't mention that I was using this in an interior, however I've tried without and still doesn't work. Well I'm stumped, I don't understand how this can be working fine for you, and not for me. Also yes, I'll need different rotations for each seat position. I'll be putting that into poker_tables along with other info, just not got around to it yet.
  18. @Zango This sets up the possible locations of chairs based on a table location (stored in poker_tables["init_loc"]), and creates a colshape which is used to trigger code in core_c.lua (seat_handler function) --world_init_s:r1 (15/03/2017) ----------------------------- --- serverside world initialization ----------------------------- local max_seats = 6 poker_tables = {} poker_tables["init_loc"] = { {1123.143, -11.800, 1002.085} } local remove_worldObjectIds = { 2188, 1978 } function poker_init(max) chairs = {} for i, v in ipairs(poker_tables["init_loc"]) do poker_tables[i] = {} poker_tables[i]["seats"] = max poker_tables[i]["seat1"] = {v[1] - 1.243, v[2], v[3]} poker_tables[i]["seat2"] = {v[1] - 1.053, v[2] - 1, v[3]} poker_tables[i]["seat3"] = {v[1] - 0.503, v[2] - 1.45, v[3]} poker_tables[i]["enter_col"] = createColSphere(v[1], v[2], v[3], 1) setElementInterior(poker_tables[i]["enter_col"], 12) addEventHandler ( "onColShapeHit", poker_tables[i]["enter_col"], function(hitElement) seat_handler(i, hitElement) end) end end function start() poker_init(max_seats) end addEventHandler ( "onResourceStart", getRootElement(), start ) aaand the core_c.lua: --poker/core_c:r1 (18/03/2017) ----------------------------- --- clientside poker core ----------------------------- addEventHandler( "onClientResourceStart", getRootElement( ), function () setElementFrozen(localPlayer, false) setElementCollisionsEnabled(localPlayer, true) end ) -- this is here just to ensure they're not frozen etc, probably doesn't have any effect so ignore it. function seat_handler(theTable, hitElement) if getElementType(hitElement) == "player" then --give lua's math.random a little help local nil_roll = math.random(3) local nil_roll = math.random(3) local random_seat = math.random(3) local pos = poker_tables[theTable]["seat"..tostring(random_seat)] -------------------------------------- setElementPosition(hitElement, pos[1], pos[2], pos[3]) setPedAnimation(hitElement, "ped", "seat_idle") setElementRotation(hitElement, 0, 0, 128) setElementCollisionsEnabled(hitElement, false) end end
  19. @NeXuS™ - just tried. However didn't make any difference. I'm pretty sure by using `setPedAnimation`, it sets the ped to frozen automatically anyway.
  20. @GTX no luck unfortunately. @SuperCroz -
  21. I'm making a basic system where players can sit down. When I set the player/ped animation, I can rotate the player fine using `setElementRotation` I need the player to have no collisions at this point, otherwise he'll get stuck between the table/chairs and glitch out. However when I use `setElementCollisionsEnabled`, it appears as though `setElementRotation` stops having any effect. setPedAnimation(hitElement, "ped", "seat_idle") setElementCollisionsEnabled(hitElement, false) setElementRotation(hitElement, 0, 0, -90) (doesn't matter in which order these lines are executed) Any thoughts?
  22. Lpsd

    DX Text Placement

    local screenX,screenY = guiGetScreenSize() local dxWidth,dxHeight = 901,119 local centerX, centerY = (screenX / 2) - (dxWidth / 2), (screenY / 2) - (dxHeight / 2) Here's what we're doing in this example. screenX, and screenY hold the width and height of the users screen. If we divide both those values by 2, we find the center of the users screen. Next we need your dx/GUI windows width & height, as you can see it's stored in dxWidth and dxHeight Now we calculate the center position for the GUI. If we were just to use screenX and screenY (both halved) to position the GUI window, it would be offset slightly from the center. We get the center of the users screen (screenX), and take away half the width of the GUI (dxWidth), this removes the offset of the GUI window. We do the same with screenY and dxHeight. These are stored in centerX, and centerY. Example below, to explain the 'offset' and why we have to do the maths. For your purposes to place it on the top, instead of in the exact center, you could slightly adjust the code as so: local screenX,screenY = guiGetScreenSize() local dxWidth,dxHeight = 901,119 local multi = 1.5 local centerX, centerY = (screenX / 2) - (dxWidth / 2), (screenY / 2) - (dxHeight * multi) Now you should be able to use centerX and centerY for the x and y positioning of your GUI. Play around with the value in 'multi' to make the GUI higher/lower on the screen. Hope this helps!
  23. Well, I thank the Wiki for making this clear at first glance (not)
  24. That's not what httpdownloadurl is for, I doubt it's making anything faster. httpdownloadurl is to specify an external URL (seperate from the MTA server) to download files from. If anything, it's going to cause you problems if you're just linking back to the same server. Remove httpdownloadurl from your mtaserver.conf
  25. Can you provide us with the code you're using? Otherwise we can't help you.
×
×
  • Create New...