Jump to content

MTA DayZ Base system


dewu

Recommended Posts

The script looks like this one in the folder:

look.png

Map:

- 

baseb2_s:

RestricLocation = {} 
TeleportLocation = {} 
EnabledAlarm = true 
TimesToKick = {} 
TimeSireneEnabled = true 
ColCuboid = false 
  
--------------------------------------- CONFIGS -------------------------------------------- 
  
  
RestricLocation["location1"] = {869.90002441406,-1996.9000244141,37.299999237061}  --Local PARTE DE CIMA 
RestricLocation["location2"] = {811.29998779297,-2076.8999023438,-9.6999998092651}  --LOCAL PARTE DE BAIXO 
TeleportLocation = {836.59997558594,-1977.8000488281,12.39999961853} --LOCAL TO TELEPORT PLAYER 
GroupName = "Staff" -- name of the acl/gang group !!! 
GroupNameBy = 1 -- 1 for gang name, 2 for ACL group ! 
cmdTurnON = "turnONcmd" -- Command to enable alarm / 
cmdTurnOFF = "TurnOFFcmd" -- Command to disable alarm / 
MsgtoKICK = "Area protected! Leave or kick!" 
MsgCantCreateCollision = "Can't be created the Collision, check your location1 and location2" 
EnableVehicleGodMode = true -- true enabled, false disabled. 
KickORBAN = 1 -- 1 for kick player, 2 for BAN 
BanTime = 900000 -- time in seconds of ban, 900000 sec = 15 min 
MsgBAN = "Invasor" -- Reason of BAN ! 
  
  
--------------------------------------- CONFIGS -------------------------------------------- 
  
  
function sendMsg(iplayer,msg) 
    outputChatBox ( msg, iplayer, 255, 255, 255, true ) 
end 
  
function EnterPlace ( theElement ) 
    if (getElementType ( theElement ) == "player") and (PlayerHaveLevel (theElement) == false) and (EnabledAlarm == true ) then 
        if(TimesToKick[theElement] > 0) then 
            sendMsg(theElement,MsgtoKICK ..TimesToKick[theElement]) 
            TimesToKick[theElement] = TimesToKick[theElement] -1 
            setElementPosition( theElement, TeleportLocation[1], TeleportLocation[2], TeleportLocation[3]) 
            if TimeSireneEnabled == true then 
                triggerClientEvent ( "ActiveAlarm", getRootElement() ) 
            end 
            sendMsgOwners(theElement) 
        else 
            if (KickORBAN == 1) then 
                kickPlayer(theElement) 
            else 
                banPlayer ( theElement , false, false, true, "Alarme system Base", MsgBAN, BanTime ) 
            end 
  
        end 
    elseif getElementType ( theElement ) == "vehicle" then 
        SetVehicleGodMode(theElement,true) 
    end 
end 
  
function ExitPlace ( theElement ) 
    if getElementType ( theElement ) == "vehicle" then 
        SetVehicleGodMode(theElement,false) 
    end 
end 
  
function ASBenable1 ( source ) 
    if(PlayerHaveLevel (source) == true) then 
        EnabledAlarm = true 
    end 
end 
  
function ASBdisable1 ( source ) 
    if(PlayerHaveLevel (source) == true) then 
        EnabledAlarm = false 
    end 
end 
  
function ResetStats ( ) 
  
    local connectedPlayers = getElementsByType ( "player" ) 
  
    for i, aPlayer in ipairs(connectedPlayers) do 
        if TimesToKick[aPlayer] == nil then 
            TimesToKick[aPlayer] = 5 
        end 
        if(TimesToKick[aPlayer] < 5) then 
            TimesToKick[aPlayer] = TimesToKick[aPlayer] + 1 
        end 
    end 
end 
  
function playerConnect ( playerNick ) 
    local iPlayer = getPlayerFromName ( playerNick ) 
    TimesToKick[iPlayer] = 5 
end 
  
function PlayerHaveLevel( PlayerID ) 
    if GroupNameBy == 1 then 
        if ( getElementData ( PlayerID , "gang" ) == GroupName ) then 
            return true 
        else 
            return false 
        end 
    else 
        local accName = getAccountName ( getPlayerAccount ( PlayerID ) ) 
        if ( isObjectInACLGroup ("user."..accName, aclGetGroup ( GroupName ) ) ) then 
            return true 
        else 
            return false 
        end 
    end 
end 
  
function ResourceStart( ) 
    LoadLocations() 
    CreateCollision() 
    local connectedPlayers = getElementsByType ( "player" ) 
    for i, aPlayer in ipairs(connectedPlayers) do 
        TimesToKick[aPlayer] = 5 
    end 
end 
addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ),ResourceStart) 
  
