setCurrentCharWeapon

Rice.

Известный
Автор темы
Модератор
1,753
1,655
Версия SA-MP
  1. 0.3.7 (R1)
Нужно, чтобы при нажатие клавиши "1" доставался дигл. А при нажатие клавиши "2" доставалась эмка. Не могу разобраться с аргументами.
 
Решение
Lua:
local keys = {['1']=24, ['2']=31} -- 24 и 31 id ганов.

function main()
    repeat wait(0) until isSampAvailable()
    while true do
        wait(0)
        if not sampIsCursorActive() then
            if isKeyJustPressed(0x31) then
                setCurrentCharWeapon(PLAYER_PED,keys['1'])
            elseif isKeyJustPressed(0x32) then
                setCurrentCharWeapon(PLAYER_PED,keys['2'])
            end
        end
    end
end

ROBERT PUSHER

Известный
305
213
Lua:
local keys = {['1']=24, ['2']=31} -- 24 и 31 id ганов.

function main()
    repeat wait(0) until isSampAvailable()
    while true do
        wait(0)
        if not sampIsCursorActive() then
            if isKeyJustPressed(0x31) then
                setCurrentCharWeapon(PLAYER_PED,keys['1'])
            elseif isKeyJustPressed(0x32) then
                setCurrentCharWeapon(PLAYER_PED,keys['2'])
            end
        end
    end
end
 

ROBERT PUSHER

Известный
305
213
2-й способ
Lua:
local keys = {['0x31']=24, ['0x32']=31}

function main()
    repeat wait(0) until isSampAvailable()
    while true do
        wait(0)
        if not sampIsCursorActive() then
            for k,v in pairs(keys) do
                if k == ('0x31') and isKeyJustPressed(k) then
                    setCurrentCharWeapon(PLAYER_PED,keys['0x31'])
                elseif k == ('0x32') and isKeyJustPressed(k) then
                    setCurrentCharWeapon(PLAYER_PED,keys['0x32'])
                end
            end
        end
    end
end