#Participation currency [object Object]

1 messages ยท Page 1 of 1 (latest)

celest herald
#

For some reason i cant choose currency to give when starting an race
TypeError: Cannot read properties of undefined (reading '__asyncLoader') (@cw-racingapp/html/dist/assets/index-7a605bca.js:1)
TypeError: Cannot read properties of null (reading 'parentNode') (@cw-racingapp/html/dist/assets/index-7a605bca.js:1)
TypeError: Cannot read properties of null (reading 'emitsOptions') (@cw-racingapp/html/dist/assets/index-7a605bca.js:1)
TypeError: Cannot read properties of null (reading 'emitsOptions') (@cw-racingapp/html/dist/assets/index-7a605bca.js:1)
TypeError: Cannot read properties of null (reading 'emitsOptions') (@cw-racingapp/html/dist/assets/index-7a605bca.js:1)
TypeError: Cannot read properties of null (reading 'emitsOptions') (@cw-racingapp/html/dist/assets/index-7a605bca.js:1)
TypeError: Cannot read properties of null (reading 'emitsOptions') (@cw-racingapp/html/dist/assets/index-7a605bca.js:1)
TypeError: Cannot read properties of null (reading 'emitsOptions') (@cw-racingapp/html/dist/assets/index-7a605bca.js:1)
TypeError: Cannot read properties of null (reading 'emitsOptions') (@cw-racingapp/html/dist/assets/index-7a605bca.js:1)
TypeError: Cannot destructure property 'bum' of 'x' as it is null. (@cw-racingapp/html/dist/assets/index-7a605bca.js:1)

#

and these are all in 1 tab idk why

#

i tried with the default config and i still have this problem

summer atlas
#

Taking a look ๐Ÿ‘๏ธ

summer atlas
#

Fixed check
There's also an option in the Config (participationCurrencyOptions in Config.Options) where you can select what shows up in the menu

#

No release yet, you'll have to grab the source code.

celest herald
#

Yea that worked but any idea why the RAC menu is like that in your screenshots it was not all together

summer atlas
celest herald
summer atlas
#

these I mean

celest herald
#

nah its still the same

#

only the line below gets white

summer atlas
#

And when you open the RAC menu you get no console printouts I assume since you did not include that?

celest herald
#

no prints

#

should i enable the debug in the config

summer atlas
#

It shouldnt change this.

You updated right? Did you just paste over the existing folders?

celest herald
#

i updated

summer atlas
#

Could you try removing the html folder and replacing it with a fresh one?

celest herald
#

๐Ÿ‘๐Ÿป

#

still the same

#

replaced with the fresh 4.0.0 html folder

summer atlas
#

How'd you go about with the config? Did you make sure everything new and changed was included?

celest herald
#

Yea i used the 4.0.0 one and just changed the colour permision etc

#

also tried without any changes to the config and it was still like that

summer atlas
#

Found a potential reason

#

Not sure what the cause is

#

You can replace the dist folkder in the html folder with this, if you wanna test out the changes

celest herald
#

i will try that in just a second

summer atlas
#

I'll see if I can find the reason, but it's probably some node packaging shit thats messing it up

celest herald
#

that did not work

summer atlas
#

Did you remove the old dist folder?

celest herald
#

yes

#

it got fixed

#

๐Ÿ˜„

#

just restarted my server

#

did that 2 times before but i guess the new dist worked

#

i just had to restart the server not the script

#

thanks alot

summer atlas
#

๐Ÿ‘ nice

#

That'll work so you can test it at least. I'll try fixing the actual core issue

#

Unless there's more fix-fixes to the actual script you can probably skip the next version since it'll mainly just be fixing the NPM packages.

celest herald
#

I update when a new patch is realised every time

#

So yea will do

#

Thanks again

#

Also i small issue i changed the buy to 0.01 because i wanted one RAC to cost $100 when u buy one it removes $99 from my cash not $100 any ideas

#

If i want it to cost $100 i should change it to 0.01 right

#

Because with 0.1 it removes $10

#

but for 0.01 removes $99

summer atlas
#

Looksl ike it's doing some rounding errors

celest herald
#

here is the edits i made
conversionRate = 0.01, -- money * conversionRate = crypto amount, so if this is 0.1 and you pay $10 you get 1 Racing App Crypto. Changed from 0.1 to 0.01
sellCharge = 0.20, -- How much is lost upon selling. If 0.20 then you will lose 20% when the crypto is converted to cash
Changed from 0.05 to 0.20

