Jump to content

Spajk

Members
  • Posts

    285
  • Joined

  • Last visited

Posts posted by Spajk

  1. local stats = {73, 75, 71, 77, 78} 
    

    for _, stat in ipairs(stats) do 
        setPedStat(source, stat, 1000) 
    end 
    

    This is why, stat ID 73 is "73: WEAPONTYPE_SAWNOFF_SHOTGUN_SKILL"

    You are setting player's skill to "pro" by, but in the code below you are only changing weapon property at "poor".

    Simple fix is to include the following line in the code:

    setWeaponProperty(26, "pro", "damage", 30) 
    

    Also, weapon properties don't need to be set again on every spawn.

  2. SMF should use the following algorithm for password hashing:

    $hash = sha1(strtolower($member_name) . $password); 
    

    Try to port that to MTA.

    EDIT:

    I wasn't really busy so I decided to do it myself.

    function generateSMFHash(user, pass) 
        return sha1(string.lower(user)..pass) 
    end 
    

    In order for it to work you should install the SHA module by mabako:

    https://wiki.multitheftauto.com/wiki/Modules/SHA

  3. I think I know enough of C++ to build something like that.

    But.

    Today I did some "testing" and what I encountered is that the calculations don't seem to be right. Sometimes, I hear the sounds very loud, I move the camera just a bit and it's almost silent.

  4. It would be better if you used newLevel argument from onPlayerChangeLevel.

    function sPlayerLevel() 
        local account = getPlayerAccount(source) 
        local playerLevel = 0 
        if not (isGuestAccount(account)) then 
            local level = exports.exp_system:getAccountLevel(account) 
            if (level ~= nil) and (level ~= false) then 
                playerLevel = level 
            end 
        end 
        setElementData(source, "Level", playerLevel) 
    end 
      
    function sPlayerLevel2(old, new) 
        setElementData(source, "Level", new) 
    end 
    addEvent("onPlayerChangeLevel", true) 
    addEvent("onPlayerLevelUP", true) 
    addEventHandler("onPlayerChangeLevel", getRootElement(), sPlayerLevel2) 
    addEventHandler("onPlayerLevelUP", getRootElement(), sPlayerLevel2) 
    addEventHandler("onPlayerLogin", getRootElement(), sPlayerLevel) 
    

    Avoid using timers as much as possible. They are very performance-intensive.

  5. -- create a blue blip 
    local blip = createBlip ( x, y, z 0, 2, 5, 120, 250) 
    local color = false 
      
    function checkColor() 
        if color then 
            setBlipColor(blip, 5, 120, 250) 
        else 
            setBlipColor(blip, 255, 0, 0) 
        end 
      
        color = not color 
    end 
    setTimer ( checkColor, 1500, 0 ) 
      
    

  6. The scoreboard uses the data from element data.

    If you are using Castillo's exp system, which I think you are using, then you can see this page:

    https://wiki.multitheftauto.com/wiki/Re ... Exp_system

    Look at the bottom and you will see the events it adds.

    As for the problem, I am not sure when is each of these events triggered as there's onPlayerChangeLevel and onPlayerLevelUP. My guess is that both of them need to be hooked.

    Try this one:

    exports.scoreboard:addScoreboardColumn('Level') 
      
    addEventHandler("onPlayerLogin", root, 
    function () 
        local account = getPlayerAccount(source) 
        local playerLevel = 0 
        if(not isGuestAccount(account))then 
            local level = exports.exp_system:getAccountLevel(account) 
            if(level)then 
                playerLevel = level 
            end 
        end 
        
        setElementData(source, "Level", playerLevel) 
    end) 
      
    addEventHandler("onPlayerChangeLevel", root, 
    function(old, new) 
        setElementData(source, "Level", new) 
    end) 
      
    addEventHandler("onPlayerLevelUP", root, 
    function(old, new) 
        setElementData(source, "Level", new) 
    end) 
    

  7. local hospitalPositions = { 
        --{name, x, y, z, r, cx, cy, cz} 
        {"Los Santos 1", 1183.3, -1323, 13.58, 0, 1183.3, -1323, 18}, 
        {"Los Santos 2", 2034.1, -1404.73, 17.25, 0, 2034.1, -1404.73, 22}, 
        {"Montgomery", 1371.83, 405.94, 19.76, 0, 1371.83, 405.94, 25}, 
        {"Blueberry", 207.5, -62.7, 1.6, 0,  207.5, -62.7, 7} 
    }; 
      
    addEventHandler("onPlayerWasted", root,  
    function() 
        local theSkin = getPedSkin(thePlayer) 
        local theTeam = getPlayerTeam(thePlayer) 
         
        local px, py, pz = getElementPosition(source) 
        local nearest = 1 
         
        for k, v in pairs(hospitalPositions) do 
            if(getDistanceBetweenPoints3D(v[2], v[3], v[4], px, py, pz) < getDistanceBetweenPoints3D(hospitalPositions[nearest][2], hospitalPositions[nearest][3], hospitalPositions[nearest][4], px, py, pz))then 
                nearest = k 
            end 
        end 
         
        setCameraMatrix(source, hospitalPositions[nearest][6], hospitalPositions[nearest][7], hospitalPositions[nearest][8], hospitalPositions[nearest][2], hospitalPositions[nearest][3], hospitalPositions[nearest][4]) 
         
        setTimer( 
            function() 
                spawnPlayer(source, hospitalPositions[nearest][2], hospitalPositions[nearest][3], hospitalPositions[nearest][4], hospitalPositions[nearest][5], theSkin, 0, 0, theTeam) 
                setCameraTarget(source) 
            end, 5000, 1) 
    end) 
    

  8. Try it out:

    exports.scoreboard:addScoreboardColumn('Level') 
      
    addEventHandler("onPlayerLogin", root, 
    function () 
        local account = getPlayerAccount(source) 
        local playerLevel = 0 
        if(not isGuestAccount(account))then  
            local level = exports.exp_system:getAccountLevel(account) 
            if(level)then 
                playerLevel = level 
            end 
        end 
         
        setElementData(source, "Level", playerLevel) 
    end) 
      
    addEventHandler("onPlayerChangeLevel", root,  
    function(old, new)  
        setElementData(source, "Level", new) 
    end) 
    

×
×
  • Create New...