Jump to content

Help - TuneShop to MySQL - !


Recommended Posts

I am having problems,

I using a basic Roleplay Gamemode, on my localhost which will not be published, but I am having problems converting this script over to MySQL Usage so it works with my Roleplay Gamemode.

function executefunction(funcname, ...) 
    if tostring(funcname) then 
        local arg = { ... } 
        if (arg[1]) then 
            for key, value in next, arg do arg[key] = tonumber(value) or value end 
        end 
        loadstring("return "..funcname)()(unpack(arg)) 
    end 
end 

ERROR: Client.lua 1: attempt to call global 'executefunction' (a nil value) 

The changes I have made to the script...

I have added in triggerServerEvent's to check in the MySQL Side.

if upg == true then 
                if upid > 3 then 
                    local ex = doesUpgradeExist(upid) 
                    if not ex then 
                        if triggerServerEvent("hasMoneyPlayer",localPlayer,tonumber(amount)) then 
                            showSure("Do you want to buy "..item.." By "..price.."$ ?","buyUpgrade",item,upid) 
                        end 
                    else 
                        showSure("You already have "..item.." do you want to remove it ?","removeUpgrade",item,upid) 
                    end 
                else 
                    if triggerServerEvent("hasMoneyPlayer",localPlayer,tonumber(amount)) then 
                        showSure("Do you want to buy "..item.." By "..price.."$ ?","buyPaintjob",item,upid) 
                    end 
                end 
            end 
        end 
        if menu == 'VEHICLE UPGRADES' then 
            if string.lower(item) == string.lower('Hydraulics') then 
                local ex = doesUpgradeExist(1087) 
                if not ex then 
                    if triggerServerEvent("hasMoneyPlayer",localPlayer,tonumber(amount)) then 
                        showSure("Do you want to buy "..item.." By "..price.."$ ?","buyUpgrade",item,1087) 
                    end 
                else 
                    showSure("You already have "..item.." do you want to remove it ?","removeUpgrade",item,1087) 
                end 
            elseif string.lower(item) == string.lower('PLATE NUMBER') then 
                showSure("Do you want to change your "..item.." By "..price.."$ ?","changePlatenumber",item) 
            end 
        end 
        ------ 
        if menu == MAIN_MENU_NAME then 
            if item == 'VEHICLE FIX' then 
                if triggerServerEvent("hasMoneyPlayer",localPlayer,tonumber(amount)) then 
                showSure("Do you want to buy "..item.." By "..price.."$ ?","buyVehicleFix",item,upid) 
                end 
            elseif item == 'VEHICLE COLOR' then 
                if triggerServerEvent("hasMoneyPlayer",localPlayer,tonumber(amount)) then 
                    showSure("Do you want to change color of your vehicle By "..price.."$ ?","buyVehicleColor",item,upid) 

SERVER SIDE---

addEvent("takeMoney",true) 
addEventHandler("takeMoney",root,function(amount) 
    if amount then 
        --local para = getElementData(source,"Money") 
        --setElementData(source,"Money",para-amount) 
        exports.global:takeMoney(source, tonumber(amount)) 
    end 
end ) 
  
function hasMoneyPlayer( amount ) 
     exports.global:hasMoney(source, tonumber(amount)) 
end 
addEvent("hasMoneyPlayer") 
addEventHandler("hasMoneyPlayer", root, hasMoneyPlayer) 

Please someone help me asap!

Link to comment

Why the hell do you need that function? It's unsafe and totally useless. Function triggerServerEvent returns boolean, but only when it's successful, it does not return from client side whatsoever. You have to send back details to client side.

triggerClientEvent 

Is that too much work for you? Or are you just lazy?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...