-
Notifications
You must be signed in to change notification settings - Fork 5
Utils
PiterMcFlebor edited this page Oct 6, 2020
·
2 revisions
-- 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'
endwarning(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(eventName[, any**])
-- this is a synchronous function!
-- Example
local hasMoney = TriggerServerCallback('cars:canBuyCar', 'cheetah')
if hasMoney then
-- stuff
endRegisterClientCallback(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(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(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)