Need to Change PlayerPos (for 2 teams) after 6 minutes.
#1

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

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

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

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

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

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

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

Got it. Thanks for helping me..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)