summer atlas
#

You talked about the issue when buying, but I assume you meant when selling since thats what you posted later?

celest herald
#

yea its for both actually

#

buying and selling

summer atlas
#

You sure?
I tried with your values and it did buying without issues

celest herald
summer atlas
#

Selling was broken tho, but the issue was that it wasn't subtracting the fee

celest herald
#

No idea why is that for me

#

i will try to restart the server to see

#

nah

#

it still removes 99 for me

summer atlas
#

I pushed a fix for the fee, it adds some more printouts

#

only need to update the server main.lua

celest herald
#

nice

summer atlas
#

run with debug on

celest herald
#

should i send you server side prints?

#

or client

#

also ran with debug and it gave me 99

#

also when selling it give it should have game me 160 for both but it gave me 159

#

๐Ÿ˜„

#

but if i make the conversionrate 0.1 and the sellcharge 0.5 it works

#
12:32:44 PM [ script:cw-racingapp] Crypto Amount:       1
12:32:44 PM [ script:cw-racingapp] In money:    10
12:32:44 PM [ script:cw-racingapp] Attempting to charge Valkata 10      cash
12:32:44 PM [ script:cw-racingapp] Payment successful```
#
12:33:02 PM [ script:cw-racingapp] Crypto Amount:       1
12:33:02 PM [ script:cw-racingapp] In money:    10.0
12:33:02 PM [ script:cw-racingapp] After fee:   5
12:33:02 PM [ script:cw-racingapp] Attempting to charge Valkata 1       racingcrypto
12:33:02 PM [ script:cw-racingapp] Attempting to give   Valkata 5       cash```
summer atlas
#

Could you provide server logs when you do with the fee and conversion you wanted

celest herald
#

when buying

12:34:48 PM [ script:cw-racingapp] Crypto Amount:       1
12:34:48 PM [ script:cw-racingapp] In money:    99
12:34:48 PM [ script:cw-racingapp] Attempting to charge Valkata 99      cash
12:34:48 PM [ script:cw-racingapp] Payment successful
12:34:48 PM [ script:cw-racingapp] Attempting to give   Valkata 1       racingcrypto```
#

when selling with the fee

12:35:07 PM [ script:cw-racingapp] Crypto Amount:       1
12:35:07 PM [ script:cw-racingapp] In money:    99.999999999984
12:35:07 PM [ script:cw-racingapp] After fee:   79
12:35:07 PM [ script:cw-racingapp] Attempting to charge Valkata 1       racingcrypto
12:35:07 PM [ script:cw-racingapp] Attempting to give   Valkata 79      cash```
#

i made some changes to the cw-racingapp:server:sellCrypto and now it gives me 80$

summer atlas
#

Ah it's probably that the 0.01 is to small

celest herald
#

here is what i changed

    local src = source
    local rounded = math.floor((cryptoAmount / Config.Options.conversionRate) * 100 + 0.5) / 100
    local feeAmount = math.floor((rounded * Config.Options.sellCharge) * 100 + 0.5) / 100
    local afterFee = math.floor((rounded - feeAmount) * 100 + 0.5) / 100

    if UseDebug then 
        print('Selling Crypto')
        print('Crypto Amount:', cryptoAmount)
        print('In money:', rounded)
        print('Fee Amount:', feeAmount)
        print('After fee:', afterFee)
    end

    if handleRemoveMoney(src, 'racingcrypto', cryptoAmount, racerName) then
        handleAddMoney(src, Config.Payments.crypto, afterFee, racerName, 'sold_crypto')
        return 'SUCCESS'
    end
    return 'NOT_ENOUGH'
end)```
#

after the changes it gives me $80 without problem

summer atlas
#

Ah wait nvm

#

lmao LUA so trash

#

it thinks 1/0.01 = 99.999999999984

celest herald
#

yea ๐Ÿ˜„

#

lua problems

#

fixed it in the cw-racingapp:server:purchaseCrypto also

    local src = source
    local moneyToPay = math.floor((cryptoAmount / Config.Options.conversionRate) * 100 + 0.5) / 100

    if UseDebug then 
        print('Buying Crypto')
        print('Crypto Amount:', cryptoAmount)
        print('In money:', moneyToPay)
    end

    if handleRemoveMoney(src, Config.Payments.crypto, moneyToPay, racerName) then
        handleAddMoney(src, 'racingcrypto', cryptoAmount, racerName, 'purchased_crypto')
        return 'SUCCESS'
    end
    return 'NOT_ENOUGH'
end)```
summer atlas
#

