Jump to content

AcidDK

Members
  • Posts

    29
  • Joined

  • Last visited

Posts posted by AcidDK

  1. I'll try and see.. Anyway, the reason why I wrote "if 0.0 < tmpLoss < 5.0" and not "if 0.0 < tmpLoss and tmpLoss < 5.0" is that you can do so in Pawn, C/C++, Visual Basic, PHP etc. I'm already getting tired of LUA's limitations. I'll be back soon with the results.

    EDIT:

    Okay your solution worked. I'm both happy and disappointed. I'm happy because I now don't have to worry about it anymore and I'm disappointed because LUA sucks ass :mrgreen:

    Anyway, thanks for your help mate :wink:

    tell us some of the limitations and we may be able to help

    Nah you're not the ones working on the LUA language. I'll just have to get used to it.

  2. The first thing is a GTA issue, not MTA.

    Anyways, I have the solution for it. You don't have to close and reopen the game in order to make it work. It happens because MTA is partially out of focus (don't ask me how :P), and it can be fixed by Alt + Tabbing a few times until you get it right. It's about Alt + Tabbing away from the MTA application (I know you can't minimize it but that's not what I'm saying either) and back again. If your eyes are fast enough you can see the Windows Alt + Tab application for some miliseconds.

  3. uhrm shouldn't that be..

    function addRednessOnDamage(pID,loss) 
        fadeCamera(pID, false, 1.0, 255, 0, 0) 
        local tmpLoss = tonumber(loss) 
    [color=#FF0000]    local tmpNumber = nil[/color] 
    [color=#FF0000]    if 0.0 < tmpLoss and tmpLoss < 5.0 then[/color] 
            tmpNumber = 150 
    [color=#FF0000]    elseif 5.0 < tmpLoss and tmpLoss < 15.0 then[/color] 
            tmpNumber = 250 
    [color=#FF0000]    elseif 15.0 < tmpLoss and tmpLoss < 40.0 then[/color] 
            tmpNumber = 450 
        elseif 40.0 < tmpLoss then 
            tmpNumber = 700 
        else 
            tmpNumber = 150 
        end 
        setTimer(fadeCamera, tmpNumber, 1, pID, true, 0.5) 
    end 
    

    also when you have local variables inside an 'if' they will be lost once it goes out

    I'll try and see.. Anyway, the reason why I wrote "if 0.0 < tmpLoss < 5.0" and not "if 0.0 < tmpLoss and tmpLoss < 5.0" is that you can do so in Pawn, C/C++, Visual Basic, PHP etc. I'm already getting tired of LUA's limitations. I'll be back soon with the results.

    EDIT:

    Okay your solution worked. I'm both happy and disappointed. I'm happy because I now don't have to worry about it anymore and I'm disappointed because LUA sucks ass :mrgreen:

    Anyway, thanks for your help mate :wink:

  4. Huh, well that's odd. Can you round the number to be an integer (with math.ceil() or math.floor())? I'm speculating MTA somehow reads it wrong because of the dot in the middle of that number.

    I've tried that in another situation just like this one (getDistanceBetweenPoints3D and comparing the same positions gives a value of 0, which it also understands as a boolean), and it didn't do any difference. Either way it would, logically, still be misunderstood by MTA if the float is rounded up/down to 0 or 1 as false or true.

  5. tonumber(loss) prolly returns false or something. Try this:
    outputChatBox( tostring(tonumber(loss)) ) 
    

    And see what it outputs.

    The first thing i tried was doing it without the "tonumber" function.. That is why I tried with "tonumber" and it made no difference. I was just too lazy to remove it. I'll try and do as you say anyways :)

    EDIT:

    Okay here are the results (I printed it instead of putting it in the chatbox):

    Printed "5.5999984741211" with print(tostring(tonumber(loss))).

    The error is still "attempt to compare boolean with number" on the 28th line which is where I'm comparing loss to a float the first time.

  6. I'm not the only one experiencing this problem.. Here's some snippets of code from the game mode:

    function addRednessOnDamage(pID,loss) 
        fadeCamera(pID, false, 1.0, 255, 0, 0) 
        local tmpLoss = tonumber(loss) 
        if 0.0 < tmpLoss < 5.0 then 
            local tmpNumber = 150 
        elseif 5.0 < tmpLoss < 15.0 then 
            local tmpNumber = 250 
        elseif 15.0 < tmpLoss < 40.0 then 
            local tmpNumber = 450 
        elseif 40.0 < tmpLoss then 
            local tmpNumber = 700 
        else 
            local tmpNumber = 150 
        end 
        setTimer(fadeCamera, tmpNumber, 1, pID, true, 0.5) 
    end 
    

    function Script_onPlayerDamage(attacker, attackerweapon, bodypart, loss) 
        addRednessOnDamage(source,loss) 
    end 
      
    addEventHandler("onPlayerDamage", getRootElement(), Script_onPlayerDamage) 
    

    It's supposed to make the camera fade for a longer period of time when losing more health at once.

  7. Hi.. I'm making a game mode for MTA and I've run into a problem. LUA can't tell the difference between boolean values and integers/float values.

    In a function for the event onPlayerDamage I'm comparing the health loss to some float values.. like:

    if loss < 10.0 then 
    print("loss is under 10") 
    end 
    

    This is not an example from my game mode, though this is how I do basically. When the server executes that piece of code I get an error saying that I can't compare a boolean to a number. In some way LUA thinks that the loss parameter is a boolean value, but when I print it in the console it really is a float value, like 0.32452. It makes no sense to me, and I figured there might be some experienced LUA users on this board who has some great work-around for this.

    Thanks in advance for your help!

  8. Please don't limit it for everybody.

    I personally think that it sucks with an fps below 40. It lags like shit. People with sucky pc's must admit the fact that they have a sucky pc or buy a new one. They shouldn't complain about others have an advantage just because they pc can't run GTA SA properly.

×
×
  • Create New...