I lost all the day in trying to make a gate. Help me, please?!?
#1

Hello guys. I was trying to make a gate all the day. In all the ways, the script gave me errors, or the gate didn't open/close. So I finally decided that I would like an automatic gate. I mean , when a cop is in range of point, to auto open the gate. I'm talking about a barrier gate. I would be very happy, if you explain me how to make it, because I was watching&checking&testing tutorials all the day without any results. I'm using strcmp gamemode. Thank you all in advance.
Reply
#2

You need to check if IsPlayerInRangeOfPoint of the barrier object and if the player is a cop, then Move(Dynamic)Object in a Timer.

Timers can cause bugs though, say 2 cops enter the area, so you should add a variable that sets to one if the gate is already opening, and set it back to zero when it closes.
Reply
#3

pawn Код:
new Gate;
new bool:IsGateOpen;
public OnGameModeInit() //or OnFilterScriptInit
{
    Gate = CreateObject(...); //Here's your gate object
    SetTimer("GateOpen", 1000, true); //Start the player check
    return 1;
}

forward GateOpen();
public GateOpen()
{
    for(new i = 0; i < MAX_PLAYERS; i++) //Start a loop
    {
        if(IsPlayerConnected(i)) //If player is online
        {
            if(IsPlayerACop(playerid) == true) //CHANGE THIS LINE!!! **************
            {
            if(IsPlayerInRangeOfPoint(i, ....) //If they are near the point
            {
                if(IsGateOpen == false)
                {
                MoveObject(Gate, ....); //Open Position
                IsGateOpen = true;
                } }
                else
                {
                if(IsGateOpen == true) {
                MoveObject(Gate,....); //Back to closed position
                IsGateOpen = false; } }
                }
        }
    }
    return 1;
}
Reply
#4

Clarencecuzz, thank you a lot for helping me today. Can I make it in a filterscript to avoid any errors in the main gamemode? If yes, can you help me with making it as a filterscript cuz I tried and nothing happens. Also, shouldn't there are a speed of the gate? Thank you again.
Reply
#5

Quote:
Originally Posted by PhoeNiX778
Посмотреть сообщение
Clarencecuzz, thank you a lot for helping me today. Can I make it in a filterscript to avoid any errors in the main gamemode? If yes, can you help me with making it as a filterscript cuz I tried and nothing happens. Also, shouldn't there are a speed of the gate? Thank you again.
He was just giving you an example. NO - It should not be put in a filterscript, how are you supposed to tell if it's a cop close to the gate? The script must be modified by you.

P.S. That script is missing a declare for "Gate" (new Gate; needed at the top of the script)
Reply
#6

I accidentally missed the top line when copying it :S
Fixed.

Pheonix, I will offer whatever help I can, but I wouldn't recommend putting it into a filterscript.

MoveObject works like this. (Syntax)
Код:
MoveObject(objectid, Float:X, Float:Y, Float:Z, Float:Speed, Float:RotX, Float:RotY, Float:RotZ);
Reply
#7

Yeah, But, If you put this into a filterscript, it will basically mess up, It's better if you keep it like this, and just modify it, or make it better, if you want.
Reply
#8

I wouldn't mind if you send me your script, as long as you have given me the details on the gate. Closed/Open position, speed of the gate etc.

I might not be able to do it for a while, because it's about 5AM here, and I need to sleep.
Reply
#9

Sure, Well, firstly u need to make a command for the /open and /close ect, then postions


public OnFilterScriptInit()
{
Gate = CreateObject(modelid,Float:X,Float:Y,Float:Z,Float :rX,Float:rY,Float:rZ,FloatrawDistance = 0.0);
return 1;
}
public OnFilterScriptInit()
{
Gate[0] = CreateObject(modelid,Float:X,Float:Y,Float:Z,Float :rX,Float:rY,Float:rZ,FloatrawDistance = 0.0);
Gate[1] = CreateObject(modelid,Float:X,Float:Y,Float:Z,Float :rX,Float:rY,Float:rZ,FloatrawDistance = 0.0);
Gate[2] = CreateObject(modelid,Float:X,Float:Y,Float:Z,Float :rX,Float:rY,Float:rZ,FloatrawDistance = 0.0);
return 1;
}
//--------------------------

Here, you go, looser.
Reply
#10

1) Why have you called OnFilterScriptInit twice?
2) Why is there Gate[0] - 2 when we're only using 1 gate?
3) You haven't explained how the /open and /close commands would work.
4) You have only shown the easiest step of this function.
5) Don't call someone else a loser when you can't even script it yourself.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)