[LUA]How can I check if a arg is entered?

Snagg

Участник
Автор темы
25
7
Lua:
script_description(".")


function main()
while not isSampAvailable() do wait(100) end
sampRegisterChatCommand('ii', health)
sampRegisterChatCommand('iz', armor)

wait(-1)
end


function health(health)
if not isPlayerDead(PLAYER_PED) then
    if health then
setCharHealth(PLAYER_PED, health)
else
    sampAddChatMessage("Add value!", -1)
end
else
    printf("You are dead!", 1500)
end
end

function armor(armor)
    if not isPlayerDead(PLAYER_PED) then
     if armor then
     addArmourToChar(PLAYER_PED, armor)
else
    sampAddChatMessage("Add value!", -1)
end
else
      printf("You are dead!", 1500)
    end
end


Firstly sorry for spamming this section with useless questions but I can't get how can I check if arg is valid. I tried many many things. Although I am familliar with coding, I seem to have a problem with lua. 😂
 

ufdhbi

Известный
Проверенный
1,460
866
Lua:
script_description(".")


function main()
while not isSampAvailable() do wait(100) end
sampRegisterChatCommand('ii', health)
sampRegisterChatCommand('iz', armor)

wait(-1)
end


function health(health)
if not isPlayerDead(PLAYER_PED) then
    if health then
setCharHealth(PLAYER_PED, health)
else
    sampAddChatMessage("Add value!", -1)
end
else
    printf("You are dead!", 1500)
end
end

function armor(armor)
    if not isPlayerDead(PLAYER_PED) then
     if armor then
     addArmourToChar(PLAYER_PED, armor)
else
    sampAddChatMessage("Add value!", -1)
end
else
      printf("You are dead!", 1500)
    end
end


Firstly sorry for spamming this section with useless questions but I can't get how can I check if arg is valid. I tried many many things. Although I am familliar with coding, I seem to have a problem with lua. 😂
tonumber(health) , and armour
 
  • Нравится
Реакции: Snagg