Prison Gates Help
#1

Okay hello guys sorry for asking a lot of questions but i am kinda a starter scripter and i wanna learn how to do gates profesional way =].

Okay i got these gates done :


Код:
	CreateObject(986,1805.32214355,-1288.56970215,197.59532166,0.00000000,0.00000000,0.00000000); //Hc-Cell 1 Close
	CreateObject(986,1806.86389160,-1288.49340820,197.59532166,0.00000000,0.00000000,0.00000000); //(HC-Cell 1 Open
	CreateObject(986,1791.77014160,-1288.49255371,197.59532166,0.00000000,0.00000000,0.00000000); //MC-Cell 2 Close
	CreateObject(986,1796.79223633,-1288.58740234,198.06715393,0.00000000,0.00000000,0.00000000); //MC-Cell 2 Open
	CreateObject(988,1799.94262695,-1332.59863281,193.59532166,0.00000000,0.00000000,0.00000000); //LC-Cell 3 Close
	CreateObject(988,1799.97021484,-1332.63964844,197.27847290,0.00000000,0.00000000,0.00000000); //LC-Cell 3 Open
	CreateObject(988,1804.66760254,-1332.64489746,193.59532166,0.00000000,0.00000000,0.00000000); //LC-Cell 4 Close
	CreateObject(988,1804.67395020,-1332.43591309,197.69656372,0.00000000,0.00000000,0.00000000); //LC-Cell 4 Open
	CreateObject(988,1808.29248047,-1332.67504883,193.59532166,0.00000000,0.00000000,0.00000000); //LC-Cell 5 Close
	CreateObject(988,1808.24597168,-1332.46374512,197.37092590,0.00000000,0.00000000,0.00000000); //LC-Cell 5 Open
I have kinda a red thing object and i want it that when i be near that red thing all these gates will open.

Co-Ordinite of the are where the red thing is placed :


Код:
AddPlayerClass(186,1798.5381,-1336.3462,194.5953,183.6750,0,0,0,0,0,0); //
I want it that when your press ENTER all cells open

I want this for the mapped prison i made Thanks a lot for your help and time.. if you can't help don't waste your time move to the next thread =]

If some one can do it for me and post it i be very glad to see and learn for next time thanks...
Reply
#2

do you want them to open as a door (rotate it) or like commonly real prison cells (slide to the right/left) cause then u could use MoveObject
Reply
#3

maybe tell him how MoveObject works^^ (:P) or link him to the wiki

Link to wiki:https://sampwiki.blast.hk/wiki/MoveObject
and if you need more help just tell me or him :P
Reply
#4

yeah, would've been smarter oops
Reply
#5

The 2 first cells HC/MC slide to the right and the LC cells slide up and down
Reply
#6

Hello again.
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];
These are the gate objects:
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
This is the OnPlayerKeyStateChange, it detects when someone presses ENTER near the red thingy:
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;
}
Add this at bottom of your script:
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
Reply
#7

Thanks mate ill test it sorry took long to reply but i gave my pc a format ill test it as soon as i install Gta again
Reply
#8

Take your time and let me know then.
Reply
#9

it didn't work i think i did some thing wrong or some thing i had no errors the pwano just crash
Reply
#10

please some one help me if u wanna see the prison come to 88.203.79.136:7777
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)