-
Notifications
You must be signed in to change notification settings - Fork 1
Lua API
YRPF provide a Lua API for write scripts in Lua that interact with the core Java plugin.
In your script just put this line at the top of your file
local yrpf = ImportPackage("yrpf")
Get the player account :
local account = yrpf.GetAccount(player)
Send Toast (Type available: info, success, warn, error, default) :
yrpf.SendToast(player, type, text)
Add ambiant sound (You need to place the sound in packages/yrpf/sounds and in the package.json) :
yrpf.AddAmbiantSound(name, fileName, x,y,z, radius, volume)
Add a restricted zone for a job
yrpf.AddRestrictedZone(jobId, sx, sy, sz, ex, ey, ez)
Add a image resource
yrpf.AddImageResource(group, key, value)
Example:
yrpf.AddImageResource("worlditems", "605", "oalm/assets/605.png")
yrpf.AddImageResource("job", "icon_bottlemaker", "oalm/test1.png")
yrpf.AddImageResource("gamemap", "icon_glassmaker", "oalm/assets/icon_glassmaker.png")
--yrpf.AddMapMarker("glassmaker", "icon_glassmaker", 0, 0)
Create a particle emitter
local particle = yrpf.CreateParticle(x, y, z, sx, sy, sz, radius, particle)
-- Ask to Talos the enumeration of particles i didnt have it too
Destroy a particle emitter
yrpf.DestroyParticle(particle)
Register a new key server/client side
yrpf.AddI18nKey(lang, key, value)
Get a i18n key
yrpf.GetI18nForPlayer(player, key, param1 = nil, param2 = nil)
Create a new items template
Note : You will need to create i18n keys for the items
yrpf.CreateItemTemplate(id, name, desc, weight, picture, modelId, modelScale, foodValue, drinkValue, weaponId, ammoPerRecharge, maskId)
Example :
yrpf.CreateItemTemplate(100001, "Vodka", "A la votre camarade !", 1, "yrpf_alcohol/cl/img/vodka.png", 508, 0.5, 0, 50, -1, -1, -1)
yrpf.AddI18nKey("fr", "item.name.100001", "Vodka")
yrpf.AddI18nKey("fr", "ui.item.desc_100001", "A la votre camarade !")
Add item into the inventory of the player
yrpf.AddItem(player, itemId, quantity)
Remove item from the inventory of the player
yrpf.RemoveItem(player, itemId, quantity)
Get item quantity from the inventory of the player
yrpf.GetItemQuantity(player, itemId)
Use item event :
AddEvent("YRPF:ItemAPI:OnUse", function(player, templateId, itemId)
end)
Example :
AddEvent("YRPF:ItemAPI:OnUse", function(player, templateId, itemId)
-- Vodka
if templateId == 100001 or templateId == 100002 or templateId == 100003 then
Delay(500, function()
if GetPlayerArmor(player) < 15 then
SetPlayerArmor(player, 15)
end
CallRemoteEvent(player, "YRPF:Alcohol:DrugsConsumeAlcohol",4)
end)
end
end)
Create a new generic menu
local menuId = yrpf.CreateMenu(player)
Add a menu item
yrpf.AddMenuItem(menuId, text, action)
Show the menu
yrpf.ShowMenu(menuId)
Set the menu image
yrpf.SetMenuImage(menuId, imageUrl)
Example:
local menuId = yrpf.CreateMenu(player)
yrpf.AddMenuItem(menuId, "Test Menu", "window.CallEvent(\"RemoteCallInterface\", \"PolicePlus:CheckPlate\");")
yrpf.SetMenuImage(menuId, "oalm/test1.png")
yrpf.ShowMenu(menuId)
Image sample : https://i.imgur.com/ynAj71j.png
Close the menu
yrpf.CloseMenu(player)
Example :
local yrpf = ImportPackage("yrpf")
AddEvent("OnPackageStart", function()
-- Add translations
yrpf.AddI18nKey("fr", "plugin.citizen.show_id_card", "Montrer ma carte d'identité")
yrpf.AddI18nKey("fr", "plugin.police.check_plate", "Vérifier la plaque")
end)
AddCommand("copmenu", function(player)
local menuId = yrpf.CreateMenu(player)
yrpf.AddMenuItem(menuId, yrpf.GetI18nForPlayer(player, "plugin.police.check_plate"), "window.CallEvent(\"RemoteCallInterface\", \"PolicePlus:CheckPlate\");")
yrpf.ShowMenu(menuId)
end)
Create a new marker
local markerId = yrpf.AddMapMarker(type, icon, x, y)
Remove a marker
yrpf.RemoveMapMarker(markerId)
Example:
local id = yrpf.AddMapMarker("furnace", "icon_furnace", 0, 0)
Delay(10000, function()
yrpf.RemoveMapMarker(id)
end)
Check if the player is whitelisted for a job
yrpf.IsJobWhitelisted(player, jobid)
Spawn a wearable object
yrpf.SpawnWearableObject(modelId, animation, x, y, z, wx, wy, wz,
wrx, wry, wrz, wsx, wsy, wsz, attachSocket)
Example:
local x,y,z = GetPlayerLocation(player)
local uuid = yrpf.SpawnWearableObject(514, "CARRY_IDLE", x, y, z, -40, 35, 0, -90, 0, 0, 1, 1, 1, "hand_r")
Delete a wearable object
yrpf.DeleteWearableObject(uuid)
Add job experience (for job check the yrpf folder you will see .json files in uppercase, you can use your custom job id too
yrpf.AddJobExp(player, job, exp)
On wear a wearable object
AddEvent("YRPF:JobAPI:OnWearWearableWorldObject", function(player, modelId, uuid, x, y, z)
end)
On drop a wearable object
AddEvent("YRPF:JobAPI:OnDropWearableWorldObject", function(player, modelId, uuid, x, y, z)
end)
On vehicle rental event :
AddEvent("YRPF:JobAPI:OnVehicleRental", function(player, jobId, vehicleModelId, vehicleId)
end)
Set the chest size for a vehicle model
yrpf.SetVehicleItemChestSize(modelId, size)
Create new layout instance for the trunk
yrpf.CreateVehicleStoreLayout(vehicleModelId)
Add a placement for a wearable object (identified by the modelId)
yrpf.AddVehicleStoreLayoutItemPlacement(vehicleModelId, modelId, index, x, y, z, rx, ry, rz, sx, sy, sz)
Add/remove bank money (amount can be negative)
yrpf.AddBankMoney(player, amount)
Create a new chest
local chestId = yrpf.CreateChest(weight)
Open the chest for the player
yrpf.OpenChest(player, chestId)
Add a new item in the chest
yrpf.AddChestItem(chestId, templateId, amount)
Remove a item in the chest
yrpf.RemoveChestItem(chestId, templateId, amount)
Get all items in the chest
local items = yrpf.GetChestItems(chestId)
Create a new WorldUI (WUI) Type available : wProgressBar, wImageContainer
local wuiID = yrpf.CreateWUI(x, y, z, rx, ry, rz, width, height, type)
Destroy WUI
yrpf.DestroyWUI(wuiID)
Set the progress for a wProgressBar
yrpf.SetProgressWUI(wuiID, progress)
Set the image url for a wImageContainer
yrpf.SetImageWUI(wuiID, imageUrl)