pbradjan1994

Members
  • Content Count

    6
  • Joined

  • Last visited

Community Reputation

0 Neutral

About pbradjan1994

  • Rank
    Vic

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. How can I disable collision for projectiles, created with createProjectile function, I tried everything, but no success, this is the line that creates a projectile. it's a shooter minigame, so the car is shooting projectiles/rockets: createProjectile(theVehicle, 19, x, y, z, 1.0, nil) And the line for ghostmode in meta.xml file: <setting name="#ghostmode" value='[ &quot;false&quot; ]' /> Here are a few options I've tried, with no success, so maybe someone knows what's the problem? Solution 1: function projectileGhost () local projType = getProjectileType(source) local objects = getElementsByType("object") for i, v in ipairs(objects) do setElementCollidableWith(source, v, false) end end addEventHandler( "onClientProjectileCreation", getRootElement(), projectileGhost) Solution 2: function projectileGhost () local projType = getProjectileType(source) setElementCollisionsEnabled(source, false) end addEventHandler( "onClientProjectileCreation", getRootElement(), projectileGhost) Solution 3: function projectileGhost () local projectiles = getElementsByType("projectile") for i, v in ipairs(projectiles) do setElementCollisionsEnabled(v, false) end end addEventHandler( "onClientProjectileCreation", getRootElement(), projectileGhost) I have also tried to disable collision for objects, and that works, the rockets then go through the wall, ground, buildings... Exactly what I need, but so does the car, and yes I've tried to enable collision just for the vehicles, after disabling it for objects, but that doesn't work either. Here is the script for disabling collision for objects, that works: function projectileGhost () local objects = getElementsByType("object") for i, v in ipairs(objects) do setElementCollisionsEnabled(v, false) end end addEventHandler( "onClientProjectileCreation", getRootElement(), projectileGhost) I really need to figure this small problem that's bothering me for days, so please if anyone knows the solution, let me know?
  2. Can you help me with this code: local objects = getElementsByType("object") for i, v in ipairs(objects) do setElementCollisionsEnabled(v, false) end This code works, it disables collisions with all objects, including rockets, so rockets go through walls, ground, buildings... But so does the player's car, so I tried to enable the collisions for vehicles only, after this code, but it doesn't work. I also tried to write a better code, to disable collisions just for projectiles, like this: local projectiles = getElementsByType("projectile") for i, v in ipairs(projectiles) do setElementCollisionsEnabled(v, false) end But nothing happens, I don't know why, so I was hoping that maybe you or anyone else can help me figure it out?
  3. Unfortunately, it's not working, I tried to put your code inside and also outsideof the "if" statement, , but nothing happens. I need the part with the if statement, because I am changing the projectile velocity and counter, and that is working perfectly. I just can't figure out how to disable collisions. Does it matter if the collisions for the map are set ENABLED, I mean in meta.xml (<setting name="#ghostmode" value='[ &quot;false&quot; ]' />)? But thanks anyway!
  4. I tried something like this, but it is not working. Can you tell me where I am wrong? function projectileGhost ( ) local projType = getProjectileType( source ) if projType == 19 then local objects = getElementsByType("object") setElementCollidableWith(projType, objects, false) end end addEventHandler( "onClientProjectileCreation", getRootElement(), projectileGhost )
  5. How can I set the projectile (id 19 - rocket) to not collide with the buildings, ground...? I have a shooter minigame, the car shoots rockets, and I want the rockets to only collide with another cars (hit the cars), which functions do I need to use?
  6. Hello everyone, I am new here, and also new to MTA scripting, so I was hoping that maybe some experienced scripters can help me with a small problem that I have. I have a shoot.Lua script, that is used for [SHOOTER] gamemode/minigame, the script allows the cars to shoot rockets, and it is working ok, but I want to modify it a little, so that the rockets go faster and travel less distance, and also if it is possible to make the rockets go through objects (walls, ground...), and only hit and make damage to the cars (other players)? I am including a video, so that you can see what I am trying to achieve, the first part of the video is from a SAMP server (faster rockets, less distance), and the second part is from MTA shoot.Lua script. The link to the video is: https://drive.google.com/file/d/1fhX6LXNca_ArJwfzhv9gwRL9N6jWDSma/view And the code from shoot.Lua: cLP = getLocalPlayer() screenWidth, screenHeight = guiGetScreenSize() function cRStest() setTimer(resourcesCheck, 10000, 1) end addEventHandler("onClientResourceStart", getRootElement(), cRStest) function resourcesCheck() if check=="done" then return else setTimer(cbinds, 1000, 1) textToggle=0 check="done" end end function cRS() if check=="done" then return else setTimer(cbinds, 3333, 1) textToggle=0 check="done" end end addEventHandler("onClientPlayerSpawn", getLocalPlayer(), cRS) function markers(player) if isPedInVehicle(player) then local vehicle = getPedOccupiedVehicle(player) fixVehicle(vehicle) end end addEventHandler("onClientMarkerHit", getResourceRootElement(getThisResource()), markers) function cbinds() local keys1 = getBoundKeys("vehicle_fire") local keys2 = getBoundKeys("vehicle_secondary_fire") if keys1 then for keyName, state in pairs(keys1) do bindKey(keyName, "down", cdoshoot) end bindKey("F", "down", cdoshoot) cbindsText = "- Press F or the button you use to fire to shoot rockets!\n- You can shoot once every 3 seconds.\n- good luck and have fun!." end if keys2 then for keyName, state in pairs(keys2) do bindKey(keyName, "down", cdoshoot) end end if (not keys1) and (not keys2) then bindKey("F", "down", cdoshoot) bindKey("lctrl", "down", cdoshoot) bindKey("rctrl", "down", cdoshoot) cbindsText = "- Press F or CTRL to shoot rockets!\n- You can shoot once every 3 seconds." end theVehicle = getPedOccupiedVehicle(cLP) allowShoots() bindKey("K", "down", toggleText) outputChatBox("#FF3366Press K to show/hide instructions", 255, 255, 255, true) end function toggleText() if textToggle==0 then addEventHandler("onClientRender", getRootElement(), bindsText) textToggle=1 elseif textToggle==1 then removeEventHandler("onClientRender", getRootElement(), bindsText) textToggle=0 end end function allowShoots() bindTrigger = 1 end function cdoshoot() if bindTrigger == 1 then if not isPedDead(cLP) then bindTrigger = 0 local x,y,z = getElementPosition(theVehicle) local rX,rY,rZ = getElementRotation(theVehicle) local x = x+4*math.cos(math.rad(rZ+90)) local y = y+4*math.sin(math.rad(rZ+90)) createProjectile(theVehicle, 19, x, y, z, 1.0, nil) setTimer(allowShoots, 3000, 1) end end end function bindsText() dxDrawText(cbindsText, screenWidth/15, screenHeight/2.5, screenWidth, screenHeight, tocolor(0, 149, 254, 255), 0.75, "bankgothic") end Thanks in advance to everyone!