Jump to content

تحويل كود ضروري


DaHoM

Recommended Posts

السلام عليكم ورحمة الله وبركاتة 

كيف الحال ان شاء الله بخير

الزبدة

ابي احول ذا الكود الى انو يحسب من داتافلوس الاعبين بلله سريع

local playersWarping = { }
local playersInInterior = { }
local lastWarp = { }
local blipsState = { }
local interiors =
    {
        [ 1 ] = { 1, 244.4119, 305.0329, 999.1484 },
        [ 2 ] = { 2, 266.5009, 304.9670, 999.1484 },
        [ 3 ] = { 4, 302.1809, 300.7229, 999.1484 },
        [ 4 ] = { 3, 2496.0065, -1692.8518, 1014.7421 },
        [ 5 ] = { 5, 1260.9622, -785.4465, 1091.9062 },
        [ 6 ] = { 2, 2468.5056, -1698.2500, 1013.5078 },
        [ 7 ] = { 5, 2352.4500, -1180.9650, 1027.976 },
        [ 8 ] = { 8, 2807.6347, -1174.2792, 1025.5703 },
        [ 9 ] = { 5, 318.6222, 1114.7529, 1083.8828 },
        [ 10 ] = { 12, 2324.4501, -1149.2780, 1050.7100 },
        [ 11 ] = { 5, 140.2478, 1366.3989, 1083.8593 },
        [ 12 ] = { 4, -260.6278, 1456.6441, 1084.3671 },
        [ 13 ] = { 8, -42.5800, 1405.6099, 1084.4269 },
        [ 14 ] = { 6, -68.8081, 1351.4376, 1080.2109 },
        [ 15 ] = { 5, 2233.6950, -1114.8648, 1050.8828 },
        [ 16 ] = { 8, 2365.3103, -1135.4029, 1050.8750 },
        [ 17 ] = { 11, 2282.9099, -1140.2900, 1050.8980 },
        [ 18 ] = { 10, 2270.0161, -1210.4719, 1047.5625 },
        [ 19 ] = { 6, 2333.1760, -1077.0630, 1049.0230 },
        [ 20 ] = { 2, 491.1, 1398.8, 1080.2 },
        [ 21 ] = { 2, 447.0, 1397.2, 1084.3 },
        [ 22 ] = { 5, 22.875, 1403.51, 1084.4 },
        [ 23 ] = { 5, 226.62, 1114.29, 1080.9 },
        [ 24 ] = { 6, 234.16, 1064.05, 1084.21 },
        [ 25 ] = { 9, 83.05, 1322.47, 1083.86 },
        [ 26 ] = { 10, 23.98, 1340.27, 1084.37 },
        [ 27 ] = { 15, 376.85, 1417.34, 1081.32 },
        [ 28 ] = { 15, 295.1, 1472.2, 1080.2 },
        [ 29 ] = { 3, 2495.97852, -1692.08447, 1014.74219 }
    }
local housesLimit = tonumber ( get ( "maxHouses" ) ) or 999999999

addEventHandler ( "onResourceStart", resourceRoot,
    function ( )
        for _, house in ipairs ( getHousingList ( ) ) do
            createHouse ( house )
        end

        for _, interior in ipairs ( interiors ) do
            local int, x, y, z = unpack ( interior )
            local exitColshape = createColTube ( x, y, ( z - 0.5 ), 1.3, 2.5 )
            setElementInterior ( exitColshape, int )
            addEventHandler ( "onColShapeHit", exitColshape, onInteriorLeave )
        end
    end
)

addEvent ( "housing:isPlayerInsideHouse", true )
addEventHandler ( "housing:isPlayerInsideHouse", root,
    function ( )
        local dimension = getElementDimension ( source )
        local houseName = houseIDS [ dimension ]
        if ( houseName and housesCreated [ houseName ] ) then
            playersInInterior [ source ] = houseName
            housesCreated [ houseName ].playersInside [ source ] = true
            lastWarp [ source ] = getTickCount ( )
            local url = housesCreated [ houseName ].data.music
            if ( url and url ~= "" ) then
                triggerClientEvent ( source, "housing:setStreamMode", source, true, url )
            end
        end
    end
)

function destroyTheBlips ( )
    destroyHouseBlips ( source )
    blipsState [ source ] = nil
end
addEventHandler ( "onPlayerQuit", root, destroyTheBlips )
addEventHandler ( "onPlayerLogout", root, destroyTheBlips )

function onHouseColshapeHit ( hitElement )
    if ( getElementType ( hitElement ) == "player" and not isPedInVehicle ( hitElement ) ) then
        local houseName = getElementData ( source, "houseName" )
        if ( houseName ) then
            bindKey ( hitElement, "Z", "down", viewHouseInformation, housesCreated [ houseName ] [ "data" ], source )
