dex. Posted November 3, 2017 Share Posted November 3, 2017 I have little problem with team. Code: function team ( source) local playerTeam = getPlayerTeam ( source ) local playeraccount = getPlayerAccount ( source ) if getAccountData (playeraccount,"Police", source) then outputChatBox ("text.", thePlayer, 255,0,0 ) cancelEvent(MoveGate) end end addEventHandler("onMarkerHit", marker, team) I want to make that like this, if Police hits marker, then gate dosent move and he says text. But other players can enter Link to comment
W4LK1NG Posted November 3, 2017 Share Posted November 3, 2017 function team (source) local playerTeam = getPlayerTeam ( source ) local playeraccount = getPlayerAccount ( source ) if getAccountData (playeraccount,"Police", source) then outputChatBox ("text.", source, 255,0,0 ) cancelEvent() end end addEventHandler("onMarkerHit", marker, team) Link to comment
kieran Posted November 3, 2017 Share Posted November 3, 2017 (edited) Untested function team(hitElement, matchingDimension) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then if isElement(hitElement) and getElementType(hitElement) == "player" and matchingDimension then local checkTeam = getTeamFromName("Police") if ( checkTeam ) then local playerTeam = getPlayerTeam(hitElement) if ( playerTeam == checkTeam ) then outputChatBox ("text.", source, 255,0,0 ) cancelEvent() end end end end end addEventHandler("onMarkerHit", marker, team) Might work, might not, use debugscript 3 and tell me what happens, just quickly took it out an old script I had. By the way, source gets the source element, so when a player hits a marker, the player is the source, so you don't need to define source in your function. Edited November 3, 2017 by kieran Link to comment
dex. Posted November 4, 2017 Author Share Posted November 4, 2017 Its says nofting at all. Still not working. Im put here my gate system, maybe that helps local gate = createObject(2938, 1534.9000244141, -1451.3000488281, 15, 0, 0, 90) local marker = createMarker(1534.9000244141, -1451.3000488281,13, "cylinder", 10, 255, 255, 255, 0) function moveGate(thePlayer, sourcePlayer) local playeraccount = getPlayerAccount ( source ) local theVehicle = isPedInVehicle ( thePlayer ) if theVehicle then moveObject(gate, 2000, 1534.9000244141, -1451.3000488281, 17, 0, -90, 0) setTimer(moveBack, 4000, 1) else outputChatBox ("You need to be in vehicle, to enter.", thePlayer, 255,0,0 ) end end addEventHandler("onMarkerHit", marker, moveGate) Link to comment
Storm-Hanma Posted November 4, 2017 Share Posted November 4, 2017 It coded has need to be in vehicle to enter ? Did u check this Link to comment
dex. Posted November 4, 2017 Author Share Posted November 4, 2017 I know, yes he has to be in vehicle, or he says you need to be in vehicle Link to comment
kieran Posted November 5, 2017 Share Posted November 5, 2017 (edited) Okay, instead of using that for your gate function, maybe try this... Oh and make use of using "not" in your if's, it can come in handy . local gate = createObject(2938, 1534.9000244141, -1451.3000488281, 15, 0, 0, 90)--The gate local marker = createMarker(1534.9000244141, -1451.3000488281,13, "cylinder", 10, 255, 255, 255, 100)--The marker IronJobBlip = createBlipAttachedTo ( marker, 56 ) is_gate_open = no --So we can check if gate is open. function moveGate(thePlayer, matchingDimension) if isElement(thePlayer) and getElementType(thePlayer) == "player" and matchingDimension then --If it's a player in the same dimension local checkTeam = getTeamFromName("Police") --We will get the police team if ( checkTeam ) then local playerTeam = getPlayerTeam(thePlayer) --We will then get the players team if ( playerTeam == checkTeam ) then --If the players team is Police outputChatBox ("You may not enter as police", thePlayer, 255,0,0 ) --Tell him return --And stop our script here end if not isPedInVehicle ( thePlayer ) then --if our player is not in a vehicle outputChatBox ("You need to be in vehicle, to enter.", thePlayer, 255,0,0 )--We will tell him if is_gate_open == no then --If our gate is not open moveObject(gate, 2000, 1534.9000244141, -1451.3000488281, 17, 0, -90, 0) --Move the gate is_gate_open = yes --Update our is_gate_open end end end end end addEventHandler("onMarkerHit", marker, moveGate) function GateClose ( thePlayer, matchingDimension ) if isElement(thePlayer) and getElementType(thePlayer) == "player" and matchingDimension then local detection = isElementWithinMarker ( thePlayer, marker ) --If a player is inside the marker detection = detection and getElementDimension( thePlayer ) == getElementDimension( gate ) --I honestly lost words and forgot how to explain this if is_gate_open == yes and not detection then --If gate is open and player isn't in the marker moveObject(gate, 2000, 1534.9000244141, -1451.3000488281, 15, 0, 90, 0) --Move it back is_gate_open = no --Our gate is no longer open end end end addEventHandler ( "onMarkerLeave", marker, GateClose ) Second function needs a little tweaking, maybe you'll want to consider using col shapes, here is an example of an old script I have using col shapes. Spoiler RHangG = createObject(16773, 397.4765625, 2476.6318359375, 19.5, 0, 0, 0)--424 LHangG = createObject(16775, 412.099609375, 2476.6298828125, 19.5, 0, 0, 180)--385.576171875[x] GateAdmin = createColCuboid( 390.8388671875, 2462.185546875, 15.501251220703, 30, 25, 12) function adminGatesOpen ( thePlayer, matchingDimension ) -- announce to everyone that the player entered the hill if (getElementType(thePlayer) == "player") then local acc = getPlayerAccount(thePlayer) -- Get it's account if (isObjectInACLGroup("user."..getAccountName(acc), aclGetGroup("Admin")) == false) then -- If the object is not in the admin acl group outputChatBox ("You do not have access to this, if you sneak in you will be killed.", player, 21, 53, 35) return elseif (isObjectInACLGroup("user."..getAccountName(acc), aclGetGroup("Admin")) == true) then local detection = isElementWithinColShape ( thePlayer, GateAdmin ) detection = detection and getElementDimension( thePlayer ) == getElementDimension( GateAdmin ) if detection then moveObject(RHangG, 1000, 385.576171875, 2476.6318359375, 19.5) moveObject(LHangG, 1000, 424, 2476.6298828125, 19.5) end end end -- This code checks if the player is in the admin acl group and if not, then kill the player. end addEventHandler ( "onColShapeHit", GateAdmin, adminGatesOpen ) function adminGatesClose ( thePlayer, matchingDimension ) -- announce to everyone that the player entered the hill if (getElementType(thePlayer) == "player") then local acc = getPlayerAccount(thePlayer) -- Get it's account if (isObjectInACLGroup("user."..getAccountName(acc), aclGetGroup("Admin")) == false) then -- If the object is not in the admin acl group return elseif (isObjectInACLGroup("user."..getAccountName(acc), aclGetGroup("Admin")) == true) then local detection = isElementWithinColShape ( thePlayer, GateAdmin ) detection = detection and getElementDimension( thePlayer ) == getElementDimension( GateAdmin ) if not detection then moveObject(LHangG, 1000, 412.099609375, 2476.6298828125, 19.5) moveObject(RHangG, 1000, 397.4765625, 2476.6318359375, 19.5) end end end -- This code checks if the player is in the admin acl group and if not, then kill the player. end addEventHandler ( "onColShapeLeave", GateAdmin, adminGatesClose ) Believe it or not, this is what I based your code on This should help you, got any other questions feel free to send me a message! But if I can't help, there are smarter people on forums... Also you might want to look at some of the stuff in above 2 code sections on the wiki, then you should just about be set with moving objects when a player hits them Edited November 5, 2017 by kieran 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