I lost all the day in trying to make a gate. Help me, please?!? -
PhoeNiX778 - 10.07.2012
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.
Re: I lost all the day in trying to make a gate. Help me, please?!? -
coole210 - 10.07.2012
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.
Re: I lost all the day in trying to make a gate. Help me, please?!? -
clarencecuzz - 10.07.2012
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;
}
Re: I lost all the day in trying to make a gate. Help me, please?!? -
PhoeNiX778 - 10.07.2012
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.
Re: I lost all the day in trying to make a gate. Help me, please?!? -
coole210 - 10.07.2012
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)
Re: I lost all the day in trying to make a gate. Help me, please?!? -
clarencecuzz - 10.07.2012
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);
Re: I lost all the day in trying to make a gate. Help me, please?!? -
reh_007 - 10.07.2012
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.
Re: I lost all the day in trying to make a gate. Help me, please?!? -
clarencecuzz - 10.07.2012
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.
Re: I lost all the day in trying to make a gate. Help me, please?!? -
reh_007 - 10.07.2012
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,Float
rawDistance = 0.0);
return 1;
}
public OnFilterScriptInit()
{
Gate[0] = CreateObject(modelid,Float:X,Float:Y,Float:Z,Float :rX,Float:rY,Float:rZ,Float
rawDistance = 0.0);
Gate[1] = CreateObject(modelid,Float:X,Float:Y,Float:Z,Float :rX,Float:rY,Float:rZ,Float
rawDistance = 0.0);
Gate[2] = CreateObject(modelid,Float:X,Float:Y,Float:Z,Float :rX,Float:rY,Float:rZ,Float
rawDistance = 0.0);
return 1;
}
//--------------------------
Here, you go, looser.
Re: I lost all the day in trying to make a gate. Help me, please?!? -
clarencecuzz - 10.07.2012
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.