adding 0.5 might cause issues

#

depending on rates and what not

celest herald
#
    local src = source
    local moneyToPay = math.floor((cryptoAmount / Config.Options.conversionRate) * 100) / 100

    if UseDebug then 
        print('Buying Crypto')
        print('Crypto Amount:', cryptoAmount)
        print('In money:', moneyToPay)
    end

    if handleRemoveMoney(src, Config.Payments.crypto, moneyToPay, racerName) then
        handleAddMoney(src, 'racingcrypto', cryptoAmount, racerName, 'purchased_crypto')
        return 'SUCCESS'
    end
    return 'NOT_ENOUGH'
end)
#

it should be good now right?

#
    local src = source
    local rounded = math.floor((cryptoAmount / Config.Options.conversionRate) * 100) / 100
    local feeAmount = math.floor((rounded * Config.Options.sellCharge) * 100) / 100
    local afterFee = math.floor((rounded - feeAmount) * 100) / 100

    if UseDebug then 
        print('Selling Crypto')
        print('Crypto Amount:', cryptoAmount)
        print('In money:', rounded)
        print('Fee Amount:', feeAmount)
        print('After fee:', afterFee)
    end

    if handleRemoveMoney(src, 'racingcrypto', cryptoAmount, racerName) then
        handleAddMoney(src, Config.Payments.crypto, afterFee, racerName, 'sold_crypto')
        return 'SUCCESS'
    end
    return 'NOT_ENOUGH'
end)
#

oh idk

#

๐Ÿ˜„

summer atlas
#

Pushed an attempt to fix it

#

when running with 0.01 conversion and 0.2 fee it works perfectly for me now

celest herald
#

LMAO

#

why it doesnt work for me

#

i guess i will stick with the one i wrote and try to the fix the 0.5 thingy

#
    local src = source
    local moneyToPay = (cryptoAmount / Config.Options.conversionRate)

    moneyToPay = tonumber(string.format("%.2f", moneyToPay))

    if UseDebug then 
        print('Buying Crypto')
        print('Crypto Amount:', cryptoAmount)
        print('In money:', moneyToPay)
    end

    if handleRemoveMoney(src, Config.Payments.crypto, moneyToPay, racerName) then
        handleAddMoney(src, 'racingcrypto', cryptoAmount, racerName, 'purchased_crypto')
        return 'SUCCESS'
    end
    return 'NOT_ENOUGH'
end)```
i removed the 0.05 now it should be an issue right?
summer atlas
#

Ih maybe not

#

haha

celest herald
#

0.5 is supposed to be $2 right

#

if thats yes then its working ๐Ÿ˜„

summer atlas
#

Maybe you got something that is overwriting the default lua math.floor

celest herald
#

it should be right i put your server/main..lua and its still $2 for 1 if i put the conversionrate to 0.5

#
01:01:49 PM [ script:cw-racingapp] Crypto Amount:       1
01:01:49 PM [ script:cw-racingapp] Conversion Rate:     0.5
01:01:49 PM [ script:cw-racingapp] Calculated Value (before floor):     200.0
01:01:49 PM [ script:cw-racingapp] Money to Pay (after rounding):       2.0
01:01:49 PM [ script:cw-racingapp] Buying Crypto
01:01:49 PM [ script:cw-racingapp] Crypto Amount:       1
01:01:49 PM [ script:cw-racingapp] In money:    2.0
01:01:49 PM [ script:cw-racingapp] Attempting to charge Valkata 2.0     cash
01:01:49 PM [ script:cw-racingapp] Payment successful
01:01:49 PM [ script:cw-racingapp] Attempting to give   Valkata 1       racingcrypto```
added prints to check if its overwriting and i think its not
summer atlas
#

Good thing that it works for you ๐Ÿ‘ not sure why the normal lua version does not

celest herald
#

this some fucked up shit

#

fivem hates me

#

๐Ÿ˜„

#

but yea good think it works for me now