usedrugs

Kegwineye.

Участник
Автор темы
478
20
Версия MoonLoader
.026-beta
как правильно оформить ?

Lua:
 nick = sampGetPlayerNickname(id)
    _ , ID = sampGetCharHandleBySampPlayerId(nick)
    hp = sampGetPlayerHealth(ID)

Lua:
if uds.v then
        if isKeyDown(vkeys.VK_MENU) and isKeyJustPressed(vkeys.VK_Z) then
            if hp <=80 then
                sampSendChat('/usedrugs 1')
            end
            if hp <=60 then
                sampSendChat('/usedrugs 2')
            end
            if hp<=40 then
                sampSendChat('/usedrugs 3')
            end
        end
    end
 

Rice.

Известный
Модератор
1,753
1,660
Lua:
function main()
    repeat wait(0) until isSampAvailable()
    while true do wait(0)
        if uds.v and isKeyDown(vkeys.VK_MENU) and isKeyJustPressed(vkeys.VK_Z) then
            local hp = getCharHealth(1)
            if hp <= 80 then
                sampSendChat('/usedrugs '..(hp <= 40 and '3' or hp <= 60 and '2' or hp <= 80 and '1'))
            end
        end
    end
end
А можно было просто сделать проверку от меньшего к большему:
Lua:
if hp <= 40 then
    sampSendChat('/usedrugs 3')
elseif hp <= 60 then
    sampSendChat('/usedrugs 2')
elseif hp <= 80 then
    sampSendChat('/usedrugs 1')
end