exports["UIPtexts"]:output ( "* Housing: Press 'Z' to open house GUI.", hitElement, 255,255,0, true, 8 )
            outputChatBox ( "* Press 'Z' to open house GUI", hitElement, 255, 255, 0 )
        end
    end
end

function onHouseColshapeLeave ( leaveElement )
    if ( getElementType ( leaveElement ) == "player" ) then
        unbindKey ( leaveElement, "Z", "down", viewHouseInformation )
    elseif ( getElementType ( leaveElement ) == "vehicle" ) then
        local seats = getVehicleMaxPassengers ( leaveElement )
        for seat = 0, seats do
            local occupant = getVehicleOccupants ( leaveElement ) [ seat ]
            if ( occupant ) then
                unbindKey ( occupant, "Z", "down", viewHouseInformation )
            end
        end
    end
end

function viewHouseInformation ( thePlayer, _, _, houseData, colshape )
    if ( houseData and type ( houseData ) == "table" ) then
        if ( colshape and isElement ( colshape ) ) then
            if ( isElementWithinColShape ( thePlayer, colshape ) ) then
                local accountName = getPlayerAccountName ( thePlayer )
                triggerClientEvent ( thePlayer, "housing:showHouseInformation", thePlayer, houseData, accountName )
            else
                unbindKey ( thePlayer, "Z", "down", viewHouseInformation )
            end
        end
    end
end

function onInteriorLeave ( leaveElement )
    if ( getElementType ( leaveElement ) == "player" ) then
        if ( playersInInterior [ leaveElement ] ) and ( not playersWarping [ leaveElement ] ) and ( getTickCount ( ) - lastWarp [ leaveElement ] >= 3000 ) then
            setPlayerInInterior ( leaveElement, playersInInterior [ leaveElement ] )
        end
    end
end

addEvent ( "housing:enterInterior", true )
addEventHandler ( "housing:enterInterior", root,
    function ( houseName )
        local accountName = getPlayerAccountName ( source )
        local houseData = housesCreated [ houseName ] [ "data" ]
        local dimension = houseData.dimension
        local interior = houseData.interior
        local doorStatus = houseData.interiorState
        if ( doorStatus ~= "Open" ) then
            if ( accountName ~= housesCreated [ houseName ] [ "data" ].owner ) then
                return triggerClientEvent ( source, "housing:showInfo", source, "error", "The house is locked!" )
            end
        end

        setPlayerInInterior ( source, houseName )
    end
)

function setPlayerInInterior ( thePlayer, houseName )
    if ( houseName ) then
        local houseData = housesCreated [ houseName ] [ "data" ]
        local dimension = houseData.dimension
        local interior = houseData.interior
        toggleAllControls ( thePlayer, false )
        fadeCamera ( thePlayer, false, 1 )
        playersWarping [ thePlayer ] = true
        setTimer (
            function ( thePlayer, houseName, interior, dimension, streamURL )
                if ( isElement ( thePlayer ) ) then
                    if ( getElementInterior ( thePlayer ) == interiors [ interior ] [ 1 ] ) then
                        x, y, z = getElementPosition ( housesCreated [ houseName ] [ "pickup" ] )
                        int, dimension = 0, 0
                    else
                        int, x, y, z = unpack ( interiors [ interior ] )
                    end
                    setElementInterior ( thePlayer, int, x, y, z )
                    setElementDimension ( thePlayer, dimension )
                    fadeCamera ( thePlayer, true, 1 )
                    toggleAllControls ( thePlayer, true )
                    playersWarping [ thePlayer ] = nil
                    lastWarp [ thePlayer ] = getTickCount ( )
                    if ( int > 0 ) then
                        if ( streamURL and streamURL ~= "" ) then
                            triggerClientEvent ( thePlayer, "housing:setStreamMode", thePlayer, true, streamURL )
                        end
                        housesCreated [ houseName ].playersInside [ thePlayer ] = true
                        playersInInterior [ thePlayer ] = houseName
                    else
                        housesCreated [ houseName ].playersInside [ thePlayer ] = nil
                        playersInInterior [ thePlayer ] = nil
                        triggerClientEvent ( thePlayer, "housing:setStreamMode", thePlayer, false )
                    end
                    triggerEvent ( ( dimension == 0 and "onPlayerLeaveHouse" or "onPlayerEnterHouse" ), thePlayer, houseName )
                end
            end
            ,1000, 1, thePlayer, houseName, interior, dimension, houseData.music
        )
    end
end

