Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Server-sided bills #18

Closed
TwitchBluelow opened this issue Jun 8, 2024 · 1 comment
Closed

Enhancement: Server-sided bills #18

TwitchBluelow opened this issue Jun 8, 2024 · 1 comment

Comments

@TwitchBluelow
Copy link

Hey there! 👋

I'm trying to bill a player through esx_billing as a server, but the current implementation of the script seems to deny this:

https://github.com/esx-framework/esx_billing/blob/main/server/main.lua

RegisterNetEvent('esx_billing:sendBill', function(playerId, sharedAccountName, label, amount)
	local xPlayer = ESX.GetPlayerFromId(source)
	local xTarget = ESX.GetPlayerFromId(playerId)
	amount = ESX.Math.Round(amount)

	if amount > 0 and xTarget then
		if string.match(sharedAccountName, "society_") then
			local jobName = string.gsub(sharedAccountName, 'society_', '')
			if xPlayer.job.name ~= jobName then
				print(("[^2ERROR^7] Player ^5%s^7 Attempted to Send bill from a society (^5%s^7), but does not have the correct Job - Possibly Cheats"):format(xPlayer.source, sharedAccountName))
				return
			end
			TriggerEvent('esx_addonaccount:getSharedAccount', sharedAccountName, function(account)
				if account then
					MySQL.insert('INSERT INTO billing (identifier, sender, target_type, target, label, amount) VALUES (?, ?, ?, ?, ?, ?)', {xTarget.identifier, xPlayer.identifier, 'society', sharedAccountName, label, amount},
					function(rowsChanged)
						xTarget.showNotification(TranslateCap('received_invoice'))
					end)
				else
					print(("[^2ERROR^7] Player ^5%s^7 Attempted to Send bill from invalid society - ^5%s^7"):format(xPlayer.source, sharedAccountName))
				end
			end)
		else
			MySQL.insert('INSERT INTO billing (identifier, sender, target_type, target, label, amount) VALUES (?, ?, ?, ?, ?, ?)', {xTarget.identifier, xPlayer.identifier, 'player', xPlayer.identifier, label, amount},
			function(rowsChanged)
				xTarget.showNotification(TranslateCap('received_invoice'))
			end)
		end
	end
end)

As we can see here, esx_billing reads the player source of the issuer to bill the player, which is obviously not possible on server-side.

Would be nice if there would be a possibility for that 👋

@Gellipapa
Copy link
Member

@TwitchBluelow Hi!
#19 Merged this solution, i hope solved your problem. Thanks @Z3rio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants