[Help] Car Ball Testing

Recommended Posts

Hello Guis I Want Make Carball Testing

So What The Codes That I Need?

I Whish Any one Help Me

15 minutes ago, raynner said:

?????????????????????????????

9 minutes ago, DABL said:

?????????????????????????????

Car Ball dont is to use Garage Car balls ?

On ١٧‏/٢‏/٢٠١٨ at 02:31, raynner said:

Car Ball dont is to use Garage Car balls ?

As Neon carball?

On ١٧‏/٢‏/٢٠١٨ at 02:31, raynner said:

Car Ball dont is to use Garage Car balls ?

I Want Know How To Move The Ball When The Ped Hit it With The Car Do You Know ?

6 hours ago, MrKAREEM said:

I Want Know How To Move The Ball When The Ped Hit it With The Car Do You Know ?

The ball isn't an object, it's a vehicle with a spherical shape and custom .col file.

• 1

Thanks I Get The Resource For CarBall

i have an problem when i shoot the ball

it fall down and didnot bumb on ground

any help pls

Edited by Dutchman101
removed useless nickmentions

Learn some maths and create your own physics, detect once it hits ground then apply force to make it bounce.

• 2

Could you just reduce your signature @MrKAREEM ? it's painful to hide it manually thanks.

• 1
• 1

20 hours ago, MisterQuestions said:

Learn some maths ﻿﻿and create your own﻿ physics﻿﻿, detect once it hits ground ﻿then apply force to make it bounce﻿.

any example pls ??

• 1

ok whats problem here or how let it falls ??

```-- client --

local hit_ball = function(hitElement, force)
if(isPedInVehicle(localPlayer)) then
setVehicleDamageProof(getPedOccupiedVehicle(localPlayer), true)
end
if(hitElement) and (getElementDimension(hitElement) == getElementDimension(localPlayer)) then
if(isBall(hitElement)) then
local x, y, z = getElementPosition(hitElement)
local throw = false
local s = playSound3D("kick.mp3", x, y, z, false)
setElementDimension(s, getElementDimension(hitElement))
setSoundMaxDistance(s, 100)
setSoundVolume(s, 0.5)
x, y, z = getElementVelocity(hitElement)
if(force > 500) then
throw = true
end
if(force > 100) then
force = 100

end
local nx, ny, nz = x*(force/30), y*(force/30), z+((force/300)*1.01)
if(source == getPedOccupiedVehicle(localPlayer)) then
x, y, z = getElementPosition(hitElement)
triggerServerEvent("onCarballBallUpdate", localPlayer, hitElement, x, y, z, nx, ny, nz)

if(throw == true) then
end
end
setElementVelocity(hitElement, nx, ny, nz)
end
end
end

isBall = function(ball)
return getElementData(ball, "ball")
end

local sync_ball = function(last_syncher, ball, x, y, z, x2, y2, z2)
if(last_syncher ~= localPlayer) then
setElementPosition(ball, x, y, z)
setElementVelocity(ball, x2, y2, z2)
end
end

```-- server --

Ball = {}

function(player)
if isElement(Ball[player]) then return outputChatBox('u have one', source) end
local x,y,z = getElementPosition(player)
Ball[player] = createObject(2912, x + 3, y, z)
outputChatBox('done', player)
setElementData(Ball[player], 'ball', true)
end)

local carball_update = function(ball, x, y, z, x2, y2, z2)
triggerClientEvent("onCarballPosUpdate", getRootElement(), source, ball, x, y, z, x2, y2, z2)
end

any one help me resource 97% completely

no help  ?

I don't think that will even set a direction to ball

7 hours ago, MisterQuestions said:

I don't think that will even ﻿set a direction to ball

how to get that ??

and how to apply physics to ball or object ??

if there was functions or what give me pls ??

and i want learn can some one help me ??

or give me code and help me pls

I did the same mistake as you time ago.

17 hours ago, MisterQuestions said:

I did the same mistake as you time ago.

﻿

1. -- "ball" is the ball element
2. -- "vehicle" is the vehicle element that collided with the ball
3.
4. local x, y, z =(ball)
5. local x2, y2, z2 =(vehicle)
6. local velX, velY, velZ =(vehicle)
7. local vel =.sqrt(velX*velX + velY*velY + velZ*velZ) -- equal to getDistanceBetweenPoints3D(0, 0, 0, velX, velY, velZ)
8.
9. local dirX, dirY, dirZ = x - x2, y - y2, z - z2
10. local dist =.sqrt(dirX*dirX + dirY*dirY + dirZ*dirZ) -- equal to getDistanceBetweenPoints3D(x, y, z, x2, y2, z2)
11. dirX, dirY, dirZ = dirX / dist, dirY / dist, dirZ / dist
12.
13. -- To change velocity of the ball now, i guess you might want to do:
14. -- setElementVelocity(ball, dirX * vel, dirY * vel, dirZ * vel)

thats work ??

• 1

thnx all solved