addEvent ( "housing:buyHouse", true )
addEventHandler ( "housing:buyHouse", root,
    function ( houseName )
        if ( not isPlayerLoggedIn ( source ) ) then
            return triggerClientEvent ( source, "housing:showInfo", source, "error", "You must be logged in." )
        end

        local house = housesCreated [ houseName ]
        if ( house [ "data" ] [ "forSale" ] == "Yes" ) then 
            local price = tonumber ( house [ "data" ] [ "price" ] )
            local owner = house [ "data" ] [ "owner" ]
            local accountName = getPlayerAccountName ( source )
            if ( #getAccountHouses ( accountName ) >= housesLimit ) then
                return triggerClientEvent ( source, "housing:showInfo", source, "error", "You can't buy more than ".. housesLimit .." houses." )
            end

            if ( getPlayerMoney ( source ) >= price ) then
                if ( owner ~= "" ) then
                    local playerOwner = getAccountPlayer ( getAccount ( owner ) )
                    if ( not playerOwner ) then
                        return triggerClientEvent ( source, "housing:showInfo", source, "error", "You can't buy the house because the owner is not online." )
                    end

                    givePlayerMoney ( playerOwner, price )
                    outputChatBox ( "Housing: ".. getPlayerName ( source ):gsub ( "#%x%x%x%x%x%x", "" ) .." has bought your ".. houseName .." house for $".. convertNumber ( price ) ..".", playerOwner, 0, 255, 0 )
                    if ( blips [ playerOwner ] and isElement ( blips [ playerOwner ] [ houseName ] ) ) then
                        destroyElement ( blips [ playerOwner ] [ houseName ] )
                    end
                end

                if ( house [ "pickup" ] and isElement ( house [ "pickup" ] ) ) then
                    setPickupType ( house [ "pickup" ], 3, 1272 )
                end

                local cDate, cTime = getCurrentDateAndTime ( )
                setHouseData (
                    houseName,
                    {
                        "houseOwner",
                        "housePrice",
                        "houseForSale",
                        "buyDate",
                        "houseInteriorState"
                    },
                    {
                        accountName,
                        price,
                        "No",
                        ( cDate .." - ".. cTime ),
                        "Closed"
                    }
                )
                takePlayerMoney ( source, price )
                triggerClientEvent ( source, "housing:showHouseInformation", source, housesCreated [ houseName ] [ "data" ], accountName )
                triggerClientEvent ( source, "housing:showInfo", source, "info", "You bought the house for $".. convertNumber ( price ) .."." )
            else
                triggerClientEvent ( source, "housing:showInfo", source, "error", "You need an additional $".. convertNumber ( price - getPlayerMoney ( source ) ) .."." )
            end
        else
            triggerClientEvent ( source, "housing:showInfo", source, "error", "The house is not for sale." )
        end
    end
)

addEvent ( "housing:toggleSaleStatus", true )
addEventHandler ( "housing:toggleSaleStatus", root,
    function ( houseName )
        if ( not isPlayerLoggedIn ( source ) ) then
            return triggerClientEvent ( source, "housing:showInfo", source, "error", "You must be logged in." )
        end

        local house = housesCreated [ houseName ]
        local accountName = getPlayerAccountName ( source )
        if ( house [ "data" ] [ "owner" ] == accountName ) then
            local newState = ( house [ "data" ].forSale == "No" and "Yes" or "No" )
            local pickupModel = ( newState == "Yes" and 1273 or 1272 )
            setPickupType ( house [ "pickup" ], 3, pickupModel )
            setHouseData (
                houseName,
                {
                    "houseForSale",
                    "houseInteriorState"
                },
                {
                    newState,
                    ( newState == "Yes" and "Open" or "Closed" )
                }
            )
            triggerClientEvent ( source, "housing:showInfo", source, "info", ( newState == "Yes" and "The house is now for sale." or "The house is no longer for sale." ) )
            triggerClientEvent ( source, "housing:showHouseInformation", source, housesCreated [ houseName ] [ "data" ], accountName )
        else
            triggerClientEvent ( source, "housing:showInfo", source, "error", "You're not the owner of this house." )
        end
    end
)

local Command1 = get("CreateHouse")

addCommandHandler ( Command1,
    function ( thePlayer )
        local accountName = getPlayerAccountName ( thePlayer )
        if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( get ( "restrictedACL" ) ) ) ) then
            triggerClientEvent ( thePlayer, "housing:showHousingManager", thePlayer, getHousingList ( ), interiors )
        end
    end
)

addEvent ( "housing:createHouse", true )
addEventHandler ( "housing:createHouse", root,
    function ( houseName, housePrice, housePosition, interior )
        local added, errorMsg = addHouseToDatabase ( houseName, housePrice, split ( housePosition, " ," ), interior )
        if ( added ) then
            triggerClientEvent ( source, "housing:returnHouses", source, getHousingList ( ) )
            outputChatBox ( "Housing manager: You have successfully created the house.", source, 0, 255, 0 )
        else
            outputChatBox ( "Housing manager: ".. errorMsg or "Unknown" ..".", source, 255, 0, 0 )
        end
    end
)

