Gates Bugged? HELP Please :D
#1

So, i have 2 gates for my Clan base in my server but they only work for 1 player (the last TT member or the first that joins the server)


Код:
public gatefront()
{
	for(new i=0;i<MAX_PLAYERS; i++)
	{
	  new PlayerName[24];
  		GetPlayerName(i, PlayerName, sizeof(PlayerName));
  		if(strfind(PlayerName[i], "[TT]", false) != -1)
		{
			if (PlayerToPoint(10.0, i,1970.0643,1764.3062,12.7157 ) && FrontGate_status == 0)
			{
				MoveObject(gatefront1, 1969.4080810547, 1761.0424804688, 17.521432876587,3);
				MoveObject(gatefront2, 1969.4031982422, 1767.6744384766, 17.521432876587,3);
				FrontGate_status = 1;
			}
			else if (!PlayerToPoint(10.0, i,1970.0643,1764.3062,12.7157 ) && FrontGate_status == 1)
			{
				MoveObject(gatefront1, 1969.4080810547, 1761.0424804688, 14.521432876587,3);
				MoveObject(gatefront2, 1969.4031982422, 1767.6744384766, 14.521432876587,3);
  				FrontGate_status = 0;
			}
		}
	}
}
public gateback()
{
	for(new i=0;i<MAX_PLAYERS; i++)
	{
		new PlayerName[24];
		GetPlayerName(i, PlayerName, sizeof(PlayerName));
	  if(strfind(PlayerName[i], "[TT]", false) != -1)
		{
			if (PlayerToPoint(10.0, i,1918.0104,1969.7140,7.5938) && BackGate_status == 0)
			{
				MoveObject(gateback1,1917.3553466797, 1973.0606689453, 12.3714904785156,3);
				MoveObject(gateback2,1917.3598632813, 1966.2652587891, 12.3723287582397,3);
				BackGate_status = 1;
			}
			else if (!PlayerToPoint(10.0, i,1918.0104,1969.7140,7.5938) && BackGate_status == 1)
			{
				MoveObject(gateback1,1917.3553466797, 1973.0606689453, 9.3714904785156,3);
				MoveObject(gateback2,1917.3598632813, 1966.2652587891, 9.3723287582397,3);
  				BackGate_status = 0;
			}
		}
	}
}
Can anyone please help me? i want them to open for ALL TT members if they are in a range of 10 [meters] and i have no idea how to fix it...

if you need more info, just say
Ofcourse i defined everything as it shud be, i have no warnings/errors in my filterscript [yes its a filterscript]
Reply
#2

Why do you need to get player name? I think that's causing the problem. I am not sure though, I use a command to open/close gates.
Reply
#3

i want the gate to open for TT members so i have to search for TT? and i dont have gates on command bcos i really hate it :O
Reply
#4

BUMP... help please
Reply
#5

pawn Код:
forward gatefront(playerid);
forward gateback(playerid);
pawn Код:
public OnPlayerConnect(playerid)
{
SetTimer("gatefront", 1000, true);
SetTimer("gateback", 1000, true);
}
pawn Код:
public gatefront(playerid)
{
    new FrontOpenGate;
    for(new i=0; i<MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i)) {
            new name[MAX_PLAYER_NAME];
            GetPlayerName(i, name, sizeof(name));
            if(strfind(name, "[TT]", true) != -1) {
                if(IsPlayerInRangeOfPoint(i, 10, i, 1970.0643,1764.3062,12.7157)) FrontOpenGate = 1;
                if(!IsPlayerInRangeOfPoint(i, 10, i, 1970.0643,1764.3062,12.7157)) FrontOpenGate = 0;
            }
        }
    }
  if(FrontOpenGate == 1) {
  MoveObject(gatefront1, 1969.4080810547, 1761.0424804688, 17.521432876587, 3);
  MoveObject(gatefront2, 1969.4031982422, 1767.6744384766, 17.521432876587,3); }
  if(FrontOpenGate == 0) {
  MoveObject(gatefront1, 1969.4080810547, 1761.0424804688, 14.521432876587,3);
  MoveObject(gatefront2, 1969.4031982422, 1767.6744384766, 14.521432876587,3); }
}
pawn Код:
public gateback(playerid)
{
    new BackOpenGate;
    for(new i=0; i<MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i)) {
            new name[MAX_PLAYER_NAME];
            GetPlayerName(i, name, sizeof(name));
            if(strfind(name, "[TT]", true) != -1) {
                if(IsPlayerInRangeOfPoint(i, 10, i, 1918.0104,1969.7140,7.5938)) BackOpenGate = 1;
                if(!IsPlayerInRangeOfPoint(i, 10, i, 1918.0104,1969.7140,7.5938)) BackOpenGate = 0;
            }
        }
    }
  if(BackOpenGate == 1) {
  MoveObject(gateback1,1917.3553466797, 1973.0606689453, 12.3714904785156,3);
  MoveObject(gateback2,1917.3598632813, 1966.2652587891, 12.3723287582397,3); }
  if(BackOpenGate == 0) {
  MoveObject(gateback1,1917.3553466797, 1973.0606689453, 9.3714904785156,3);
  MoveObject(gateback2,1917.3598632813, 1966.2652587891, 9.3723287582397,3); }
}
Just fix the indentations..
Reply
#6

1 question, why you use the timers onplayerconnect, i used them at onfilterscriptinit/ongamemodeinit and why did you use i twice at IsPlayerInRangeOfPoint, isnt that btw a 0.3a function? my server is in 0.2x
Reply
#7

Quote:
Originally Posted by doggeh
1 question, why you use the timers onplayerconnect, i used them at onfilterscriptinit/ongamemodeinit and why did you use i twice at IsPlayerInRangeOfPoint, isnt that btw a 0.3a function? my server is in 0.2x
Timers work the same if they're in OnPlayerConnect or OnGameModeInit, and yes this is for 0.3.
Reply
#8

Well can you somehow make it for 0.2x please bcos my server is not in 0.3a...

another thing, why you forward it like this: forward gatefront(playerid);
why that playerid?
Reply
#9

The code in the first post should be fine. Just change this
pawn Код:
if(strfind(PlayerName, "[TT]", false) != -1)
Reply
#10

Quote:
Originally Posted by doggeh
Well can you somehow make it for 0.2x please bcos my server is not in 0.3a...

another thing, why you forward it like this: forward gatefront(playerid);
why that playerid?
Habit I've gotten into.. I forward all functions with a playerid.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)