SA-MP Forums Archive
auto gate - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: auto gate (/showthread.php?tid=599495)



auto gate - GeneralAref - 26.01.2016

what is this code problem?this works only for id 1 and upper.

Код:
public areagatecheck()
{
 	foreach(Player, i){
  	if(i < 101){
 		if(IsPlayerInRangeOfPoint(i, 15, 134.7061, 1941.5814, 21.6600)){
            if(gTeam[i] == TEAM_Internationalforces){
          		MoveObject(areagate1, 121.6021, 1941.5845, 21.6600, 5);}}
        else MoveObject(areagate1, 134.7061, 1941.5814, 21.6600, 5);
        if(IsPlayerInRangeOfPoint(i, 15, 286.0547, 1819.8330, 19.9611)){
            if(gTeam[i] == TEAM_Internationalforces){
          		MoveObject(areagate2, 286.0697, 1833.7720, 19.9611, 5);}}
   		else MoveObject(areagate2, 286.05475, 1819.83301, 19.96110, 5);
        return;}}}



Re: auto gate - Sascha - 26.01.2016

might be because your "foreach" starts with "i" as 1 instead of "0"...
In this case just use "i-1" each time within the loop


Re: auto gate - Vince - 26.01.2016

Foreach syntax is:
PHP код:
foreach(new Player
Also I have no idea what this is supposed to do:
PHP код:
if(101
If your max players is 100 then redefine MAX_PLAYERS as such. Foreach only loops over connected players, which is one of its major design features.


Re: auto gate - GeneralAref - 27.01.2016

Quote:
Originally Posted by Vince
Посмотреть сообщение
Foreach syntax is:
PHP код:
foreach(new Player
Also I have no idea what this is supposed to do:
PHP код:
if(101
If your max players is 100 then redefine MAX_PLAYERS as such. Foreach only loops over connected players, which is one of its major design features.
with this code, gates works only for id 0.


Re: auto gate - VVWVV - 27.01.2016

pawn Код:
public areagatecheck()
{
    foreach(new i: Player)
    {
        if(i < 101){
            if(IsPlayerInRangeOfPoint(i, 15, 134.7061, 1941.5814, 21.6600))
            {
                if(gTeam[i] == TEAM_Internationalforces)
                {
                    MoveObject(areagate1, 121.6021, 1941.5845, 21.6600, 5);
                }
            }
            else MoveObject(areagate1, 134.7061, 1941.5814, 21.6600, 5);

            if(IsPlayerInRangeOfPoint(i, 15, 286.0547, 1819.8330, 19.9611))
            {
                if(gTeam[i] == TEAM_Internationalforces)
                {
                    MoveObject(areagate2, 286.0697, 1833.7720, 19.9611, 5);
                }
            }
            else MoveObject(areagate2, 286.05475, 1819.83301, 19.96110, 5);

            // return; Removes the iteration.
        }
    }
}



Re: auto gate - GeneralAref - 27.01.2016

not works.gates works only for 0


Re: auto gate - itsCody - 27.01.2016

What does
PHP код:
if(101
even do?

Remove that and try again?


Re: auto gate - GeneralAref - 28.01.2016

not works for all player.


Re: auto gate - GeneralAref - 28.01.2016

I need this code. please help.


Re: auto gate - N0FeaR - 28.01.2016

Quote:
Originally Posted by GeneralAref
Посмотреть сообщение
I need this code. please help.
Stop spam,

try this

PHP код:
public areagatecheck()
{
    foreach(new 
iPlayer)
    {
            if(
IsPlayerInRangeOfPoint(i15134.70611941.581421.6600))
            {
                if(
gTeam[i] == TEAM_Internationalforces)
                {
                    
MoveObject(areagate1121.60211941.584521.66005);
                }
            }
            else 
MoveObject(areagate1134.70611941.581421.66005);
            if(
IsPlayerInRangeOfPoint(i15286.05471819.833019.9611))
            {
                if(
gTeam[i] == TEAM_Internationalforces)
                {
                    
MoveObject(areagate2286.06971833.772019.96115);
                }
            }
            else 
MoveObject(areagate2286.054751819.8330119.961105);
            
// return; Removes the iteration.
        
}
    }