addEvent ( "housing:removeHouse", true )
addEventHandler ( "housing:removeHouse", root,
    function ( houseName )
        local removed, errorMsg = removeHouseFromDatabase ( houseName )
        if ( removed ) then
            outputChatBox ( "Housing manager: The house has been successfully removed.", source, 0, 255, 0 )
            triggerClientEvent ( source, "housing:returnHouses", source, getHousingList ( ) )
        else
            outputChatBox ( "Housing manager: ".. errorMsg or "Unknown" ..".", source, 255, 0, 0 )
        end
    end
)

addEvent ( "housing:editHouse", true )
addEventHandler ( "housing:editHouse", root,
    function ( houseName, houseName_, houseOwner, housePrice, housePosition, interiorID )
        if ( houseName ) then
            local toSet =
                {
                
                    [ "houseName" ] = { houseName_, "name" },
                    [ "houseOwner" ] = { houseOwner, "owner" },
                    [ "housePrice" ] = { housePrice, "price" },
                    [ "housePosition" ] = { toJSON ( split ( housePosition, " ," ) ), "position" },
                    [ "houseInterior" ] = { interiorID, "interior" }
                }
            for dataName, dataValue in pairs ( toSet ) do
                if ( housesCreated [ houseName ] [ "data" ] [ dataValue [ 2 ] ] ~= dataValue [ 1 ] ) then
                    setHouseData ( houseName, dataName, dataValue [ 1 ] )
                end
            end
            triggerClientEvent ( source, "housing:returnHouses", source, getHousingList ( ) )
            outputChatBox ( "Housing manager: The house has been successfully updated.", source, 0, 255, 0 )
        end
    end
)

addEvent ( "housing:setDoorStatus", true )
addEventHandler ( "housing:setDoorStatus", root,
    function ( houseName )
        local accountName = getPlayerAccountName ( source )
        local houseData = housesCreated [ houseName ] [ "data" ]
        local doorStatus = houseData.interiorState
        local newDoorStatus = ( doorStatus == "Open" and "Closed" or "Open" )
        setHouseData ( houseName, "houseInteriorState", newDoorStatus )
        triggerClientEvent ( source, "housing:showInfo", source, "info", "The house is now ".. ( newDoorStatus == "Closed" and "locked" or "open" ) .."." )
        triggerClientEvent ( source, "housing:showHouseInformation", source, housesCreated [ houseName ] [ "data" ], accountName )
    end
)

addEvent ( "housing:setSalePrice", true )
addEventHandler ( "housing:setSalePrice", root,
    function ( houseName, housePrice )
        if ( not isPlayerLoggedIn ( source ) ) then
            return triggerClientEvent ( source, "housing:showInfo", source, "error", "You must be logged in." )
        end

        local house = housesCreated [ houseName ]
        local accountName = getPlayerAccountName ( source )
        if ( house [ "data" ] [ "owner" ] == accountName ) then
            if ( house [ "data" ] [ "forSale" ] == "No" ) then
                setHouseData ( houseName, "housePrice", housePrice )
                triggerClientEvent ( source, "housing:showInfo", source, "info", "Price set to $".. convertNumber ( housePrice ) )
                triggerClientEvent ( source, "housing:showHouseInformation", source, housesCreated [ houseName ] [ "data" ], accountName )
            else
                triggerClientEvent ( source, "housing:showInfo", source, "error", "You can't set the price during sale." )
            end
        else
            triggerClientEvent ( source, "housing:showInfo", source, "error", "You're not the owner of this house." )
        end
    end
)

addCommandHandler ( "houses",
    function ( thePlayer )
        blipsState [ thePlayer ] = ( not blipsState [ thePlayer ] )
        if ( blipsState [ thePlayer ] ) then
            createHouseBlips ( thePlayer )
        else
            destroyHouseBlips ( thePlayer )
        end
    end
)

addCommandHandler ( "housemusic",
    function ( thePlayer, _, ... )
        local url = table.concat ( { ... }, " " )
        if ( url ~= "" ) then
            local houseName = playersInInterior [ thePlayer ]
            if ( houseName ) then
                local house = housesCreated [ houseName ]
                if ( house ) then
                    if ( house.data.owner == getPlayerAccountName ( thePlayer ) ) then
                        setHouseData ( houseName, "streamURL", url )
                        outputChatBox ( "House music set!", thePlayer, 0, 255, 0 )
                    end
                end
            end
        end
    end
)

addEventHandler ( "onPlayerWasted", root,
    function ( )
        if ( getElementInterior ( source ) > 0 ) then
            local houseName = playersInInterior [ source ]
            if ( houseName ) then
                local house = housesCreated [ houseName ]
                if ( house ) then
                    housesCreated [ houseName ].playersInside [ source ] = nil
                end
            end
            playersInInterior [ source ] = nil
        end
    end
)

ذا كود السيرفر

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...