[Help with functions] Client and server


#1

Hello,
I trying to call client function (event) by server but this wont work
Client:

AddEventHandler(‘spawnDCar’, function()
Citizen.CreateThread(function()
Citizen.Wait(50)
local carid = GetHashKey(‘luxor2’ )
local playerPed = GetPlayerPed(-1)
if playerPed and playerPed ~= -1 then
RequestModel(carid)
while not HasModelLoaded(carid) do
Citizen.Wait(0)
end
local playerCoords = GetEntityCoords(playerPed)
playerCoords = playerCoords + vector3(0, 2, 0)
local car = CreateVehicle(carid, playerCoords, 0.0, true, false)
TaskWarpPedIntoVehicle(playerPed, car, -1)
end
end)
end)
Server:

function CMD_car(source, args, help)
TriggerClientEvent(‘chatMessage’, source, ‘’, { 0, 0, 0 }, ‘Vehicle Spawned.’ )
TriggerClientEvent(‘spawnDCar’ )
end

I need help please!!!


#2

Have you setup the command processor properly?


#3

@kanersps
Yes both the server function work but the client function i have impression that not called