[Release] Calculator UI with custom prop

it is a stand alone script it will work with any framework

why the fu*k is that always the first thing people ask for? omg…

1 Like

Agree - dont get why they dont do it them self, it takes litterly like 2 min to convert this in to esx.

create server.lua

Add

ESX.RegisterUsableItem('calculator', function(source)
    TriggerClientEvent('Calculator:Open', source)
end)

Open client.lua

Remove the this part.

RegisterCommand('calc', function(source, args, rawCommand)
    if (oIsAnimationOn == false) then
        Calculator()
    end
end)

Go to the end of the script add the following

RegisterNetEvent('Calculator:Open')
AddEventHandler('Calculator:Open', Calculator)

Open __resource.lua

Add

server_scripts {
'server.lua'
}

Add Item to Items in mysql create a item called calculator, add it to your shops if you want to.

Now you got it as a item needed, and as something that can only be ā€œopenedā€ up if you got the item.

This aint tested there might need to be added a piece of code to close all esx menu’s down, but again this is how simple it is to make something in to an item.

1 Like

How do you exit the calculator? Pressing escape doesn’t seem to take it away

Download it again from Github, and dont rename the resource…
I made a mistake before;p Should be fixed, so ESC work again.
Edit: https://github.com/TerbSEC/Calculator/releases/tag/1.1

1 Like

how to close the calc ?

ESC or the Back button on the calc.

@CruelAlpha and @SezayThomas
I made a stupid mistake lol :stuck_out_tongue:
If you download the newest version now, it should work just fine to close it;P
The folder name need to be calculator ;p Remember that.

Cheers, i’ll try that. is the ā€œCā€ in calculator meant to be capital or simple?

This doesnt work at all for me.

Simple;)

For ESX Users!
If you want the calculator as an item, follow these steps!

Add this into your Client.lua

RegisterNetEvent("Calculator:Open")
AddEventHandler("Calculator:Open", function()
    Calculator()
end)

Create a new Server.lua, and put this in it!

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

ESX.RegisterUsableItem('calculator', function(source)
    TriggerClientEvent('Calculator:Open', source)
end)

And then, add this to your __resource.lua

server_scripts {
    "server.lua"
}

Last step: Add ā€œcalculatorā€ to the item table in database.

ez pz lemon squeezy

3 Likes

No need to do this.

Just do

RegisterNetEvent('Calculator:Open')
AddEventHandler('Calculator:Open', Calculator)

Just has to be below the function Calculator to work :slight_smile:

It basicly just calls the function direct, insted of having to do the wrapping around a function all.

You can actually even do it with functions that require parameters like

function something(a,b,c)
print(a)
end

Then add the RegisterNetEvent.

And you are able to call

TriggerEvent(ā€˜eventName’, a, b, c) direct, easy method to keep the code cleaned up.

1 Like

The function thing is normal.
But never heard about that

AddEventHandler('Calculator:Open', Calculator)

before tho

1 Like

it didn’t work out for me could you share?

1 Like

Nice good script

1 Like

What?

1 Like

dude i download the last update and its not closing the calc even i press ESC or backspace. Any fixes?

3 Likes

Don’t change the resource name:p

hi ı need a help

I also made a tv_renote prop, but it does the hand holding animation only with prop_amb_phone. Doesn’t animate with gta5 prop rop_cs_remote_01