Th3-0x04-v3d1m
Member
- Joined
- Jan 12, 2019
- Messages
- 6
- Reaction score
- 5
Hello everyone, I want to introduce you to the library for MoonLoader 0.26, which will make it possible to write scripts for SA:MP 0.3.DL. In order for the library to work correctly, it is important to observe the following requirements:
In order to start writing a script, we must connect the SA-MP API:
The library has a list of functions:
Starts writing a script. We do a check for the existence of SAMP:
We did a check on SAMP, let's post something to the chat after it:
We can also register the command:
Here's a simple NoStun for example:
The author of the idea and implementation of version 0.1: LUCHARE
Author of continued development: S E V E N
If anyone has questions, write to thread
- To have a GTA assembly without too much "garbage" in it
- Have installed CLEO (preferably version 4.1)
- Have the latest version ASI Loader installed
- Installed in GTA MoonLoader 0.26
In order to start writing a script, we must connect the SA-MP API:
C++:
local dl = require "lib.SA-MP API.init"
Code:
dl.GetIsAvailable() -- SAMP congestion check
dl.Get() -- loads SAMP 0.3.DL structures with which it will be possible to work
dl.SendChat(text) -- sends text to chat (if there is a command in text, it will send a command)
dl.ToggleCursor(toggle) -- enable / disable cursor rendering
dl.RegisterClientCommand(cmd, func, replaceOld) -- registers a command for SA:MP 0.3.DL (there can be 144 client commands in total)
dl.DeleteClientCommand(cmd) -- deletes a command by its name
dl._RegisterClientCommand(cmd, func) -- registers a command, unlike RegisterClientCommand, this function cannot replace commands
dl.TakeScreenshot() -- takes a screenshot
dl.RequestSpawn() -- sends RPC about player spawn
dl.Spawn() -- spawn player
dl.SetInputMode(mode, disable_cursor) -- open / close SAMP text input line
dl.UnlockActorCam() -- returns character control (use if cursor is hidden)
dl.AddMessageToChat(msgType, msg, prefix, msgColor, prefixColor) -- sends a chat message
dl.UpdateScoreboardData()-- sends RPC UpdateScoreboardData
dl.Say(msg) -- sends text to chat
dl.SendCommand(cmd) -- sends a command to the server
dl.SendInteriorChange(intID) -- sends an RPC to change the interior
dl.RequestClass(classID) -- sends RPC class change
dl.DisableScoreboard(enable) -- disables scoreboard
dl.SetSpecialAction(actionId) -- gives the player a special action
dl.getLocalUsername() -- returns the nickname of the local player
dl.getLocalPlayerId() -- returns the local player ID
dl.getLocalPlayerPing() -- returns ping local player
dl.getLocalPlayerScore() -- returns the local player level
dl.getMaxPlayerId() -- returns the maximum ID on the server
dl.getServerIp() -- returns the IP of the server to which the player is connected
dl.getServerHostname() -- returns the name of the server to which the player is connected
dl.getServerPort() -- returns the server port to which the player is connected
dl.getGameState() -- returns the current state of SAMP
dl.isChatOpen() -- checks if chat is open, returns true / false
dl.setLocalUsername(pLocalPlayerName) -- visually sets the nickname to the local player, accepts pLocalPlayerName (string)
dl.isScoreboardOpen() -- checks if Scoreboard is open, returns true / false
dl.getServerWeather() -- returns the weather number set by the server
dl.isDialogOnScreen(pDialogId) -- checks if a dialog with a specific ID is on the screen, accepts pDialogId (int)
dl.isAnyDialogOnScreen() -- checks if any dialog is on the screen, returns true / false
dl.getDialogId() -- returns the ID of the dialog that is on the screen (use in conjunction with isAnyDialogOnScreen)
dl.getDialogStyle() -- returns the style number of the dialog that is on the screen
dl.getDialogCaption() -- returns the title of the dialog that is on the screen
dl.getDialogText() -- returns the text of the dialogue that is on the screen
dl.isPlayerConnected(playerId) -- checks if a player with a specific ID is connected to the server, returns true / false(на ID локального игрока выдает false)
Code:
function main()
while not dl.GetIsAvailable() do wait(100) end -- nothing will happen until SAMP is loaded
end
Code:
dl.AddMessageToChat(4, "Hello men", "", 0xFFFFFF, 0xFFFFFF) -- 4 is the message type, Hello men text, "" prefix (not used), and the last two parameters are color text and prefix
Code:
dl.RegisterClientCommand("test_cmd", TEST_FUNCTION)
function TEST_FUNCTION()
dl.AddMessageToChat(4, "You used the /test command", "", 0xFFFFFF, 0xFFFFFF)
end
Code:
local dl = require "lib.SA-MP API.init"
act = false
function main()
while not dl.GetIsAvailable() do wait(100) end
dl.RegisterClientCommand("nostun", NoStunAct)
while true do wait(0) end
end
function NoStunAct()
act = not act
if act then
setCharUsesUpperbodyDamageAnimsOnly(PLAYER_PED, 1)
else
setCharUsesUpperbodyDamageAnimsOnly(PLAYER_PED, 0)
end
end
The author of the idea and implementation of version 0.1: LUCHARE
Author of continued development: S E V E N
If anyone has questions, write to thread