Utils - pitermcflebor/fivem-classes-lua GitHub Wiki
Methods
_type(any) [shared]
-- This is used internally by classes, but you can use it if you want.
local objectType = _type(any)
-- Example when using it
if _type(vehicle) == 'Vehicle' then
--stuff
end
if _type(player) == 'Player' then
--stuff
end
-- WARNING! Using pure lua type() wont get the type of the classes
if type(player) == 'Player' then
-- this don't work
-- will return 'table'
end
warning [shared]
warning(string[, any**])
-- this will print a warning on console with the full name of the script,
-- the line where it was executed the warning, and the function that raised the warning
-- THIS DONT STOP THE THREAD
-- Example
warning('The Player (%s) %s doesn\'t exists!', source, name)
TriggerServerCallback [client]
TriggerServerCallback(eventName[, any**])
-- this is a synchronous function!
-- Example
local hasMoney = TriggerServerCallback('cars:canBuyCar', 'cheetah')
if hasMoney then
-- stuff
end
RegisterClientCallback [client]
RegisterClientCallback(eventName, function)
-- register a client callable event from server!
-- Example
local password = '123'
RegisterClientCallback('my:cool:callback:fromclient', function(code)
if code == password then
return true
else
return false
end
end)
TriggerClientCallback [server]
TriggerClientCallback(source, eventName[, any**])
-- this is a synchronous function!
-- Example
local vehicleProps = TriggerClientCallback(source, 'vehicle:get:props')
MySQL.Sync.execute('UPDATE owned_vehicles SET props = @props WHERE plate = @plate', {['@props']=vehicleProps, ['@plate']=vehicleProps.plate})
RegisterServerCallback [server]
RegisterServerCallback(eventName, function)
-- register a callable event from client
-- Example
RegisterServerCallback('my:cool:event:fromserver', function(gotcha)
if gotcha then
return 'hey, this is awesome!'
end
end)