function LoadLocations() 
    local RX, RY, RZ, WRX, WRX, WRX 
    if(RestricLocation["location1"][1] > RestricLocation["location2"][1]) then 
        RestricLocation["maxx"] = RestricLocation["location1"][1] 
        RestricLocation["minx"] = RestricLocation["location2"][1] 
    else 
        RestricLocation["maxx"] = RestricLocation["location2"][1] 
        RestricLocation["minx"] = RestricLocation["location1"][1] 
    end 
    if(RestricLocation["location1"][2] > RestricLocation["location2"][2]) then 
        RestricLocation["maxy"] = RestricLocation["location1"][2] 
        RestricLocation["miny"] = RestricLocation["location2"][2] 
    else 
        RestricLocation["maxy"] = RestricLocation["location2"][2] 
        RestricLocation["miny"] = RestricLocation["location1"][2] 
    end 
    if(RestricLocation["location1"][3] > RestricLocation["location2"][3]) then 
        RestricLocation["maxz"] = RestricLocation["location1"][3] 
        RestricLocation["minz"] = RestricLocation["location2"][3] 
    else 
        RestricLocation["maxz"] = RestricLocation["location2"][3] 
        RestricLocation["minz"] = RestricLocation["location1"][3] 
    end 
end 
  
function CreateCollision() 
    RX = RestricLocation["minx"] 
    WRX = RestricLocation["maxx"] - RestricLocation["minx"] 
    RY = RestricLocation["miny"] 
    WRY = RestricLocation["maxy"] - RestricLocation["miny"] 
    RZ = RestricLocation["minz"] 
    WRZ = RestricLocation["maxz"] - RestricLocation["minz"] 
    ColCuboid = createColCuboid ( RX, RY, RZ, WRX, WRY, WRZ ) 
    if ColCuboid then 
        addEventHandler ( "onColShapeHit", ColCuboid, EnterPlace ) 
        addEventHandler ( "onColShapeLeave", ColCuboid, ExitPlace ) 
    else 
        outputDebugString(MsgCantCreateCollision) 
    end 
end 
  
function ResourceStop( ) 
    destroyElement ( ColCuboid ) 
end 
addEventHandler( "onResourceStop", getResourceRootElement( getThisResource() ),ResourceStop) 
  
function SireneEnabled() 
    TimeSireneEnabled = true 
end 
  
function sendMsgOwners( PlayerID ) 
    local connectedPlayers = getElementsByType ( "player" ) 
    for i, aPlayer in ipairs(connectedPlayers) do 
        if(PlayerHaveLevel (aPlayer) == true) then 
            sendMsg(aPlayer," Player " ..getPlayerName ( PlayerID ) .." is trying to join in our base!") 
        end 
    end 
end 
  
function SetVehicleGodMode( VehicleID, godEoD ) 
    if EnableVehicleGodMode == true then 
        setElementData(VehicleID, "godmode", godEoD) 
        setVehicleDamageProof (VehicleID, godEoD ) 
    end 
end 
  
setTimer ( SireneEnabled , 20000, 0, "" ) 
setTimer ( ResetStats , 15000, 0, "" ) 
addCommandHandler("alarmon",ASBenable1) 
addCommandHandler("alarmoff",ASBdisable1) 
addEventHandler ("onPlayerConnect", getRootElement(), playerConnect) 
  
  
  

*To change locations, use map editor -> create a gate -> double click (x,y,z)

gatescript:

function createTheGate () 
  
         myGate1 = createObject ( 980,664.90002441406,-1309.0999755859,15.199999809265, 0, 0, 0 ) 
  
  
      end 
  
      addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate ) 
  
  
  
  
  
 function openMyGate ( ) 
 moveObject ( myGate1, 2500,664.90002441406,-1309.0999755859,15.199999809265) 
 end 
 addCommandHandler("s3",openMyGate) 
  
  
 function movingMyGateBack () 
 moveObject ( myGate1, 2500,652.90002441406,-1309.3000488281,15.199999809265) 
 end 
 addCommandHandler("s4",movingMyGateBack) 

*Command to open the gate is s4 and to lose s3.

If you want more gates, just use myGate2, like this one:

  
myGate2 = createObject ( 980,786.09997558594,-1152.5,25.200000762939, 0, 0, 90 ) 
  
  
 function openMyGate ( ) 
 moveObject ( myGate2, 2500, 786.09997558594,-1152.5,25.200000762939) 
 end 
 addCommandHandler("s1",openMyGate) 
  
  
 function movingMyGateBack () 
 moveObject ( myGate2, 2500, 786.20001220703, -1164, 25.200000762939) 
 end 
 addCommandHandler("s2",movingMyGateBack) 

*Command to open/close s2/s1.

The meta.xml, looks like this one:

<meta> 
    <info author="shoBy" version="1.0" name="Base" type="misc" /> 
    <info type="map" version="1.0.0"></info> 
    <map src="(yourmapname).map" dimension="0"></map> 
    <script src="gatescript.lua" type="server" /> 
    <script src="gatescript2.lua" type="server" /> 
    <script src="(yourbasename(lua)).lua" type="server" /> 
</meta> 

Good luck!

EDIT!!:

You said:

Thank you dude, but i need system where bases can buy by game $. 

To make a system like this, you can use the script of the gate, a map from map editor made by you or by other and a house system like this one: viewtopic.php?f=108&t=27571

Good luck, again!

Link to comment
  • 2 weeks later...

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...