[help] With code

Hello everyone, new to the business of learning to write by myself :slight_smile: I wanted to know the right way to connect two chat commands in one code (else) for example)
And for example connecting “PRINT” after the command that is executed .
Probably when I understand the basics I will continue from here alone, thanks for any desire to help :slightly_smiling_face:
code test :arrow_down:

RegisterCommand('test1', function(source, args)
    local ped = PlayerPedId(-1)
    local currentPos1 = GetEntityCoords(ped)
    print(currentPos1)
    
    SetEntityCoords(ped, vector3(215.34, 7419.04, 19.07))
    currentPos1 = GetEntityCoords(ped)
    print('test1')
end)
  RegisterCommand('test2', function(source, args)
    local ped = PlayerPedId(-1)
    local currentPos2 = GetEntityCoords(ped)
    print(currentPos2)

    SetEntityCoords(ped, vector3(226.08, 7451.0, 22.86))
    currentPos2 = GetEntityCoords(ped)
    print('test2')
  end)

First you don’t have to write PlayerPedId(-1) just write PlayerPedId() and for your connecting commands questions you can just use the args parameter
.


RegisterCommand('test', function(source, args)
    local ped = PlayerPedId()
    if args[1] == '1' then
    currentPos1 = GetEntityCoords(ped)
    print(currentPos1)
    SetEntityCoords(ped, vector3(215.34, 7419.04, 19.07))
    currentPos1 = GetEntityCoords(ped)
    print('test1')
    elseif args[1] == '2' then
    currentPos2 = GetEntityCoords(ped)
    print(currentPos2)
    SetEntityCoords(ped, vector3(226.08, 7451.0, 22.86))
    currentPos2 = GetEntityCoords(ped)
    print('test2')
    end
end)

The command will be /test 1 and /test 2

Sorry for the bad formatting I’m writing from my phone.

1 Like

Thanks buddy for teaching me something new :slightly_smiling_face: