local farm = exports['m-FarmingSimulator']:GetPlayerFarm(source)
if farm then
print("Farm ID: " .. farm.land_id)
print("Total earned: $" .. farm.total_earned)
end
local owner = exports['m-FarmingSimulator']:GetFarmOwner(1)
if owner then
print("Farm 1 is owned by: " .. owner)
end
local hasAccess = exports['m-FarmingSimulator']:HasFarmAccess(source, 1)
if hasAccess then
-- Player can interact with this farm
end
local inventory = exports['m-FarmingSimulator']:GetFarmInventory(source)
for itemName, quantity in pairs(inventory) do
print(itemName .. ": " .. quantity)
end
local success = exports['m-FarmingSimulator']:AddToFarmInventory(source, 'tomato', 10)
if success then
print("Added 10 tomatoes to farm inventory")
end
local success = exports['m-FarmingSimulator']:RemoveFromFarmInventory(source, 'tomato', 5)
if success then
print("Removed 5 tomatoes from farm inventory")
else
print("Not enough tomatoes in inventory")
end
local plants = exports['m-FarmingSimulator']:GetPlayerPlants(source)
print("Player has " .. #plants .. " plants")
for _, plant in ipairs(plants) do
print("Plant: " .. plant.plant_type .. " | Health: " .. plant.health .. "%")
end
local count = exports['m-FarmingSimulator']:GetPlayerPlantCount(source)
print("Player has " .. count .. " plants")
local animals = exports['m-FarmingSimulator']:GetPlayerAnimals(source)
print("Player has " .. #animals .. " animals")
for _, animal in ipairs(animals) do
print("Animal: " .. animal.animal_type .. " | Health: " .. animal.health .. "%")
end
local count = exports['m-FarmingSimulator']:GetPlayerAnimalCount(source)
print("Player has " .. count .. " animals")
local stats = exports['m-FarmingSimulator']:GetPlayerStatistics(source)
if stats then
local profit = stats.total_earned - stats.total_spent
print("Total profit: $" .. profit)
end
local reputation = exports['m-FarmingSimulator']:GetPlayerReputation(source)
print("Player reputation: " .. reputation)
-- Add reputation for completing contract
exports['m-FarmingSimulator']:AddPlayerReputation(source, 10)
-- Remove reputation for failing
exports['m-FarmingSimulator']:AddPlayerReputation(source, -5)
local contracts = exports['m-FarmingSimulator']:GetPlayerActiveContracts(source)
print("Player has " .. #contracts .. " active contracts")
-- Give farm ID 1 to player
local success = exports['m-FarmingSimulator']:GiveFarmToPlayer(source, 1)
if success then
TriggerClientEvent('chat:addMessage', source, {
args = {"System", "You received a farm!"}
})
end
local success = exports['m-FarmingSimulator']:RemoveFarmFromPlayer(source)
if success then
print("Farm removed from player")
end
-- Check if player owns farm before allowing purchase
RegisterServerEvent('myshop:buyFarmSeeds')
AddEventHandler('myshop:buyFarmSeeds', function()
local src = source
if not exports['m-FarmingSimulator']:DoesPlayerOwnFarm(src) then
TriggerClientEvent('chat:addMessage', src, {
args = {"Shop", "You need to own a farm first!"}
})
return
end
-- Process purchase...
end)
-- Reward players based on farming activity
function GiveFarmingBonus(source)
local stats = exports['m-FarmingSimulator']:GetPlayerStatistics(source)
if stats and stats.plants_harvested >= 100 then
-- Give bonus for harvesting 100+ plants
GivePlayerMoney(source, 5000)
exports['m-FarmingSimulator']:AddPlayerReputation(source, 25)
end
end
-- Create farming leaderboard
function GetTopFarmers()
local allPlayers = GetPlayers()
local farmers = {}
for _, playerId in ipairs(allPlayers) do
local stats = exports['m-FarmingSimulator']:GetPlayerStatistics(tonumber(playerId))
if stats then
table.insert(farmers, {
source = playerId,
earnings = stats.total_earned
})
end
end
table.sort(farmers, function(a, b) return a.earnings > b.earnings end)
return farmers
end