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
Name | Type | Description |
---|---|---|
name | Hook | Hook name |
callback | function | Callback function |
Example
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
Name | Type | Description |
---|---|---|
src | number | Player source |
data | PhoneData | Phone data |
Example
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
Name | Type | Description |
---|---|---|
src | number | Player source |
data | PhoneData | Phone data |
Example
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
Name | Type | Description |
---|---|---|
src | number | Player source |
call | PhoneCall | Call data |
Example
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
Name | Type | Description |
---|---|---|
src | number | Player source |
call | PhoneCall | Call data |
Example
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
Name | Type | Description |
---|---|---|
src? | number | Player source if not sent from the server |
message | MessageData | Message data |
Example
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
Name | Type | Description |
---|---|---|
src | number | Player source |
account | string | Sender IBAN |
amount | number | Amount of transfer |
recipient | string | Recipient phone number / ID / IBAN |
reason | string | Transfer reason |
request? | boolean | Is this a request being accepted |
messages? | boolean | Is this a transfer within Messages app |
Example
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
Name | Type | Description |
---|---|---|
src | number | Player source |
ad | MessageData | Ad data |
Example
exports['high-phone']:createHook('postAd', function(src, message)
print(src, ad.title, ad.content)
-- Cancel the ad post
return false
end)
Last updated on