SA-MP Forums

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

 
 
Thread Tools Display Modes
Old 23/11/2009, 05:27 PM   #1
GaGlets(R)
Gangsta
 
GaGlets(R)'s Avatar
 
Join Date: Oct 2009
Posts: 791
Reputation: 5
Default Auto gates ;)

Hello all..

Im making my first map....


It will be autogates

My autogates wont work... I made that, if player is in any police car gate opens, if he is in right place gates open..

here is my script.... i know shame on me..

Code:
public autogates(playerid)
{
	new vehicleid = GetPlayerVehicleID(playerid);
	GetPlayerVehicleID(playerid);
	
  if(isacar(vehicleid) == 1)
	{
		if(IsPlayerInRangeOfPoint(playerid, 25, 1544.7, -1628.0, 14.0))
		{
		MoveObject(lsdpprieksa, 1544.7757568359, -1636.0593261719, 14.057502746582, 3); //vala
		}
		else if(IsPlayerInRangeOfPoint(playerid, 26, 1544.7, -1628.0, 14.0))
		{
		MoveObject(lsdpprieksa, 1544.7757568359, -1628.0593261719, 14.057502746582, 3); //ciet
		}
		else if(IsPlayerInRangeOfPoint(playerid, 25, 1588.181640625, -1637.8323974609, 15.19012260437))
		{
  		MoveObject(lsdpgaraza, 1598.181640625, -1637.8323974609, 15.19012260437, 3); //vala
  		}
  		else if(IsPlayerInRangeOfPoint(playerid, 26, 1588.181640625, -1637.8323974609, 15.19012260437))
	  	{
  	MoveObject(lsdpgaraza, 1588.181640625, -1637.8323974609, 15.19012260437, 3); //ciet
  	}
  }
  else if(isacar(vehicleid) == 0)
  {
  	SendClientMessage(playerid, COLOR_5,"Error: You need to be in any police car!");
  }
  return 0;
}

The gates wont move i have dona all this with cmds and works perfect...
GaGlets(R) is offline  
Old 23/11/2009, 05:31 PM   #2
patchkinson
Gangsta
 
Join Date: Nov 2009
Posts: 548
Reputation: 1
Default Re: Auto gates ;)

hehe u need to do like new object1; and then object1=CreateObject X Y Z then ifplayerrangetopoint Move object1 to X Y Z else X Y Z
patchkinson is offline  
Old 23/11/2009, 05:49 PM   #3
dice7
High-roller
 
Join Date: Apr 2009
Location: Slovenia
Posts: 2,200
Reputation: 22
Default Re: Auto gates ;)

Are you using any kind of timer ?
dice7 is offline  
Old 23/11/2009, 07:57 PM   #4
GaGlets(R)
Gangsta
 
GaGlets(R)'s Avatar
 
Join Date: Oct 2009
Posts: 791
Reputation: 5
Default Re: Auto gates ;)

hehe u need to do like new object1; and then object1=CreateObject X Y Z then ifplayerrangetopoint Move object1 to X Y Z else X Y Z

i have this all already...

I used timer for gates witch using cmd's

For these autogates i dont..
GaGlets(R) is offline  
Old 23/11/2009, 11:33 PM   #5
Joe Staff
High-roller
 
Join Date: Aug 2007
Posts: 2,593
Reputation: 379
Default Re: Auto gates ;)

Your method is wrong, I'm sure you've basically copied the WIKI, but that's wrong too.

First I would start by changing the parameters on your callback. Even though you will be needing playerid, you should do a loop for all players instead of apparently having timers for all players.

pawn Code:
forward GateChecks();
new gate1,gate2;
public OnGameModeInit()
{
  gate1=CreateObject(X1,Y1,Z1);
  gate2=CreateObject(X2,Y2,Z2);
  SetTimer("GateChecks",3000,1);
  return 1;
}
public GateChecks()
{
  new PlayerNearGate1, PlayerNearGate2;
  for(new playerid,playerid<MAX_PLAYERS;playerid++)
  {
    if(IsPlayerInRangeOfPoint(playerid,X1,Y1,Z1))PlayerNearGate1=1;
    if(IsPlayerInRangeOfPoint(playerid,X2,Y2,Z2))PlayerNearGate2=1;
  }
  if(PlayerNearGate1)MoveObject(gate1,openedX1,openedY1,openedZ1);
  else MoveObject(gate1,closedX1,closedY1,closedZ1);

  if(PlayerNearGate2)MoveObject(gate2,openedX2,openedY2,openedZ2);
  else MoveObject(gate2,closedX2,closedY2,closedZ2);
}

And I hope you're smart enough to change 'closedX1' to the coordinate you need. I'm tired of people giving me errors like 'No such definition: "closedX1"' ... morons...
Joe Staff is offline  
Old 24/11/2009, 11:45 AM   #6
GaGlets(R)
Gangsta
 
GaGlets(R)'s Avatar
 
Join Date: Oct 2009
Posts: 791
Reputation: 5
Default Re: Auto gates ;)

YES sure i can.. tnx, but why my metod dnt work.. (i dont copy wiki)

First i start making auto closegates with timer.. then i wanted to make that gates opens itself
And done that all...

