Gate opening for specific team?
#1

Код:
#define TEAM_LVPD 1
new gTeam[MAX_PLAYERS];

public OnGameModeInit()
{
  gatelvpd1 = CreateObject(969, 2238.020264, 2450.397705, 9.976515, 0.0000, 0.0000, 89.3814);
  SetTimer("Neargatelvpd1", 500, true);
}
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(strcmp("/teamlvpd0152", cmdtext, true, 13) == 0)
	{
	  gTeam[playerid] = TEAM_LVPD;
	  SendClientMessage(playerid, 0x00FF00FF, "You are now LVPD");
	  return 1;
    }
}
forward Neargatelvpd1(playerid);

forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
public Neargatelvpd1(playerid)
{
	for(new i=0; i<MAX_PLAYERS; i++)
	{
	  if(IsPlayerConnected(i))
	  {
			if(PlayerToPoint(10.0, i, 2238.3220,2453.8621,10.8203) && GetPlayerTeam(playerid) == TEAM_LVPD)
			{
	     	    MoveObject(gatelvpd1, 2238.114014, 2457.015137, 9.959967, 3.5);
			}
			else
			{
			 	MoveObject(gatelvpd1, 2238.020264, 2450.397705, 9.976515, 3.5);
			}
	   }
	}
}

public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
	new Float:oldposx, Float:oldposy, Float:oldposz;
	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;
}
Prob?!:

The gate won't open when I typed /teamlvpd0152 and when I'm near the gate ofc...

Greetz Rizzy
Reply
#2

Use this:
Код:
if(gTeam[playerid] != TEAM_LVPD)
gTeam[playerid] - player`s team
!= - if not ....
TEAM_LVPD - your definition of the team
Reply
#3

Quote:
Originally Posted by [balkan-samp.com
Luka ]
Use this:
Код:
if(gTeam[playerid] != TEAM_LVPD)
gTeam[playerid] - player`s team
!= - if not ....
TEAM_LVPD - your definition of the team
gotto correct you. != means not equal. and yes that probably is the error. but why use else?
and you gotto make a loop. either use SetTimerEx and input the playerid using a loop at the ongamemodeinit or remove param and loop there.you're no good with that code.. sadly
Reply
#4

pawn Код:
if(gTeam[playerid] == TEAM_LVPD)
Reply
#5

Thnx Klutty for this simple amazing answer

It worked perfectly

Greetzz Rizzy
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)