[RELEASE] [ESX] Diamond Casino Lucky Wheel

Replace in client lua:

Citizen.CreateThread(function()
	while ESX == nil do
		TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
		Citizen.Wait(0)
	end
	while not ESX.IsPlayerLoaded() do 
        Citizen.Wait(500)
    end

    if ESX.IsPlayerLoaded() then
        local model = GetHashKey('vw_prop_vw_luckywheel_02a')
        Citizen.CreateThread(function()
            RequestModel(model)
            while not HasModelLoaded(model) do
                Citizen.Wait(0)
            end
            _wheel = CreateObject(model, 978.0117, 50.3487, 73.9561, false, false, true)
            SetEntityHeading(_wheel, -30.9754)
            SetModelAsNoLongerNeeded(model)
            Citizen.InvokeNative(0x651D3228960D08AF, "SE_DLC_APT_Yacht_Exterior_04", _wheel)
            SetEmitterRadioStation("SE_DLC_APT_Yacht_Exterior_04", GetRadioStationName(1))
            SetStaticEmitterEnabled("SE_DLC_APT_Yacht_Exterior_04", true)
            spawnveh()      
        end)
    end
end)

Remove the emitter stuff if you dont want music playing out the wheel lol

Add at the bottom of the client.lua:

function spawnveh()

    Zones = {
        VehicleSpawnPoint = {
            Pos   = {x = 963.75, y = 47.50, z = 75.75},
            Heading = 120.00
        }
    }

    local carmodel = GetHashKey('thrax')
    RequestModel(carmodel)
    while not HasModelLoaded(carmodel) do
        Citizen.Wait(0)
    end

    ESX.Game.SpawnLocalVehicle(carmodel,  Zones.VehicleSpawnPoint.Pos, Zones.VehicleSpawnPoint.Heading, function(vehicle)
        Citizen.Wait(10)
        SetEntityAsMissionEntity(vehicle, true, true)
        SetVehicleHasBeenOwnedByPlayer(vehicle, true)
        SetVehicleOnGroundProperly(vehicle)
        Citizen.Wait(10)
        FreezeEntityPosition(vehicle, true)
        SetEntityInvincible(vehicle, true)
        SetVehicleDoorsLocked(vehicle, 2)
        _lambo = vehicle
    end)
end
2 Likes

Thank you so much! You’re a life saver!

What do you mean? That’s just wrong- that native creates only 1 vehicle at the position you tell it to.
Of course everyone will see it- it’s networked. Are you saying it shouldn’t be networked?
If you don’t want users to steal cars, code something else, or use a resource for car ownership that I’m sure ESX has. Don’t just break multiplayer interactions for it.

Originally I thought you meant rewarding the car, not displaying it to everyone. You are right, it will spawn again and again for every client, but only if the isNetwork bool is true. In this case however, you could just set the isNetwork bool in the native to false when running the native and it will do the same as the stinky “local” ESX function.
In fact it’s likely that’s exactly what ESX is doing when you call that function, just calling a native with params and nothing else. I’ve seen one-line functions in that damn framework that just pass params to a native. It’s so pathetic.

Don’t use stinky ESX functions if you don’t have to. In fact don’t rely on framework at all if you don’t have to, especially when the alternative is literally no longer than the frameworks way of doing it.

CreateVehicle doesn’t spawn a vehicle for every client if you set isNetwork = false in that function.

Please read the document carefully before you comment out
https://runtime.fivem.net/doc/natives/#_0xAF35D0D2583051B0

That is not how that works. If cars despawn often it’s something a resource is doing to clean the server.
ESX doesn’t just magically use another method of creating cars. It has to use natives, that’s how FiveM works. And because it uses natives, it is calling CreateVehicle as well, just like as if you would call it yourself.

EDIT: You don’t know what you’re talking about, which is fine, but what isn’t fine is when you insult users due to it.
Look at these code lines for the function that spawns a “local vehicle” in ESX:

ESX.Game.SpawnLocalVehicle = function(modelName, coords, heading, cb)
	local model = (type(modelName) == 'number' and modelName or GetHashKey(modelName))

	Citizen.CreateThread(function()
		ESX.Streaming.RequestModel(model)

		local vehicle = CreateVehicle(model, coords.x, coords.y, coords.z, heading, false, false)

		SetEntityAsMissionEntity(vehicle, true, false)
		SetVehicleHasBeenOwnedByPlayer(vehicle, true)
		SetVehicleNeedsToBeHotwired(vehicle, false)
		SetModelAsNoLongerNeeded(model)
		RequestCollisionAtCoord(coords.x, coords.y, coords.z)

		while not HasCollisionLoadedAroundEntity(vehicle) do
			RequestCollisionAtCoord(coords.x, coords.y, coords.z)
			Citizen.Wait(0)
		end

		SetVehRadioStation(vehicle, 'OFF')

		if cb then
			cb(vehicle)
		end
	end)
end

ALL this function pretty much does is call natives. It does nothing else. So when you say stuff like “this is better than the native” or “even if you call the natives correctly it doesn’t work”, you are wrong. It relies completely on natives, it even calls the CreateVehicle native that you hate so much- how else do you think it would spawn a car? It literally has to use natives or there is no other way for it to work.

You didn’t know that ESX is call Native function?
ESX is not magic it just wrapping native function

well… someone can share the correct file then?

and is there a way to win the correct item ?(match with the wheel)

1 Like

wrong map

Can someone share the working casino? Thank you!

I already did. Read thru the thread.

this is good map

https://forum.cfx.re/t/release-diamonds-casino-dlc-for-fivem/668141/6

but my esx Error item

SCRIPT ERROR: @es_extended/server/classes/player.lua:325: attempt to index a nil value (local ‘item’)

ref (@es_extended/server/classes/player.lua:325)
fn (@esx_tpnrp/server/server.lua:91)

Hello, I would like to ask lottery
How to change the amount of 100,000

The wheel doesn’t spawn for me when the interior is loaded. I was able to see it without the interior but when I put the interior in the server the wheel was gone. I can still press E to spin it. Is there any fix for this?

ông ơi share mod map đê <3

I Don’t see The wheel and the car please help

1 Like

same here

is that possible that the wheel spin can be restiktet to one all 24 hours ?

How elevators increase career restrictions

This is not working, even with the fixes from [RELEASE] [ESX] Diamond Casino Lucky Wheel
The car does not show and the wheel does not show.
I am using the [The Diamond Casino Enterable MLO] as map.

https://pastebin.com/rAaHHCdu <-- Client.lua


Could someone assist :slight_smile: