Jump to content

[HELP] MTA Paradise - Phone not in inventory


..:D&G:..

Recommended Posts

Hello guy, I am using MTA Paradise for a very small project of mine (and also to learn more scripting) and when I try to buy a phone from the electronics shop, I don't get it in my inventory. There are no errors that could tell me why or what's wrong, but here is the function:

addEvent( "shops:buy", true ) 
addEventHandler( "shops:buy", root, 
    function( key ) 
        if source == client and type( key ) == "number" then 
            -- check if the player is even meant to shop, if so only the index is transferred so we need to know where 
            if p[ source ] then 
                local shop = shops[ p[ source ].shopID ] 
                if shop then 
                    -- check if it's a valid item 
                    local item = shop.items and shop.items[ key ] or shop_configurations[ shop.configuration ][ key ] 
                    if item then 
                        if exports.players:takeMoney( source, item.price ) then 
                            local value = item.itemID == 7 and exports.items:createPhone( ) or item.itemValue 
                            if exports.items:give( source, item.itemID, value, item.name ) then 
                                outputChatBox( "You've bought a " .. ( item.name or exports.items:getName( item.itemID ) ) .. " for $" .. item.price .. ".", source, 0, 255, 0 ) 
                                if item.itemID == 7 then 
                                    outputChatBox( "Your phone number is #" .. value .. ".", source, 0, 255, 0 ) 
                                end 
                            end 
                        else 
                            outputChatBox( "You can't afford to buy a " .. ( item.name or exports.items:getName( item.itemID ) ) .. ".", source, 0, 255, 0 ) 
                        end 
                    end 
                end 
            end 
        end 
    end 
) 

Everything looks fine to me, I don't know what's the problem here...

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...