Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

166 Commits

Repository files navigation

YALP v1.1

YALP, short for Yet Another Lua Plugin, aims to be a simple yet extendable SA-MP plugin allowing to use Lua for SA-MP server programming.

Compared to older Lua plugins, YALP doesn't export any of the SA-MP natives or callbacks directly. Instead, it exposes a set of functions to interact with the server via a virtual filterscript, mimicking calls to AMX functions. The actual server API can be ported entirely with Lua, which removes the need to update the plugin for new versions of SA-MP and maintain all functions, and also allows the use of other plugins.

Installation

Download the latest release for your platform to the "plugins" directory and add "YALP" (or "YALP.so" on Linux) to the plugins line in server.cfg.

Include YALP.inc to create and control Lua machines on-the-fly.

Building

Use Visual Studio to build the project on Windows, or make on Linux.

Example

localinterop=require"interop"localnative=interop.nativelocalcommands= {}
functioncommands.lua(playerid, params)
-- no need to import native functions, simply call them! native.SendClientMessage(playerid, -1, "Hello from Lua!")
returntrueendfunctioncommands.setpos(playerid, params)
-- even a function from any plugin can be usedlocalfail, x, y, z=interop.vacall(native.sscanf, interop.asboolean, params, "fff")(0.0, 0.0, 0.0)
-- return values can be easily specifiediffailthenreturnnative.SendClientMessage(playerid, -1, "Wrong arguments!")
endnative.SetPlayerPos(playerid, x, y, z)
returntrueendfunctioninterop.public.OnPlayerCommandText(playerid, cmdtext)
-- properly convert values to Lua (YALP cannot determine their types)playerid=interop.asinteger(playerid)
cmdtext=interop.asstring(cmdtext)
-- take advantage of everything Lua has to offerlocalretcmdtext:gsub("^/([^ ]+) ?(.*)$", function(cmd, params)
localhandler=commands[string.lower(cmd)]
ifhandlerthenret=handler(playerid, params)
endend)
returnretend

Credits

  • Zeex for creating subhook, the backbone of this plugin.
  • The creators of Lua.

About

Yet Another Lua Plugin for SA-MP

Topics

Resources

Stars

19 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages