Jump to content

[HELP] "Gate" problem...


rafull6

Recommended Posts

Hello guys. I'm newbe in scripting, so i need your help a bit... The problem consists in that i cant force my gate moving, when someone coming up to them. The idea in that this gate should move away when someone coming to them nearer (i don't know how this "number" named... it set in script to 3. Looks like

a51col = createColCircle ( 213.94564819336, 1875.40234375, 13.938992500305, 3 )

) doors must open up, and when someone going away it's closing. I tried to made script by myself, because i didn't this resource. I tried to make it script. Here is original script:

a51gate1 = createObject ( 2929, 215.99548339844, 1875.40234375, 13.938992500305, 0, 0, 0 )
  a51gate2 = createObject ( 2929, 211.94564819336, 1875.40234375, 13.938992500305, 0, 0, 0 )
  a51col = createColCircle ( 213.94564819336, 1875.40234375, 13.938992500305, 7 )
 
function opena51gates(thePlayer)
if getElementModel( thePlayer ) == 287 then
moveObject (a51gate1, 5000, 218.99548339844, 1875.40234375, 13.938992500305 )
moveObject (a51gate2, 5000, 208.94564819336, 1875.40234375, 13.938992500305 )
end
end
addEventHandler( "onColShapeHit", a51col, opena51gates )
 
function closea51gates(thePlayer)
if getElementModel( thePlayer ) == 287 then
moveObject (a51gate1, 5000, 215.99548339844, 1875.40234375, 13.938992500305 )
moveObject (a51gate2, 5000, 211.94564819336, 1875.40234375, 13.938992500305 )
end
end
addEventHandler( "onColShapeLeave", a51col, closea51gates )

i've deleted this lines:

a51gate2 = createObject ( 2929, 211.94564819336, 1875.40234375, 13.938992500305, 0, 0, 0 )

moveObject (a51gate2, 5000, 208.94564819336, 1875.40234375, 13.938992500305 )

moveObject (a51gate2, 5000, 211.94564819336, 1875.40234375, 13.938992500305 )

then i renamed a51gate2 to a1gate everywhere, and tested. It has worked!

BUT!!!!!!!!!

when i changed lines of cordinates to what i wanted - work stoped. :(

Here is my script:

a1gate = createObject ( 2929, 215.99548339844, 1875.40234375, 13.938992500305, 0, 0, 0 )
  a51col = createColCircle ( 213.94564819336, 1875.40234375, 13.938992500305, 3 )
 
function opena1gate(thePlayer)
 
moveObject (a1gate, 5000, 218.99548339844, 1875.40234375, 13.938992500305 )
end
addEventHandler( "onColShapeHit", a51col, opena1gate )
 
function closea1gate(thePlayer)
moveObject (a1gate, 5000, 215.99548339844, 1875.40234375, 13.938992500305 )
end
addEventHandler( "onColShapeLeave", a51col, closea1gate )

Where have i made a mistake? What is wrong? Correct me, please...

P.S. createColCircle cordinated i changed too.

Link to comment
function createob ()
ob = createObject ( 2933, -221.83, 2629.10, 63.55, 0.0000, 0.0000, 0.0000)
marker = createMarker ( 0, 0, 0, "cylinder", 5, 0, 0, 255, 0 )
end
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource ()), createob )
 
function obCheck ( thePlayer, matchingDimension )
if hasObjectPermissionTo (thePlayer, "command.kick", false ) then
moveObject ( ob, 3000, -221.83, 2629.10, 66.55)
outputChatBox ( "Command Recived , opening Admin Base!", thePlayer, 0, 255, 0)
end
 
end
 
addCommandHandler ( "open", obCheck ) 
addEventHandler ( "onMarkerHit", marker, obCheck )
 
function onPlrLeaveob ( thePlayer, matchingDimension )
if hasObjectPermissionTo (thePlayer, "command.kick", false ) then
setTimer ( movingBackob, 1000, 1, thePlayer )
outputChatBox ( "Command Recived! Closing Admin Base!", thePlayer, 0, 255, 0 )
end
end
addCommandHandler ( "close", onPlrLeaveob)
addEventHandler ( "onMarkerLeave", marker, onPlrLeaveob )
 
function movingBackob ()
moveObject ( ob, 3000, -221.83, 2629.10, 63.55 )
end

:roll::roll:

Link to comment

nice resource =), but i want to understand what im doing wrong!?! i've tested a lot mine script and understood that problem in Colshape. Mb i doing something wrong when im getting cordinates for colshape zone?

How i'm getting cordinates:

Im standing in front of my gates. Then copypasting cordinates to lua script. After reloading gates sdanding where they must be, but hwen im going to colshape zone nothing happen =( WHY!? :?:

Link to comment

Sorry... I'll remember it.

----------------------------------------------------------

Guys, i tried to do like varez told me to do. I've added line:

if (getElementType(element)=="player")

and now my script looks like that:

agate1 = createObject ( 988, -1972.7886962891, 293.92767333984, 35.171875, 0, 0, 90 )
  acol =  createColCuboid ( -1975.0732373047, 290.97298681641, 35.171875, 5, 7, 3)
 
function opena51gates(thePlayer)
 
if ( getElementType ( element ) == "player" ) then
moveObject (agate1, 3000, -1972.7886962891, 303.92767333984, 35.171875 )
end
end
 
addEventHandler( "onColShapeHit", acol, opena51gates )
 
function closea51gates(thePlayer)
 
if ( getElementType ( elemen t) == "player" ) then
moveObject (agate1, 3000, -1972.7886962891, 293.92767333984, 35.171875 )
end
end
 
addEventHandler( "onColShapeLeave", acol, closea51gates )

But it won't work! Why? What have i did wrong?

Link to comment
agate1 = createObject ( 988, -1972.7886962891, 293.92767333984, 35.171875, 0, 0, 90 )
  acol =  createColCuboid ( -1975.0732373047, 290.97298681641, 35.171875, 5, 7, 3)
 
function opena51gates(thePlayer)
 
if ( getElementType ( thePlayer ) == "player" ) then
moveObject (agate1, 3000, -1972.7886962891, 303.92767333984, 35.171875 )
end
end
 
addEventHandler( "onColShapeHit", acol, opena51gates )
 
function closea51gates(thePlayer)
 
if ( getElementType ( thePlayer ) == "player" ) then
moveObject (agate1, 3000, -1972.7886962891, 293.92767333984, 35.171875 )
end
end
 
addEventHandler( "onColShapeLeave", acol, closea51gates )

and first, look that :

if ( getElementType ( elemen t) == "player" ) then

:roll:

Link to comment
agate1 = createObject ( 988, -1972.7886962891, 293.92767333984, 35.171875, 0, 0, 90 )
acol = createColCuboid ( -1975.0732373047, 290.97298681641, 35.171875, 5, 7, 3)
 
function opena51gates(thePlayer)
 
if ( getElementType ( thePlayer ) == "player" ) then
moveObject (agate1, 3000, -1972.7886962891, 303.92767333984, 35.171875 )
end
end
 
addEventHandler( "onColShapeHit", acol, opena51gates )
 
function closea51gates(thePlayer)
 
if ( getElementType ( thePlayer ) == "player" ) then
moveObject (agate1, 3000, -1972.7886962891, 293.92767333984, 35.171875 )
end
end
 
addEventHandler( "onColShapeLeave", acol, closea51gates )

and first, look that :

if ( getElementType ( elemen t) == "player" ) then

:roll:

like i sayd...

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