SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 11/09/2010, 10:07 AM   #1
AndriusZ*
Big Clucker
 
AndriusZ*'s Avatar
 
Join Date: Jul 2010
Posts: 108
Reputation: 0
Default [TUT]Automatic gates.

==== Information. =====
Quote:
Hello, with this tut u can learn create „Automatic Gates“.
Ok, lets start. For example will be LSPD gates.
P.S: This automatic gates script 50% not my, but tut created by me.
P.S.S: Good luck, if u need help with this - post there!
==== Variables. =====
Ok, create that variables on top of ur script.
Quote:
#define PlayerLoop(%1) for(new %1=0;%1<MAX_PLAYERS,IsPlayerConnected(%1);%1++) // C. 'for'
new LSPDG; // Gates variable.
new PoliceA[ MAX_PLAYERS ]; // Automatic gates variable
==== Create the object. =====
Put this object somewhere at OnGameModeInit
Quote:
LSPDG= CreateObject(980, 1539.563110, -1627.313354, 15.156204, 0.0000, 0.0000, 90.0000); // Police gates object.
==== PlayerToPoint function. =====
Put it anywhere.
stock PlayerToPoint(Float:radi, playerid, Float, Float:y, Float:z)
{
if(IsPlayerConnected(playerid))
{
new Floatldposx, Floatldposy, Floatldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
}
return 0;
}
==== Ok, - moving object, etc. =====
Ok, last - put this somewhere OnPlayerUpdate
Quote:
PlayerLoop(i) // C. PlayerLoop ( 'for' )
{ // open
if(IsPlayerAdmin(i)) // checks, if player admin
{ // open
if(PlayerToPoint(10.0, i,1539.567993, -1628.364502, 9.606209) && PoliceA[i] == 0) // Checks, if player near closed gates.
{
MoveObject(LSPDG, 1539.567993, -1628.364502, 9.606209, 3.5); // Moving object.
PoliceA[i] = 1; // variable sets to 1...
return 1;
} // End of open gate
else if(!PlayerToPoint(10.0, i, 1539.563110, -1627.313354, 15.156204) && PoliceA[i] == 1) // Checks, if player not near gates.
{ // open
MoveObject(LSPDG, 1539.563110, -1627.313354, 15.156204, 2); // Moving object
PoliceA[i] = 0; // variable sets to 0
return 1; // end
} // close
} // playerloop close
__________________
My motto fuck lotto

Last edited by AndriusZ*; 11/09/2010 at 05:55 PM.
AndriusZ* is offline   Reply With Quote
Old 11/09/2010, 10:08 AM   #2
thomas..
Huge Clucker
 
Join Date: Sep 2010
Posts: 200
Reputation: 0
Default Re: [TUT]Automatic gates.

nice!

but why not isplayerinrangeofpoint?
thomas.. is offline   Reply With Quote
Old 11/09/2010, 10:10 AM   #3
AndriusZ*
Big Clucker
 
AndriusZ*'s Avatar
 
Join Date: Jul 2010
Posts: 108
Reputation: 0
Default Re: [TUT]Automatic gates.

well, if i need to check is player near some . . . im using playertopoint.. + some lines of script created by another ppl. :P
__________________
My motto fuck lotto
AndriusZ* is offline   Reply With Quote
Old 11/09/2010, 05:02 PM   #4
Jantjuh
High-roller
 
Jantjuh's Avatar
 
Join Date: Jul 2010
Location: In the blouse van je zoes
Posts: 1,410
Reputation: 531
Default Re: [TUT]Automatic gates.

coowl, i'll use it for my admin house

** This forum requires that you wait 120 seconds between posts. Please try again in 36 seconds. >: (
__________________

When Minecraft gets boring..
http://www.youtube.com/watch?v=U5qByy-775Q


Jantjuh is offline   Reply With Quote
Old 11/09/2010, 09:30 PM   #5
wups
High-roller
 
wups's Avatar
 
Join Date: Apr 2010
Location: Lithuania
Posts: 1,369
Reputation: 132
Default Re: [TUT]Automatic gates.

tag the code with [ pawn] [ /pawn]
wups is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
automatic gates tomo523869 Help Archive 5 22/03/2010 12:40 AM
Automatic Gates Ritchie999 Server Support 0 31/10/2009 02:34 AM
need help with automatic gates! BMGP Help Archive 2 24/08/2009 11:30 AM
automatic gates help Sfinx_17 Help Archive 2 22/08/2009 09:09 PM
about automatic gates Sfinx_17 Help Archive 5 20/08/2009 03:05 PM


All times are GMT. The time now is 05:45 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.