High Scripts

Documentation

Hooks

Server hooks allow you to intervene in the internal processes of High Phone

General

createHook

Creates a hook for a specified action. You can also return false in some hooks to cancel the action!

Arguments

NameTypeDescription
nameHookHook name
callbackfunctionCallback function

Example

server.lua
exports['high-phone']:createHook('startCall', function(src, call)
    print(src, json.encode(call, { indent = true }))
    -- Cancel the call
    return false
end)

Hooks

beforeCreatePhone

Gets called before the phone is inserted into the database, which means you can inject your own data.

Function Parameters

NameTypeDescription
srcnumberPlayer source
dataPhoneDataPhone data

Example

server.lua
exports['high-phone']:createHook('beforeCreatePhone', function(src, data)
    print(src, data.number)
end)

afterCreatePhone

Gets called after the phone is inserted into the database. Use for tasks that don't inject any data, as it will not get updated in the database.

Function Parameters

NameTypeDescription
srcnumberPlayer source
dataPhoneDataPhone data

Example

server.lua
exports['high-phone']:createHook('afterCreatePhone', function(src, data)
    print(src, data.number)
end)

startCall

Gets called when a player starts a phone call.

Function Parameters

NameTypeDescription
srcnumberPlayer source
callPhoneCallCall data

Example

server.lua
exports['high-phone']:createHook('startCall', function(src, call)
    print(src, call.caller.number, call.participants[1].number)
    -- Cancel the call
    return false
end)

endCall

Gets called when a phone call is ended.

Function Parameters

NameTypeDescription
srcnumberPlayer source
callPhoneCallCall data

Example

server.lua
exports['high-phone']:createHook('endCall', function(src, call)
    print(src, call.caller.number, call.participants[1].number)
end)

sendMessage

Gets called when a message is sent, that includes server-sent messages.

Function Parameters

NameTypeDescription
src?numberPlayer source if not sent from the server
messageMessageDataMessage data

Example

server.lua
exports['high-phone']:createHook('sendMessage', function(src, message)
    print(src, message.sender, message.recipient)
    -- Cancel the message
    return false
end)

Last updated on

On this page