SA-MP Forums Archive
Need to Change PlayerPos (for 2 teams) after 6 minutes. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Need to Change PlayerPos (for 2 teams) after 6 minutes. (/showthread.php?tid=207069)



Need to Change PlayerPos (for 2 teams) after 6 minutes. - bhaveshnande - 05.01.2011

Hello there,
I am trying to change my server map (as I have 3 right now), after every 6 minutes. Basically I don't want to spawn the objects while changing the maps but Create all objects at first and then change the player position after every six minutes. I have two teams (made from this tutorial : https://sampwiki.blast.hk/wiki/PAWN_tutorial) and I want to set different locations for both of them after changing the map. Like when the map changes TeamA should spawn at x1,y1,z1 and TeamB should spawn at x2,y2,z2.
I tried to set a timer but it didn't help.
For example :

Код:
SetTimer - above and
forward changemap1();
public changemap1()
{
      if (gTeam[playerid] == TEAM_GROVE)
      {
            SetPlayerPos(playerid,XYZ);
      }
      else if (gTeam[playerid] == TEAM_BALLA)
      {
            SetPlayerPos(playerid,XYZ);
      }
}
When I try to compile the above code, it generates the error : undefined symbol 'playerid'.
And when I add 'playerid' in arguments like
Код:
forward changemap1(playerid)
public changemap1(playerid)
Nothing happens.
Is there any way to solve the problem?


Re: Need to Change PlayerPos (for 2 teams) after 6 minutes. - iggy1 - 05.01.2011

pawn Код:
public changemap1()
{
    for(new playerid; playerid < MAX_PLAYERS; playerid++)//i advise using foreach.
    {
        if(!IsPlayerConnected(playerid))continue;
        if (gTeam[playerid] == TEAM_GROVE)
        {
            SetPlayerPos(playerid,XYZ);
        }
        else if (gTeam[playerid] == TEAM_BALLA)
        {
            SetPlayerPos(playerid,XYZ);
        }
    }
}
I don't know why playerid param won't work it should.

EDIT: Sorry i'm not sure if you wanted to change everyones map/pos.


Re: Need to Change PlayerPos (for 2 teams) after 6 minutes. - WebGh0st - 05.01.2011

pawn Код:
forward changemap1(playerid);

public changemap1(playerid)
{
      if (gTeam[playerid] == TEAM_GROVE)
      {
            SetPlayerPos(playerid,XYZ);
      }
      else if (gTeam[playerid] == TEAM_BALLA)
      {
            SetPlayerPos(playerid,XYZ);
      }
      return 1;
}
Make it playerid, behind it, because you also use playerid, so you need to forward that to!

Greetz, iLex


Re: Need to Change PlayerPos (for 2 teams) after 6 minutes. - iggy1 - 05.01.2011

Quote:
Originally Posted by bhaveshnande
Посмотреть сообщение
When I try to compile the above code, it generates the error : undefined symbol 'playerid'.
And when I add 'playerid' in arguments like
Код:
forward changemap1(playerid)
public changemap1(playerid)
Nothing happens.
Is there any way to solve the problem?
He tried it


Re: Need to Change PlayerPos (for 2 teams) after 6 minutes. - bhaveshnande - 05.01.2011

Thanks iggy1 it worked! I was thinking over it for about 3-4 days, trying different methods but nothing worked lol.
Well,
Why does adding a for loop with the condition playerid < MAX_PLAYERS and playerid++ makes it work good?


Re: Need to Change PlayerPos (for 2 teams) after 6 minutes. - _rAped - 05.01.2011

Quote:
Originally Posted by bhaveshnande
Посмотреть сообщение
Thanks iggy1 it worked! I was thinking over it for about 3-4 days, trying different methods but nothing worked lol.
Well,
Why does adding a for loop with the condition playerid < MAX_PLAYERS and playerid++ makes it work good?
It creates a loop that checks all the players.


Re: Need to Change PlayerPos (for 2 teams) after 6 minutes. - iggy1 - 05.01.2011

The "playerid" could be called anything i just called it that to keep the vaiables ect looking uniform. The loop will loop through all players check their team and set their position. If you added the playerid param (to the function) you would need to call the function for every player thats connected. That might be why it didn't seem to work in the first place.


Re: Need to Change PlayerPos (for 2 teams) after 6 minutes. - bhaveshnande - 05.01.2011

Got it. Thanks for helping me..