Auto gates ;)
#1

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...
Reply
#2

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
Reply
#3

Are you using any kind of timer ?
Reply
#4

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..
Reply
#5

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...
Reply
#6

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....

Reply
#7

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;
}
Reply
#8

RESLOWED TNX FOR READING...

(needed to add new playerneaargate.. in same line ;(
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)