OK NVM tnx....

GaGlets(R) is offline  
Old 25/11/2009, 03:02 PM   #7
GaGlets(R)
Gangsta
 
GaGlets(R)'s Avatar
 
Join Date: Oct 2009
Posts: 791
Reputation: 5
Default Re: Auto gates ;)

Ok guys... i have new problem : D

Made gates.. worked for some time.. after 1 day it crashed..

Problem: Gates wont to close !

Code:
public GateChecks()
{
  for(new playerid;playerid<MAX_PLAYERS;playerid++)
  {
    if(IsPlayerInRangeOfPoint(playerid,20, 1544.7, -1628.0, 14.0))PlayerNearlsdpprieksa=1;
    if(IsPlayerInRangeOfPoint(playerid,20, 1588.18, -1637.8, 15.19))PlayerNearlsdpgaraza=1;
    if(IsPlayerInRangeOfPoint(playerid,20, 2237.92, 2450.3, 9.7))PlayerNearlvdpprieksa=1;
    if(IsPlayerInRangeOfPoint(playerid,20, -1571.9, 661.0, 10.0))PlayerNearsfdpprieksa=1;
    if(IsPlayerInRangeOfPoint(playerid,20, -1640.0, 681.0, 10.0))PlayerNearsfdpprieksa2=1;
    if(IsPlayerInRangeOfPoint(playerid,20, 2293.7, 2498.3, 5.6))PlayerNearlvdpgaraza=1;
    if(IsPlayerInRangeOfPoint(playerid,20, -1633.0, 691.0, 6.0 ))PlayerNearsfpdgaraza=1;
  }
  if(PlayerNearlsdpprieksa)MoveObject(lsdpprieksa, 1544.7757568359, -1636.0593261719, 14.057502746582, 3); //vala;
  else MoveObject(lsdpprieksa, 1544.7757568359, -1628.0593261719, 14.057502746582, 3); //ciet

  if(PlayerNearlsdpgaraza)MoveObject(lsdpgaraza, 1598.181640625, -1637.8323974609, 15.19012260437, 3); //vala
  else MoveObject(lsdpgaraza, 1588.181640625, -1637.8323974609, 15.19012260437, 3); //ciet

  if(PlayerNearlvdpprieksa)MoveObject(lvdpprieksa, 2237.9245605469, 2440.337890625, 9.7784118652344, 3); //vala;
  else MoveObject(lvdpprieksa, 2237.9245605469, 2450.337890625, 9.7784118652344, 3); //ciet

  if(PlayerNearsfdpprieksa)MoveObject(sfdpprieksa, -1571.8327636719, 671.40673828125, 10.757417678833, 3); //vala;
  else MoveObject(sfdpprieksa,-1571.8327636719, 661.40673828125, 10.757417678833, 3); //ciet

  if(PlayerNearsfdpprieksa2)MoveObject(sfdpprieksa2, -1640.7103271484, 670.74017333984, 10.143852233887, 3); //vala;
  else MoveObject(sfdpprieksa2, -1640.7103271484, 681.74017333984, 10.143852233887, 3); //ciet

  if(PlayerNearlvdpgaraza)MoveObject(lvdpgaraza, 2293.5239257813, 2498.0485839844, 10.119644165039, 3); //vala;
  else MoveObject(lvdpgaraza, 2293.5239257813, 2498.0485839844, 5.119644165039, 3); //ciet

  if(PlayerNearsfpdgaraza)MoveObject(sfpdgaraza, -1633.3469238281, 691.77557373047, 11.1875, 3); //vala;
  else MoveObject(sfpdgaraza, -1633.3469238281, 691.77557373047, 6.1875, 3); //ciet
}
compiled:No errors :-/
what i have made wrong?

with other stuff - OKI,DOKI

Code:
public OnPlayerSpawn(playerid)
{
	if(isskin())  {
	SetTimer("GateChecks",3000,1);}
	return 1;
}
Code:
forward isskin();
public isskin()
{
  new playerid;
  new skin = GetPlayerSkin(playerid);
	switch(skin)
	{
	  case 274,275,276,280,281,282,283,284,288,285,286,287,163,164,165,166,277,278,279: return 1;
	}
	return 0;
}
GaGlets(R) is offline  
Old 25/11/2009, 04:01 PM   #8
GaGlets(R)
Gangsta
 
GaGlets(R)'s Avatar
 
Join Date: Oct 2009
Posts: 791
Reputation: 5
Default Re: Auto gates ;)

RESLOWED TNX FOR READING...

(needed to add new playerneaargate.. in same line ;(
GaGlets(R) is offline  
 

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
[Include] [INC] t-Auto Gates Toad Includes 131 13/04/2014 09:01 AM
LVPD Gates v2 Now with Auto Gates!! SlashPT Filterscripts 37 16/03/2010 03:59 PM
auto gates need cssbart Help Archive 8 18/02/2010 01:45 PM
Auto Gates Danikov Help Archive 26 20/10/2009 03:31 PM
[HELP] t-Auto Gates joeri55 Help Archive 2 02/06/2009 08:50 AM


All times are GMT. The time now is 03:07 AM.


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