Time doubles speed when 2 players online.
#1

So here is my problem.
I made a command so that the player can use it once in 1 minute.
When there are 2 players, the speed of the textdraw doubles, goes 2x faster, only if we both use the command.
So here i'm going to show you my code.

It's a pretty long command, but i'm going to show you where the problem is...
pawn Код:
if(strcmp(cmd, "/HEAL", true) == 0)
    {
   
    if(GetPlayerRank(playerid) == 0)
  {
    SendClientMessage(playerid, COLOR_RED, "You are not allowed to use this command.Low rank!");
  }
 
  if(GetPlayerRank(playerid) == 1)
  {
        if(DMzone[playerid] == 0)
        {
          if (GetPlayerMoney(playerid) >= 2000)
          {
                new Float:HHEALTH;
                GivePlayerMoney(playerid, -2000);
                GetPlayerHealth(playerid, HHEALTH);
        SetPlayerHealth(playerid, HHEALTH+50);
                GameTextForPlayer(playerid, "~g~Healed~w~!~n~~r~-~y~2~w~.~y~000~g~$",2000,1);
      }
      else
      {
                SendClientMessage(playerid, COLOR_RED, "You need atleast 2.000$");
          }
             
    }
        if(DMzone[playerid] == 1)
        {
     if (GetPlayerMoney(playerid) >= 5000)
         {
            if(HEALTHTIMER[playerid] == 1)
      {
                SendClientMessage(playerid, COLOR_RED, "This command can be used again after 1 minute");
                return 1;
      }
/////////////////////////////////////////////////////////////////////////////
        new Float:HHEALTH;
            GetPlayerHealth(playerid, HHEALTH);
            SetPlayerHealth(playerid, HHEALTH+50);
            GameTextForPlayer(playerid, "~g~~h~Healed~w~!", 3000, 1);
            //SetTimerEx("NewbieH", 60000, false, "i", playerid);//1 MINUTES
            CountDownTrue = 1;
        CountDownMinutes = 1; //in minutes
            CountDownSeconds = 1; //in seconds
            HEALTHTIMER[playerid] = 1;
           
            format(string, sizeof(string), "%d:%d", CountDownMinutes, CountDownSeconds);
            TextDrawSetString(Text:CountText2, string);
            TextDrawShowForPlayer(playerid,CountText2);
            SetTimer("CountDownTimer", 1000, 0);
/////////////////////////////////////////////////////////////////////////////
       }
         else
     {
       SendClientMessage(playerid, COLOR_RED, "You need atleast 5.000$.");
     }

        }
  }
 
  if(GetPlayerRank(playerid) == 2)
  {
        if(DMzone[playerid] == 0)
        {
            new Float:UBHealth;
            GetPlayerHealth(playerid, UBHealth);
      SetPlayerHealth(playerid, UBHealth+50);
    }
        else
        {
          SendClientMessage(playerid, COLOR_RED, "This command can be used only in Stunt Zones.");
        }
  }
 
    return 1;
  }
My problem is betwen the comented lines....

Oh and here is the textdraw:
pawn Код:
public CountDownTimer(playerid)
{
  if (CountDownTrue == 1)
    {
        CountDownSeconds--;
        if (CountDownSeconds == 0)
        {
          CountDownSeconds = 60;
          if (CountDownMinutes == 0)
            {
                CountDownTrue = 0;
                TextDrawHideForPlayer(playerid, CountText2);
                HEALTHTIMER[playerid] = 0;
            }
            CountDownMinutes--;
        }
        new string[256];
      format(string, sizeof(string), "%d:%d", CountDownMinutes, CountDownSeconds);
        TextDrawSetString(Text:CountText2, string);
        SetTimer("CountDownTimer", 1000, 0);
        return 1;
    }
    return 1;
}
I know its a long code, but i beg you to don't just tae a look and if it's too big u'll go away.

Help

BTW, pawn codes fcked up identation...
Reply
#2

You have to define your var. with MAX_PLAYERS

So change
Код:
new CountDownSeconds;
into
Код:
new CountDownSeconds[MAX_PLAYERS];
Then use
Код:
CountDownSeconds[playerid]--;
Reply
#3

Like this?
pawn Код:
public CountDownTimer(playerid)
{
  if (CountDownTrue == 1)
    {
        CountDownSeconds[playerid]--;
        if (CountDownSeconds == 0)
        {
          CountDownSeconds = 60;
          if (CountDownMinutes == 0)
            {
                CountDownTrue = 0;
                TextDrawHideForPlayer(playerid, CountText2);
                HEALTHTIMER[playerid] = 0;
            }
            CountDownMinutes--;
        }
        new string[256];
      format(string, sizeof(string), "%d:%d", CountDownMinutes, CountDownSeconds);
        TextDrawSetString(Text:CountText2, string);
        SetTimer("CountDownTimer", 1000, 0);
        return 1;
    }
    return 1;
}
O tried also with a loop first, didn't work.

Gotta try now and tell results, thanks ryder
Reply
#4

Don't forget to change to other variables too.
(Do CTRL+F and type above CountDownSeconds and let it all replace with CountDownSeconds[playerid]);

Also CountDownMinutes needs MAX_PLAYERS.
Reply
#5

Done what you told me.
This is how it looks like now...

