You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
doreturn"test" endlocalinterop=require"interop"localpublic=interop.publiclocalSendClientMessage, SetPlayerHealthimport(interop.native) -- assigns SendClientMessage and SetPlayerHealth from interop.native.SendClientMessage and interop.native.SetPlayerHealthlocalCOLOR_WHITE=0xFFFFFFFFlocalfunctiontofloat(num) -- when calling native functions with a float parameter, a float value must be ensuredreturn0.0+numendfunctionpublic.OnPlayerConnect(playerid) -- adding a function to the "public" table automatically registers the callback (based on the name)SendClientMessage(playerid, COLOR_WHITE, "Hello from Lua!") -- calling a native function requires almost no modificationsendlocalcommands= {}
functioncommands.hp(playerid, params)
localhp=tonumber(params)
ifnothpthenreturnSendClientMessage(playerid, COLOR_WHITE, "Usage: /hp [value]")
endSetPlayerHealth(playerid, tofloat(hp))
SendClientMessage(playerid, COLOR_WHITE, "Your health was set to "..hp.."!")
returntrueendfunctionpublic.OnPlayerCommandText(playerid, cmdtext)
playerid=interop.asinteger(playerid) -- YALP cannot guess the type of the arguments, so they must be explicitly convertedcmdtext=interop.asstring(cmdtext)
localretcmdtext:gsub("^/([^ ]+) ?(.*)$", function(cmd, params)
localhandler=commands[string.lower(cmd)]
ifhandlerthenret=handler(playerid, params)
endend)
returnretendprint("Lua script initialized!")
[2023-10-06T02:45:44+0200] [Info] Loading plugin: YALP
[2023-10-06T02:45:44+0200] [Info] YALP v1.1 loaded
[2023-10-06T02:45:44+0200] [Info] Created by IllidanS4
[2023-10-06T02:45:44+0200] [Info] Test
[2023-10-06T02:45:44+0200] [Error] (sleep mode)
The text was updated successfully, but these errors were encountered:
[2023-10-06T02:45:44+0200] [Info] Loading plugin: YALP
[2023-10-06T02:45:44+0200] [Info] YALP v1.1 loaded
[2023-10-06T02:45:44+0200] [Info] Created by IllidanS4
[2023-10-06T02:45:44+0200] [Info] Test
[2023-10-06T02:45:44+0200] [Error] (sleep mode)
The text was updated successfully, but these errors were encountered: