Jump to content

Forthwind

Members
  • Posts

    43
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Forthwind

  1. Use getCommandHandlers Check mta wiki for explenation.
  2. No, this was just a test run. After everything works fine I'm ofc going to switch over from commands to events.
  3. Yeah I am doing everything from scratch, I just ran into this problem and couldn't figure out why the colshape couldn't detect the item. (item created after colshape was created). I'm guessing it's not possible for this way to be detected so I'll revamp my code so it'll create the items before the colshape. Long answer short. Yeah, making a pickup script.
  4. If this's the only way, then I'll revamp my code so it'll create the object first and afterwards the colshape. Thanks.
  5. Greetings, I've got a small problem with getElementsWithinColShape, the script for some reason doesn't seem to be able to detect if there are any items in the colshape. I've tried some bugfixing myself and the only way I could sort of make it work was by first creating the object and afterwards create the colshape. Any other way of doing it, it tells me there's no object inside the colshape. I've gone through the wiki and all it says is: "Please note that for legacy reasons, a colshape created on the client does not collide with elements already existing at that location until they first move". My code is created in serverside, and the objects are created -after- the colshape is created. On line 30 it checks if checkColz is above 0. It never continues from here because it never counts any object that is inside the colshape. batspawns = {} function allRandomz(source, commandName, dimension) maxBats = 25 spawnedBats = 0 spawnedKnives = 0 spawnedRifles = 0 spawnedShotguns = 0 if (#batspawns == 0) then for i, v in pairs(bats) do checkCol = createColSphere(bats[i][1], bats[i][2], bats[i][3], 3) finalBats = {x = bats[i][1], y = bats[i][2], z = bats[i][3], col = checkCol} table.insert(batspawns, finalBats) end end while spawnedBats < maxBats do randombat = math.random(1, #bats) taken = false for i, v in pairs(batspawns) do if i == randombat and isElement(v['col']) then checkColz = #getElementsWithinColShape(v['col'], 'object') foundDimension = getElementsWithinColShape(v['col'], "object") if checkColz > 0 then outputChatBox("is it different? " .. checkColz) -- Never outputs this, checkColz is always 0 (no elements found in colshape) for i, v in pairs(foundDimension) do if getElementDimension(v) == dimension then taken = true break else taken = false end end elseif checkColz == 0 then taken = false end end end if taken == false then newbat = createObject(336, batspawns[randombat]['x'], batspawns[randombat]['y'], batspawns[randombat]['z']) setElementDimension(newbat, dimension) spawnedBats = spawnedBats + 1 end end end addCommandHandler("spawnit", allRandomz)
  6. Bro. MTARP has/had a donation system and a good 80% of the roleplayers have been boycotting that server for years now. Other than that, you can't be too strict on players. You're trying to make everything feel like real life, you shouldn't take the fun away from the player. If I am a player and I'm forced to login everyday to open a shop to earn money, I'm going to quit playing. The roleplay experience should be realistic, but shouldn't feel like a job. You're playing to have fun, not forcing yourself online to keep your business going.
  7. 1. You can either make a table such as: myTable = { [1] = [itemID, x, y, z), [2] = [itemID, x, y, z), --etc } function spawnObject() number = math.random(1, 2) -- First item and last item in table createObject(myTable[number][1], myTable[number][2], myTable[number][3], myTable[number][4]) end -- add some edits to make it loop whatever times you want it to loop, to spawn said items or, if you're working on a flat surface where z is always the same you can do: createObject(itemID, math.random(x first side, x other side), math.random(y first side, y other side), z) Althrough I would recommend using the first method as you got full control. 2. Haven't really had any experience with this but I'm suggesting you to read the wiki about getElementsByType.
  8. Ipairs loops through all the rows of your table, with your code you only told the loop to create a vehicle for row 1 in your table. I remade the code my way, hope it'll help. vehicleList = { [1] = {422, -2409.80029, -598.06927, 132.64844}, [2] = {422, -2425.80981, -602.30896, 132.56250}, } function spawnCar() for i, v in ipairs(vehicleList) do veh = createVehicle(vehicleList[i][1], vehicleList[i][2], vehicleList[i][3], vehicleList[i][4]) end end addCommandHandler("spawncarz", spawnCar) i = index, meaning that when the loop starts it'll first go through everything in the first row of the table (this time it's [1], then it'll go through everything in the second row [2], etc. That's why I'm using vehicleList[(i)], because it'll first be 1, and when the loop completes the first section in the table, it'll become 2.
  9. I'll put something together for you, will PM you lateron tonight.
  10. You shouldn't get mad if someone steals your work, considering you stole it from owlgaming and modified 1%.
  11. Give this guy a break. Yes the server is using leaked/stolen Owl scripts but at least he's improving it/customising the scripts. Althrough this doesn't justify his actions, it's a step in the right direction. We've seen and heard it all, a couple of servers starting from scratch and building their own roleplay gamemode in the course of 1-2 years. And... What happened to those servers? They had a lifespam of 2 weeks. It's not worth the risk. In MTA Roleplay it's as the following: You build your own RP gamemode from scratch: It fails. Build it from an already existing popular but stolen gamemode: It succeeds (F*ck logic right?). Owlgaming is dieng as the developers are putting more effort into their GTA 5 gamemode than in their already existing server, players are therefore looking for something that's new, stable, shows organisation/new ideas and shows somewhat of a capable scripting team (as you also got a lot of owl copies with people claiming they can script and showing 0 progress in months of time). Well, they found it here and they're happy with it.
  12. So I'm trying to use my script to transfer a variable from server side to client side, it's going to be placed in a dx. Yet whatever I've tried so far resulted in an error, along with involving an experienced friend who also wasn't able to find the error. Anyway the script is as following: Server side: function Position (thePlayer) local root = getRootElement() spawnPlayer (source, -1756.2720947266, 787.56939697266, 167.65625, 0, math.random(0,288), 0, 0) fadeCamera(source, true) setCameraTarget(source, source) end addEventHandler( "onPlayerJoin", getRootElement(), Position ) function startgame(playerSource) actualtimer = setTimer(outputChatBox, 100000, 1, "Life is gut") setElementData(playerSource, "countdowntimer", actualtimer) end addCommandHandler( "countdown", startgame )] -- client function transferhandler() outputChatBox ("countdown") end addEventHandler("onClientRender", root, function(timer) dxDrawRectangle(313, 242, 378, 55, tocolor(5, 0, 0, 149), false) countdown = (getTimerDetails(getElementData(getLocalPlayer(), "countdowntimer"))/1000) dxDrawText("Game starts in:" .. countdown .. "seconds!", 323, 258, 646, 280, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false) end ) addEvent( "StartEvent", true ) addEventHandler( "StartEvent", getRootElement(), countdown ) These are the errors I'm getting: When I start the resourse: When I write the command /countdown (to start the countdown, variable that's going to be transferred. Lastly, those errors are equal to these lines in the script: Client.lua:30 is this line: countdown = (getTimerDetails(getElementData(getLocalPlayer(), "countdowntimer"))/1000) So the transfer is working fine, just the clientside part isn't.
×
×
  • Create New...