Buy GCPhone from shop

THIS MIGHT NOT WORK FOR YOU SINCE IT WAS MADE A LONG TIME AGO
THIS MIGHT NOT WORK FOR YOU SINCE IT WAS MADE A LONG TIME AGO
THIS MIGHT NOT WORK FOR YOU SINCE IT WAS MADE A LONG TIME AGO

GCPhone in store
Hello!
I have started a tutorial to help newbies make the GCPhone an buyable item.
If you haven´t purchased the phone you won´t be able to open the phone which is exactly what this guide will make you accomplish.
So to start with i want you to download the latest resource GCPhone which you can find here: GitHub - N3MTV/gcphone: Téléphone pour FiveM



Adding phone as an item
So to start with you need to add the phone into the database to make it an item.
To accomplish this you need to add ´´phone´´ under name. [THE NAME MUST BE PHONE]
Then you need to add the label which is what the in-game name is going to be. [Name can be whatever]
On the third row you have the limit which is the amount you can carry in-game. [-1= Unlimited amount.
1= 1 phone max. 2= 2 phones max that a player can carry etc.]
Then we have the other 2 rows which i suggest you leave as mine.
527295a62bbbe56dd298de08823e5f2b
OR JUST DOWNLOAD THIS IF YOU ARE USING ESX_SHOPS:

INSERT INTO `items` (`name`, `label`, `limit`) VALUES  
    ('phone', 'Phone', 1)
;
INSERT INTO shops (id, name, item, price) VALUES (98, 'TwentyFourSeven', 'phone', 175), (99, 'RobsLiquor', 'phone', 175), (100, 'LTDgasoline', 'phone', 175);

Modifying the GCPhone code to make it look for the phone in players inventory
First navigate to GCPhone then go into client/main.lua
In main.lua add this on top of the lua:

ESX              = nil

Citizen.CreateThread(function()
	while ESX == nil do
		TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
		Citizen.Wait(0)
	end
end)


Then search(CTRL+F) for these lines in main.lua:

Citizen.CreateThread(function()

        while true do
            Citizen.Wait(0)
            if IsControlJustPressed(1, KeyOpenClose) and GetLastInputMethod( 0 ) then
                TooglePhone()
            end
            if menuIsOpen == true then
                for _, value in ipairs(KeyToucheCloseEvent) do
                    if IsControlJustPressed(1, value.code) then
                        SendNUIMessage({keyUp = value.event})
                    end
                end
            end
        end
end)

And replace them with the following:

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		if IsControlJustPressed(1, KeyOpenClose) and GetLastInputMethod( 0 ) then
			ESX.TriggerServerCallback('gcphone:getItemAmount', function(qtty)
				if qtty > 0 then
					TooglePhone()
				else
					TriggerEvent('esx:showNotification', "You don´t have a ~r~phone~s~")
				end
			end, 'phone')
		end
		if menuIsOpen == true then
			for _, value in ipairs(KeyToucheCloseEvent) do
				if IsControlJustPressed(1, value.code) then
					SendNUIMessage({keyUp = value.event})
				end
			end
		end
	end
end)


Now we are done in client/main.lua. Go to server/main.lua and ADD this code as high up as you can:

ESX = nil

TriggerEvent('esx:getSharedObject', function(obj)
    ESX = obj
end)

ESX.RegisterServerCallback('gcphone:getItemAmount', function(source, cb, item)
    local xPlayer = ESX.GetPlayerFromId(source)
    local qtty = xPlayer.getInventoryItem(item).count
    cb(qtty)
end)


Restart GCPhone and you should now have phone as an item on your server.
For any problems just comment on this topic and i will try to help you the best i can :smiley:

6 Likes

does anyone have for vrpex?

SCRIPT ERROR: @gcphone/server/server.lua:13: attempt to index a nil value

Send a screenshot at your server.lua (At line 13)

i do it thank you but when im on 64 slots OneSync I can hear everyone around the map

What if my version of gcphone dosnt have a main lua in server or client but for some reason still works?? I must have an old version does anyone have a link to the newest version in en that works

Its not working properly without a server.lua and client.lua, i guess the only thing that works is the UI and you cant call anyone

well with my version I can call and text ppl it just dosent have any of the main files for some reason

Seems like a leaked version :smiley:

Lol wtf idk

Ig I’ll just use it as is but I need to add the Twitter table on the database but everyone I’ve found is either in a different language or there is an sql error

It because you need an twitter.lua aswell :smiley:

I have the twitter.lua but I need to make the right sql file to have the twitter tables in my database for it to work lol and for some reason everytime I try to write the sql it just goes wrong lol

twitter.sql (2.4 KB)

thanks bro im gonna test it now

yayayayaya it worked thanks bro thats one of the last things I needed to get done for the server release

NP :smiley:

having a bunch of issues with my other script now on my activity account lol and its being a pain in the ass now haha

What scripts?

Nvm I fixed all my errors I’m back up and running now lol just had to redo like everything