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. Can be cancelled.

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. Can be cancelled.

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)

transferMoney

Gets called when you transfer money to someone. Can be cancelled.

Function Parameters

NameTypeDescription
srcnumberPlayer source
accountstringSender IBAN
amountnumberAmount of transfer
recipientstringRecipient phone number / ID / IBAN
reasonstringTransfer reason
request?booleanIs this a request being accepted
messages?booleanIs this a transfer within Messages app

Example

server.lua
exports['high-phone']:createHook('postAd', function(src, message)
    print(src, ad.title, ad.content)
    -- Cancel the ad post
    return false
end)

postAd

Gets called when an advertisment is posted in Adspot. Can be cancelled.

Function Parameters

NameTypeDescription
srcnumberPlayer source
adMessageDataAd data

Example

server.lua
exports['high-phone']:createHook('postAd', function(src, message)
    print(src, ad.title, ad.content)
    -- Cancel the ad post
    return false
end)

Last updated on