09.08.2010, 18:56
Hello again.
I have made a code for you, it is untested, but you can test it. ^^
Add this at TOP of your script:
These are the gate objects:
This is the OnPlayerKeyStateChange, it detects when someone presses ENTER near the red thingy:
Add this at bottom of your script:
Tell me if you get any errors or if there are any bugs.
I hope it works, and you enjoy it.
Greetings,
Jeffry
I have made a code for you, it is untested, but you can test it. ^^
Add this at TOP of your script:
pawn Код:
new GateStatus;
new Gate[5];
pawn Код:
Gate[0]=CreateObject(986,1805.32214355,-1288.56970215,197.59532166,0.00000000,0.00000000,0.00000000); //Hc-Cell 1 Close
Gate[1]=CreateObject(986,1791.77014160,-1288.49255371,197.59532166,0.00000000,0.00000000,0.00000000); //MC-Cell 2 Close
Gate[2]=CreateObject(988,1799.94262695,-1332.59863281,193.59532166,0.00000000,0.00000000,0.00000000); //LC-Cell 3 Close
Gate[3]=CreateObject(988,1804.66760254,-1332.64489746,193.59532166,0.00000000,0.00000000,0.00000000); //LC-Cell 4 Close
Gate[4]=CreateObject(988,1808.29248047,-1332.67504883,193.59532166,0.00000000,0.00000000,0.00000000); //LC-Cell 5 Close
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_SECONDARY_ATTACK)
{
if(IsPlayerInRangeOfPoint(playerid, 1798.5381,-1336.3462,194.5953, 5.0)) //Change the 5.0 if you want a smaller range
{
if(GateStatus==0) // The gates are closed, and will open now
{
OpenGates();
return SendClientMessage(playerid, 0xFF00FFFF, "[Gate] The gates are opening now!");
}
else // The gates are in the opend status
{
return SendClientMessage(playerid, 0xFF00FFFF, "[Gate] The gates are already open!");
}
}
}
return 1;
}
pawn Код:
forward OpenGates();
public OpenGates()
{
GateStatus=1;
MoveObject(Gate[0], 1806.86389160,-1288.49340820,197.59532166, 1.0); //Change the 1.0 If you want them to be faster/slower
MoveObject(Gate[1], 1796.79223633,-1288.58740234,198.06715393, 1.0); //Change the 1.0 If you want them to be faster/slower
MoveObject(Gate[2], 1799.97021484,-1332.63964844,197.27847290, 1.0); //Change the 1.0 If you want them to be faster/slower
MoveObject(Gate[3], 1804.67395020,-1332.43591309,197.69656372, 1.0); //Change the 1.0 If you want them to be faster/slower
MoveObject(Gate[4], 1808.24597168,-1332.46374512,197.37092590, 1.0); //Change the 1.0 If you want them to be faster/slower
SetTimer("CloseGates", 30000, 0); //Change the 30000 (30 sec) if you want them to stay open longer/shorter
return 1;
}
forward CloseGates();
public CloseGates()
{
GateStatus=0;
MoveObject(Gate[0], 1805.32214355,-1288.56970215,197.59532166, 1.0); //Change the 1.0 If you want them to be faster/slower
MoveObject(Gate[1], 1791.77014160,-1288.49255371,197.59532166, 1.0); //Change the 1.0 If you want them to be faster/slower
MoveObject(Gate[2], 1799.94262695,-1332.59863281,193.59532166, 1.0); //Change the 1.0 If you want them to be faster/slower
MoveObject(Gate[3], 1804.66760254,-1332.64489746,193.59532166, 1.0); //Change the 1.0 If you want them to be faster/slower
MoveObject(Gate[4], 1808.29248047,-1332.67504883,193.59532166, 1.0); //Change the 1.0 If you want them to be faster/slower
return 1;
}
Tell me if you get any errors or if there are any bugs.
I hope it works, and you enjoy it.
Greetings,
Jeffry
