indilo53 / fxserver-resource-scrambler

FXServer Resource Scrambler
GNU General Public License v3.0
22 stars 12 forks source link

RegisterNetEvent on Server Side doesn't get scrambled #3

Open Blumlaut opened 6 years ago

Blumlaut commented 6 years ago

Note that RegisterNetEvent is an alias of RegisterServerEvent ( or the other way around, i can't remember ), but from my testing RegisterNetEvent on Server doesn't scramble, i didn't test it on client, but RegisterServerEvent scrambles correctly.

TanguyOrtegat commented 6 years ago

netevent for client side 🤔

Blumlaut commented 6 years ago

netevent for client side 🤔

No, they are interchangeable, both use the same internal function for it.

BrutalBirdie commented 5 years ago

I also noticed this issue. I will try to replace all RegisterNetEvent with RegisterServerEvent and check if everything is working correctly.

EDIT: NO! You can't replace RegisterNetEvent with RegisterServerEvent and expect everything to work!

For example, I use the FiveM_LockSystem and every time I try to get the key to my car it tells me event 0fddb3e4-266e-48d5-8317-5af2561ec6e7 was not safe for net and this is that { "original": "ls:checkOwner", "new": "0fddb3e4-266e-48d5-8317-5af2561ec6e7" } https://github.com/acecconato/FiveM_LockSystem/blob/dbcbe6d857dc8083cbf7cb2364aa3082c2e1736b/server/server.lua#L55 This should be the function which is used and fails.

Blumlaut commented 5 years ago

NO! You can't replace RegisterNetEvent with RegisterServerEvent and expect everything to work! Yes you can? RegisterServerEvent and RegisterNetEvent are interchangeable.

BrutalBirdie commented 5 years ago

NO! You can't replace RegisterNetEvent with RegisterServerEvent and expect everything to work! Yes you can? RegisterServerEvent and RegisterNetEvent are interchangeable.

I just tried it like this. find . -type f -exec sed -i 's/RegisterNetEvent/RegisterServerEvent/g' {} + This will replace every "RegisterNetEvent" in every file in every folder with "RegisterServerEvent" Which resulted in an unusable server, nothing worked, you could not even join

Blumlaut commented 5 years ago

Of course RegisterServerEvent wont work on the clientside, do note this issue specifically states "RegisterNetEvent on Server Side"

BrutalBirdie commented 5 years ago

Of course RegisterServerEvent wont work on the clientside, do note this issue specifically states "RegisterNetEvent on Server Side"

Oops mind blooper :) this makes sense. Could you please point me to the doc which states that RegisterNet and Server are interchangeable? I just checked here https://docs.fivem.net/scripting-manual/working-with-events/listening-for-events/ but could not verify your claim.

EDIT: Okay what would be the solution? Update this script to include all RegisterNetEvent and/or replace every RegisterNetEvent in every Resource/server file with RegisterServerEvent. Is this statement correct @Bluethefurry

Blumlaut commented 5 years ago

Could you please point me to the doc which states that RegisterNet and Server are interchangeable?

it doesn't, but looking at scheduler:

function RegisterNetEvent(eventName)
    local tableEntry = eventHandlers[eventName]

    if not tableEntry then
        tableEntry = { }

        eventHandlers[eventName] = tableEntry
    end

    tableEntry.safeForNet = true
end

function TriggerEvent(eventName, ...)
    local payload = msgpack.pack({...})

    return TriggerEventInternal(eventName, payload, payload:len())
end

if IsDuplicityVersion() then
    function TriggerClientEvent(eventName, playerId, ...)
        local payload = msgpack.pack({...})

        return TriggerClientEventInternal(eventName, playerId, payload, payload:len())
    end

    RegisterServerEvent = RegisterNetEvent // THIS PART IS INTERESTING

Okay what would be the solution? Update this script to include all RegisterNetEvent and/or replace every RegisterNetEvent in every Resource/server file with RegisterServerEvent.

there are two solutions:

1) make all of your server side scripts use RegisterServerEvent, easy if you wrote it yourself or

2) update the script to consider RegisterServerEvent and RegisterNetEvent the same, although im not sure how easy that would be.

NebelRebell commented 5 years ago

We check now all and got this error

Error loading script server/main.lua in resource esx_inventoryhud: @esx_inventoryhud/server/main.lua:10: attempt to index a nil value (global 'ESX')
stack traceback:
        @esx_inventoryhud/server/main.lua:10: in main chunk
Failed to load script server/main.lua.
Started resource esx_inventoryhud
Creating script environments for esx_inventoryhud_trunk
Error loading script server/esx_trunk-sv.lua in resource esx_inventoryhud_trunk: @esx_inventoryhud_trunk/server/esx_trunk-sv.lua:93: attempt to index a nil value (global 'ESX')
stack traceback:
        @esx_inventoryhud_trunk/server/esx_trunk-sv.lua:93: in main chunk
Failed to load script server/esx_trunk-sv.lua.

Only with this scrip - no idea why - if we scramble all, but only not this both scripts, the inventory can't be open. Any Idea?

copy @BrutalBirdie

BrutalBirdie commented 5 years ago

We check now all and got this error

Error loading script server/main.lua in resource esx_inventoryhud: @esx_inventoryhud/server/main.lua:10: attempt to index a nil value (global 'ESX')
stack traceback:
        @esx_inventoryhud/server/main.lua:10: in main chunk
Failed to load script server/main.lua.
Started resource esx_inventoryhud
Creating script environments for esx_inventoryhud_trunk
Error loading script server/esx_trunk-sv.lua in resource esx_inventoryhud_trunk: @esx_inventoryhud_trunk/server/esx_trunk-sv.lua:93: attempt to index a nil value (global 'ESX')
stack traceback:
        @esx_inventoryhud_trunk/server/esx_trunk-sv.lua:93: in main chunk
Failed to load script server/esx_trunk-sv.lua.

Only with this scrip - no idea why - if we scramble all, but only not this both scripts, the inventory can't be open. Any Idea?

copy @BrutalBirdie

This error is/was related to Issue #5