COMMAND:
pawn Код:
if(HEALTHTIMER[playerid] == 1)
      {
                SendClientMessage(playerid, COLOR_RED, "This command can be used again after 1 minute");
                return 1;
      }
        new Float:HHEALTH;
            GetPlayerHealth(playerid, HHEALTH);
            SetPlayerHealth(playerid, HHEALTH+50);
            GameTextForPlayer(playerid, "~g~~h~Healed~w~!", 3000, 1);
            //SetTimerEx("NewbieH", 60000, false, "i", playerid);//1 MINUTES
            CountDownTrue = 1;
        CountDownMinutes[playerid] = 1; //in minutes
            CountDownSeconds[playerid] = 1; //in seconds
            HEALTHTIMER[playerid] = 1;
           
            format(string, sizeof(string), "%d:%d", CountDownMinutes[playerid], CountDownSeconds[playerid]);
            TextDrawSetString(Text:CountText2, string);
            TextDrawShowForPlayer(playerid,CountText2);
            SetTimer("CountDownTimer", 1000, 0);
       }
TEXTDRAW:
pawn Код:
public CountDownTimer(playerid)
{
  if (CountDownTrue == 1)
    {
        CountDownSeconds[playerid]--;
        if (CountDownSeconds[playerid] == 0)
        {
          CountDownSeconds[playerid] = 60;
          if (CountDownMinutes[playerid] == 0)
            {
                CountDownTrue = 0;
                TextDrawHideForPlayer(playerid, CountText2);
                HEALTHTIMER[playerid] = 0;
            }
            CountDownMinutes[playerid]--;
        }
        new string[256];
      format(string, sizeof(string), "%d:%d", CountDownMinutes[playerid], CountDownSeconds[playerid]);
        TextDrawSetString(Text:CountText2, string);
        SetTimer("CountDownTimer", 1000, 0);
        return 1;
    }
    return 1;
}
And still doesn't works
do i have to do MAX_PLAYERS with CountDownTrue too?
Reply
#6

Quote:
Originally Posted by PlayON
Done what you told me.
This is how it looks like now...

COMMAND:
pawn Код:
if(HEALTHTIMER[playerid] == 1)
      {
                SendClientMessage(playerid, COLOR_RED, "This command can be used again after 1 minute");
                return 1;
      }
        new Float:HHEALTH;
            GetPlayerHealth(playerid, HHEALTH);
            SetPlayerHealth(playerid, HHEALTH+50);
            GameTextForPlayer(playerid, "~g~~h~Healed~w~!", 3000, 1);
            //SetTimerEx("NewbieH", 60000, false, "i", playerid);//1 MINUTES
            CountDownTrue = 1;
        CountDownMinutes[playerid] = 1; //in minutes
            CountDownSeconds[playerid] = 1; //in seconds
            HEALTHTIMER[playerid] = 1;
           
            format(string, sizeof(string), "%d:%d", CountDownMinutes[playerid], CountDownSeconds[playerid]);
            TextDrawSetString(Text:CountText2, string);
            TextDrawShowForPlayer(playerid,CountText2);
            SetTimer("CountDownTimer", 1000, 0);
       }
TEXTDRAW:
pawn Код:
public CountDownTimer(playerid)
{
  if (CountDownTrue == 1)
    {
        CountDownSeconds[playerid]--;
        if (CountDownSeconds[playerid] == 0)
        {
          CountDownSeconds[playerid] = 60;
          if (CountDownMinutes[playerid] == 0)
            {
                CountDownTrue = 0;
                TextDrawHideForPlayer(playerid, CountText2);
                HEALTHTIMER[playerid] = 0;
            }
            CountDownMinutes[playerid]--;
        }
        new string[256];
      format(string, sizeof(string), "%d:%d", CountDownMinutes[playerid], CountDownSeconds[playerid]);
        TextDrawSetString(Text:CountText2, string);
        SetTimer("CountDownTimer", 1000, 0);
        return 1;
    }
    return 1;
}
And still doesn't works
do i have to do MAX_PLAYERS with CountDownTrue too?
Yep, everything. Because it's for each player apart. If you use one variable over 500 players it will bug =D.
Can you send me the FS/GM ?
Reply
#7

http://pastebin.com/DfqbRaK8

Here is, i put things togheter, if you need something else in it, tell me
If you solve my problem, u'll be in credits, twice, coz i use your Transmission xD
Reply
#8

Quote:
Originally Posted by PlayON
http://pastebin.com/DfqbRaK8

Here is, i put things togheter, if you need something else in it, tell me
If you solve my problem, u'll be in credits, twice, coz i use your Transmission xD
Hold on a min or something
I'll post here.

Edit: I need ranks.inc :/
Reply
#9

Quote:
Originally Posted by » RyDeR «
Quote:
Originally Posted by PlayON
http://pastebin.com/DfqbRaK8

Here is, i put things togheter, if you need something else in it, tell me
If you solve my problem, u'll be in credits, twice, coz i use your Transmission xD
Hold on a min or something
I'll post here.
Oh, the ranks!

http://forum.sa-mp.com/index.php?topic=47989.0
Reply
#10

Okey and can you also give me the textdraw?
Because that's needed too.
Reply


Forum Jump:


Users browsing this thread: