Jump to content

[HELP]Gate Problem


ViRuZGamiing

Recommended Posts

Posted

Hello Community,

here's my script:

local gate = createObject(7709, -2122.5, 381.89999389648, 35.700000762939, 0, 0, 358) 
  
function open() 
moveObject(gate, -2122.5, 381.89999389648, 30, 0, 0, 358 ) 
end 
addCommandHandler("open", open) 
  
function close() 
moveObject(gate, -2122.5, 381.89999389648, 35.700000762939, 0, 0, 358 ) 
end 
addCommandHandler("close", close) 

My Problem:

When /open the Gate is Invisible but still there

When /close nothing happens.

Please help me,

Thanks

Posted

You forgot argument "time" at moveObject

time: The time in milliseconds the object will arrive at the destination.

local gate = createObject(7709, -2122.5, 381.89999389648, 35.700000762939, 0, 0, 358) 
  
function open() 
moveObject(gate, 2500, -2122.5, 381.89999389648, 30, 0, 0, 358 ) 
end 
addCommandHandler("open", open) 
  
function close() 
moveObject(gate, 2500, -2122.5, 381.89999389648, 35.700000762939, 0, 0, 358 ) 
end 
addCommandHandler("close", close) 

Posted

You had the rotation set to 358 while moving.

local gate = createObject(7709, -2122.5, 381.89999389648, 35.700000762939, 0, 0, 358) 
  
function open() 
moveObject(gate, 2500, -2122.5, 381.89999389648, 30, 0, 0, 0 ) 
end 
addCommandHandler("open", open) 
  
function close() 
moveObject(gate, 2500, -2122.5, 381.89999389648, 35.700000762939, 0, 0, 0 ) 
end 
addCommandHandler("close", close) 

BTW, you can move the gate with one command with this code:

local gate = createObject(7709, -2122.5, 381.89999389648, 35.700000762939, 0, 0, 358) 
megusta = false 
  
addCommandHandler("openclose",  
function () 
if (megusta == false) then 
moveObject(gate, 2500, -2122.5, 381.89999389648, 30, 0, 0, 0 ) 
megusta = true 
elseif (megusta == true) then 
moveObject(gate, 2500, -2122.5, 381.89999389648, 35.700000762939, 0, 0, 0 ) 
megusta = false 
end 
end) 
  

Posted

U can make it on a col shape, so when a person driving a vehicle hits the col shape, it gets his vehicle if it matches up (( the vehicle to the specified vehicle )) it will move the object.

Posted

Can you show me the Col thing?

My Coördinates

Open:  
"object (barrierturn) (1)" interior="0" alpha="255" doublesided="true" model="968" scale="1" dimension="0" posX="-2063.5" posY="1371.0999755859" posZ="7.0999999046326" rotX="0" rotY="0" rotZ="0"> 
Closed:  
"object (barrierturn) (1)" interior="0" alpha="255" doublesided="true" model="968" scale="1" dimension="0" posX="-2063.5" posY="1371.0999755859" posZ="7.0999999046326" rotX="0" rotY="270" rotZ="0"> 

Posted

Do I replace

colshape createColRectangle ( float fX, float fY, float fWidth, float fHeight) 

for the addCommandHandler?

Please I'm really a noob in scripting and I don't understand the WIKI language

Posted

It explains everything ... it takes only about minute or 2 to read the whole thing.

and create the col shape by side of the gate .. so it is on both sides ...

Posted

Here ya go, with explanations

bargate = createObject (968,-2063.5,1371.0999755859,7.0999999046326,0,270,0) 
-- creating the object 
damarker = createMarker (-2066.81201, 1370.72888, 6.90067, "cylinder", 9.5, 255, 0, 0, 100 ) 
-- the last thing 255,0,0,0 = the color & the alpha so: Red,Green,Blue,alpha, so the alpha is 0 so you can't see the marker 
  
moving = false 
  
function gatefunc(hitPlayer) 
 if getElementType ( hitPlayer ) == "player" and isPedInVehicle(hitPlayer) and (moving == false ) then 
-- you want to chek if the hitElement is a player and if it's in a vehicle, because you only want to do this for busses. 
--and because you are working with rotations, you need to chek if it's moving. or else it will rotate sometimes twice when two people are hitting it. 
  
veh = getPedOccupiedVehicle ( hitPlayer ) 
-- get the players vehicle 
  
if getElementModel ( veh ) == 431 then 
-- if the players vehicle is 431 so the bus then it will execute these lines underneath 
  
moving = true 
moveObject(bargate, 1500, -2063.5,1371.0999755859,7.0999999046326, 0,90,0 ) 
end 
end 
end 
addEventHandler ("onMarkerHit",damarker, gatefunc ) 
-- adding event when the player will hit the marker 
  
  
  
  
  
  
  
  
function gatefuncclose(leavePlayer) 
 if getElementType ( leavePlayer ) == "player" and isPedInVehicle(leavePlayer) and ( moving == true ) then 
