I’ve created a mod plugin for BeamMP which adds a robbery feature for players. By using the command “/rob,” players can “steal” from specific locations across the map. When a player uses this command, a message will be sent to all players on the server, informing them of the robbery, the perpetrator, and the location.
In the future, I plan to include police within the mod to increase the gameplay challenge. This plugin is designed for those who want to experience a new aspect of gameplay in BeamMP and engage in more player interaction.
I’m interested in hearing your thoughts and suggestions for improvement.
-- rob_command.lua
local locations_table = require("locations_table")
function onInit()
print("Rob Command Plugin Loaded")
MP.RegisterEvent("onChatMessage", "onChatMessage")
end
function onChatMessage(senderID, name, message)
if message == "/rob" then
local vehicles = MP.GetPlayerVehicles(senderID)
if not vehicles or next(vehicles) == nil then
MP.SendChatMessage(senderID, "You need a vehicle to get the position.")
return 1
end
local vid = next(vehicles)
local position, errorStr = MP.GetPositionRaw(senderID, vid)
if not position then
MP.SendChatMessage(senderID, "An error occurred while getting your position.")
print("Error: " .. errorStr)
else
local x, y, z = position.pos[1], position.pos[2], position.pos[3]
local player_pos = {x = x, y = y, z = z}
for location_name, location_data in pairs(locations_table) do
for _, coord in ipairs(location_data.coords) do
local dx, dy, dz = coord.x - player_pos.x, coord.y - player_pos.y, coord.z - player_pos.z
local distance = math.sqrt(dx * dx + dy * dy + dz * dz)
if distance <= coord.range then
if location_data.robbable then
MP.SendChatMessage(-1, name .. " has robbed " .. location_name .. "!")
else
MP.SendChatMessage(senderID, location_name .. " is not robbable.")
end
return 1
end
end
end
MP.SendChatMessage(senderID, "You are not near any robbable location.")
end
return 1
end
end
-- locations_table.lua
local locations_table = {
["Firwood Fire & Police Department"] = {
coords = {
{x = 383.291, y = 100.339, z = 53.952, range = 40},
-- {x = 4, y = 5, z = 6, range = 15},
},
robbable = false,
},
["Firwood Garage"] = {
coords = {
{x = 596.140, y = -142.277, z = 53.452, range = 25},
},
robbable = true,
},
["Firwood Savings Bank"] = {
coords = {
{x = 633.377, y = -82.045, z = 51.343, range = 20},
},
robbable = true,
},
["Firwood Motor Company"] = {
coords = {
{x = 702.536, y = -341.630, z = 56.598, range = 25},
},
robbable = true,
},
["Nodeoline City Gas Station"] = {
coords = {
{x = 715.808, y = -28.646, z = 52.325, range = 40},
},
robbable = false,
},
["Nodeoline Convenience Store"] = {
coords = {
{x = 701.986, y = -48.244, z = 51.852, range = 10},
},
robbable = true,
},
["City Church"] = {
coords = {
{x = 715.317, y = -205.848, z = 53.341, range = 35},
},
robbable = false,
},
["South City Bridge"] = {
coords = {
{x = 616.332, y = -448.192, z = 53.173, range = 70},
},
robbable = false,
},
-- Add more locations as needed
}
return locations_table
Just save each .lua to its own file, and put them in the same folder under Server, you can name the folder what ever you like.