shoBy Posted August 30, 2014 Share Posted August 30, 2014 Hi guys! This is my first post and i hope that you can help me with this script. I'm new in LUA Scripting, so I want to use a script wich can create bases. The plugin looks: base.map / base_s.lua / gatescript.lua / gatescript2.lua / inf.zip / meta.xml . Base_s.lua: RestricLocation = {} TeleportLocation = {} EnabledAlarm = true TimesToKick = {} TimeSireneEnabled = true ColCuboid = false --------------------------------------- CONFIGS -------------------------------------------- RestricLocation["location1"] = {1110.8000488281,1250.9000244141,42.599998474121} --Local PARTE DE CIMA RestricLocation["location2"] = {1167.6999511719,1327.4000244141,6.0999999046326} --LOCAL PARTE DE BAIXO TeleportLocation = {1142.4000244141,1374.8000488281,10.60000038147} --LOCAL TO TELEPORT PLAYER GroupName = "AbuzadoZ" -- 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 ( =GOW=brokengunman26 ) 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) Gatescript.lua function createTheGate () myGate1 = createObject ( 980,1140.9000244141,1319.6999511719,12.60000038147, 0, 0, 0 ) end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate ) function openMyGate ( ) moveObject ( myGate1, 2500,1140.9000244141,1319.6999511719,6.4000000953674) end addCommandHandler("1234",openMyGate) function movingMyGateBack () moveObject ( myGate1, 2500,1140.9000244141,1319.6999511719,12.60000038147) end addCommandHandler("4321",movingMyGateBack) Gatescript2.lua: function createTheGate () myGate2 = createObject ( 10828,1139.4000244141,1285.5999755859,18.799999237061, 88.999847412109, 0, 359.5 ) end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate ) function openMyGate ( ) moveObject ( myGate2, 2500,1139.9000244141,1301.1999511719,18.799999237061) end addCommandHandler("111",openMyGate) function movingMyGateBack () moveObject ( myGate2, 2500,1139.4000244141,1285.5999755859,18.799999237061) end addCommandHandler("222",movingMyGateBack) Zipped folder: [url=http://www.girlshare.ro/33893635.6]http://www.girlshare.ro/33893635.6[/url] meta.xml: <meta> <info author="600er" version="1.0" name="BEbase" type="misc" /> <info type="map" version="1.0.0"></info> <map src="baseb001.map" dimension="0"></map> <script src="gatescript.lua" type="server" /> <script src="gatescript2.lua" type="server" /> <script src="baseb1_s.lua" type="server" /> </meta> So...I want to know: 1. Why the base gate doesn't open. 2. Wich is the password of the base. Link to comment
xeon17 Posted August 30, 2014 Share Posted August 30, 2014 Try it ( no tested ) myGate2 = createObject ( 10828,1139.4000244141,1285.5999755859,18.799999237061, 88.999847412109, 0, 359.5 ) function openMyGate ( ) moveObject ( myGate2, 2500,1139.9000244141,1301.1999511719,18.799999237061) end addCommandHandler("111",openMyGate) function movingMyGateBack () moveObject ( myGate2, 2500,1139.4000244141,1285.5999755859,18.799999237061) end addCommandHandler("222",movingMyGateBack) To open the gate use /111 , to close /222 Link to comment
shoBy Posted August 30, 2014 Author Share Posted August 30, 2014 This is gatescript2 or gatescript ? Sorry..I said that i'm new in LUA. Link to comment
xeon17 Posted August 30, 2014 Share Posted August 30, 2014 This is gatescript2 or gatescript ? Sorry..I said that i'm new in LUA. gatescript2 Link to comment
shoBy Posted August 30, 2014 Author Share Posted August 30, 2014 And i should cut all from gatescript2 and paste your script ? myGate2 = createObject ( 10828,1139.4000244141,1285.5999755859,18.799999237061, 88.999847412109, 0, 359.5 ) function openMyGate ( ) moveObject ( myGate2, 2500,1139.9000244141,1301.1999511719,18.799999237061) end addCommandHandler("111",openMyGate) function movingMyGateBack () moveObject ( myGate2, 2500,1139.4000244141,1285.5999755859,18.799999237061) end addCommandHandler("222",movingMyGateBack) This ? Link to comment
shoBy Posted August 30, 2014 Author Share Posted August 30, 2014 It works, but i have 2 gates on this base. How to open gate number 1 ? This script opens only the gate from up base...(sorry for my english) EDIT: Oh. I found ! Thanks a lot man <3 Link to comment
shoBy Posted August 30, 2014 Author Share Posted August 30, 2014 But if i'm not in that clan, I can open this gate if i know the password ?! Or is because i'm admin ? Link to comment
xeon17 Posted August 30, 2014 Share Posted August 30, 2014 The gate open for everyone who write /111 , no important are you in some clan or are you're admin. Link to comment
shoBy Posted August 30, 2014 Author Share Posted August 30, 2014 Ahh...What i have to do that only that clan can join ? Link to comment
xeon17 Posted August 30, 2014 Share Posted August 30, 2014 myGate2 = createObject ( 10828,1139.4000244141,1285.5999755859,18.799999237061, 88.999847412109, 0, 359.5 ) function openMyGate (player) playerTeam = getPlayerTeam ( player ) HisTeam = getTeamFromName ( "YOURCLANNAME" ) if ( playerTeam ) == HisTeam then moveObject ( myGate2, 2500,1139.9000244141,1301.1999511719,18.799999237061) end end addCommandHandler("111",openMyGate) function movingMyGateBack (player) playerTeam = getPlayerTeam ( player ) HisTeam = getTeamFromName ( "YOURCLANNAME" ) if ( playerTeam ) == HisTeam then moveObject ( myGate2, 2500,1139.4000244141,1285.5999755859,18.799999237061) end end addCommandHandler("222",movingMyGateBack) Replace ''YOURCLANNAME'' in the script with your clan name. Link to comment
shoBy Posted August 30, 2014 Author Share Posted August 30, 2014 It works ? Or I should try it ? Link to comment
xeon17 Posted August 30, 2014 Share Posted August 30, 2014 It works ? Or I should try it ? It should work , i don't tested it. Link to comment
shoBy Posted August 30, 2014 Author Share Posted August 30, 2014 It doesn't work...Sorry, but thanks for that for the last script. function createTheGate () myGate1 = createObject ( 980,1140.9000244141,1319.6999511719,12.60000038147, 0, 0, 0 ) end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), createTheGate ) function openMyGate ( ) moveObject ( myGate1, 2500,1140.9000244141,1319.6999511719,6.4000000953674) end addCommandHandler("1234",openMyGate) function movingMyGateBack () moveObject ( myGate1, 2500,1140.9000244141,1319.6999511719,12.60000038147) end addCommandHandler("4321",movingMyGateBack) Link to comment
xeon17 Posted August 30, 2014 Share Posted August 30, 2014 What dosen't work ? what are the errors in console/debugscript 3 ? Link to comment
shoBy Posted August 30, 2014 Author Share Posted August 30, 2014 I didn't try to see, but it's good that script. Thanks a lot man. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now