### Add Custom Packet Handler for PlaySound RPC (Lua) Source: https://github.com/the-fyp/samp.lua/blob/master/README.md This example shows how to add a custom handler for the PlaySound RPC using SAMP.Events and SAMP.Raknet. It logs sound information and mutes the sound. ```lua local sampev = require 'samp.events' local raknet = require 'samp.raknet' sampev.INTERFACE.INCOMING_RPCS[raknet.RPC.PLAYSOUND] = {'onPlaySound', {soundId = 'int32'}, {coordinates = 'vector3d'}} function sampev.onPlaySound(sound, coords) -- add log message print(string.format('Sound %d at coords %0.2f, %0.2f, %0.2f', sound, coords.x, coords.y, coords.z)) -- and mute sound return false end ``` -------------------------------- ### Handle SA:MP Chat Messages with SAMP.Events (Lua) Source: https://github.com/the-fyp/samp.lua/blob/master/README.md This snippet demonstrates how to use SAMP.Events to intercept outgoing chat messages in SA:MP. It shows how to print the message, modify it before sending, and interrupt the sending process. ```lua local sampev = require 'samp.events' -- intercept outgoing chat messages function sampev.onSendChat(msg) print('You said: ' .. msg) end ``` ```lua function sampev.onSendChat(msg) return {'I said: ' .. msg} end ``` ```lua function sampev.onSetPlayerPos(position) -- prevent server from changing player's position return false end ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.