-- you want to chek if the hitElement is a player and if it's in a vehicle, because you only want to do this for busses. 
--chekking if it's moving or else when it's already done it will rotateback 
  
veh = getPedOccupiedVehicle ( leavePlayer ) 
-- get the players vehicle 
  
if getElementModel ( veh ) == 431 then 
-- if the players vehicle is 431 so the bus then it will execute these lines underneath 
  
moving = false 
moveObject(bargate, 1500, -2063.5,1371.0999755859,7.0999999046326, 0,-90,0 ) 
end 
end 
end 
addEventHandler ("onMarkerLeave",damarker, gatefuncclose ) 
-- adding event when the player will leave the marker 

Posted

Now i use your script denny,

The Gate won't open when bus is near, I see the Red Marker (Not supposed to be vissable)

I the bus of the Bus Job Script I have. normally no problem.

Please Help

Posted

Try this

bargate = createObject (968,-2063.5,1371.0999755859,7.0999999046326,0,270,0) 
damarker = createMarker (-2066.81201, 1370.72888, 6.90067, "cylinder", 9.5, 255, 0, 0, 100 ) 
  
isMoving = false 
  
function gatefunc( hitPlayer ) 
    if ( getElementType ( hitPlayer ) == "player" and isPedInVehicle( hitPlayer ) ) then 
    local veh = getElementModel ( getPedOccupiedVehicle ( hitPlayer ) ) 
        if ( veh == 431 ) then 
        isMoving = true 
        moveObject( bargate, 1500, -2063.5, 1371.0999755859, 7.0999999046326, 0, 90, 0 ) 
        end 
    end 
end 
addEventHandler( "onMarkerHit", damarker, gatefunc ) 
  
function gatefuncclose( hitPlayer ) 
    if ( getElementType( hitPlayer ) == "player" and isPedInVehicle( hitPlayer ) ) then 
    local veh = getElementModel( getPedOccupiedVehicle( hitPlayer ) ) 
        if ( veh == 431 ) then 
        isMoving = false 
        moveObject( bargate, 1500, -2063.5, 1371.0999755859, 7.0999999046326, 0, -90, 0 ) 
        end 
    end 
end 
addEventHandler( "onMarkerLeave", damarker, gatefuncclose ) 

Posted
Try this
bargate = createObject (968,-2063.5,1371.0999755859,7.0999999046326,0,270,0) 
damarker = createMarker (-2066.81201, 1370.72888, 6.90067, "cylinder", 9.5, 255, 0, 0, 100 ) 
  
isMoving = false 
  
function gatefunc( hitPlayer ) 
    if ( getElementType ( hitPlayer ) == "player" and isPedInVehicle( hitPlayer ) ) then 
    local veh = getElementModel ( getPedOccupiedVehicle ( hitPlayer ) ) 
        if ( veh == 431 ) then 
        isMoving = true 
        moveObject( bargate, 1500, -2063.5, 1371.0999755859, 7.0999999046326, 0, 90, 0 ) 
        end 
    end 
end 
addEventHandler( "onMarkerHit", damarker, gatefunc ) 
  
function gatefuncclose( hitPlayer ) 
    if ( getElementType( hitPlayer ) == "player" and isPedInVehicle( hitPlayer ) ) then 
    local veh = getElementModel( getPedOccupiedVehicle( hitPlayer ) ) 
        if ( veh == 431 ) then 
        isMoving = false 
        moveObject( bargate, 1500, -2063.5, 1371.0999755859, 7.0999999046326, 0, -90, 0 ) 
        end 
    end 
end 
addEventHandler( "onMarkerLeave", damarker, gatefuncclose ) 

isMoving not used at all.

Posted

-- Server Side --

bargate = createObject (968,-2063.5,1371.0999755859,7.0999999046326,0,270,0) 
damarker = createMarker (-2066.81201, 1370.72888, 6.90067, "cylinder", 9.5, 255, 0, 0, 0 ) 
  
isMoving = false 
  
function gatefunc( hitPlayer ) 
    if ( getElementType ( hitPlayer ) == "player" and isPedInVehicle( hitPlayer ) ) then 
    local veh = getElementModel ( getPedOccupiedVehicle ( hitPlayer ) ) 
        if ( veh == 431 ) and not isMoving then 
        isMoving = true 
        moveObject( bargate, 1500, -2063.5, 1371.0999755859, 7.0999999046326, 0, 90, 0 ) 
        end 
    end 
end 
addEventHandler( "onMarkerHit", damarker, gatefunc ) 
  
function gatefuncclose( hitPlayer ) 
    if ( getElementType( hitPlayer ) == "player" and isPedInVehicle( hitPlayer ) ) then 
    local veh = getElementModel( getPedOccupiedVehicle( hitPlayer ) ) 
        if ( veh == 431 ) and isMoving then 
        isMoving = false 
        moveObject( bargate, 1500, -2063.5, 1371.0999755859, 7.0999999046326, 0, -90, 0 ) 
        end 
    end 
end 
addEventHandler( "onMarkerLeave", damarker, gatefuncclose ) 

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