SAMP.Lua
A SA-MP API library for MoonLoader
Install / Use
/learn @THE-FYP/SAMP.LuaREADME
SAMP.Lua
SAMP.Lua is a lua library for MoonLoader that adds some features to make SA:MP modding simpler.
Currently this library is work in progress. At this moment the only implemented module is SAMP.Events.
Installation
Copy the entire folder samp into the moonloader/lib/ directory.
SAMP.Events
Gives ability to handle SA:MP incoming and outcoming low-level network packets by very easy way.
Usage
local sampev = require 'samp.events'
-- intercept outgoing chat messages
function sampev.onSendChat(msg)
print('You said: ' .. msg)
end
You can rewrite data. Just return all arguments in the right order within a table.
function sampev.onSendChat(msg)
return {'I said: ' .. msg}
end
You can also interrupt processing any packets by returning false.
function sampev.onSetPlayerPos(position)
-- prevent server from changing player's position
return false
end
Adding your own packet handler
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
The same way you can add your own types for more complex packet structures. See source code for more information and examples.
Links
MoonLoader: http://blast.hk/moonloader/
Official thread at BlastHack: http://blast.hk/threads/14624/
Credits
FYP, MISTER_GONWIK and contributors.
Related Skills
node-connect
346.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
