How to
#1

Okay, let's say I have this :

pawn Код:
new playerid2; // On top of my script

dcmd_stats(playerid, params[])
{
  new string[156];
  new name[MAX_PLAYER_NAME];
  if(sscanf(params, "u", playerid2))
  {
    stats = SetTimerEx("Stats", 1000, true, "i", playerid);
  }
  else if(playerid2 == INVALID_PLAYER_ID) SendClientMessage(playerid, Red, "[Server] : Invalid Player ID! Player not connected");
  else if(playerid2 == playerid)
  {
    stats = SetTimerEx("Stats", 1000, true, "i", playerid);
  }
  else
  {
    stats = SetTimerEx("Stats", 1000, true, "i", playerid);
  }
  return 1;
}
So now I'm stuck on how to get the player's stats on the Timer I've setted.
How can I get the player's stats in the Timer I've setted.
Just give me an example.
Reply
#2

pawn Код:
new playerid2; // On top of my script

dcmd_stats(playerid, params[])
{
  new string[156];
  new name[MAX_PLAYER_NAME];
  if(sscanf(params, "u", playerid2))
  {
    stats = SetTimerEx("Stats", 1000, true, "i", playerid);
  }
  else if(playerid2 == INVALID_PLAYER_ID) SendClientMessage(playerid, Red, "[Server] : Invalid Player ID! Player not connected");
  else if(playerid2 == playerid)
  {
    stats = SetTimerEx("Stats", 1000, true, "i", playerid);
  }
  else
  {
    stats = SetTimerEx("Stats", 1000, true, "i", playerid2);//just change this to playerid2
  }
  return 1;
}
Reply
#3

But wouldn't that give him the timer instead of me?
And the textdraw will show to him instead of me?
Reply
#4

Well, you will have to show us your 'Stats' function.
Reply
#5

Basically it's like this :

pawn Код:
forward Stats(playerid);
public Stats(playerid)
{
  new string[186];
  new ip[56];
  GetPlayerIp(playerid, ip, sizeof(ip));
  TextDrawShowForPlayer(playerid, Stats0);
  TextDrawShowForPlayer(playerid, Stats1);
 
  format(string, sizeof(string), "~r~Your Statistics :~n~~n~~b~Money :~n~~w~($%d)~n~~b~Score :~n~~w~(%d)~n~~b~Ping :~n~~w~(%d)~n~~b~Kills :~n~~w~(%d)~n~~b~Deaths :~n~~w~(%d)~n~~b~IP Address :~n~~w~(%s)", GetPlayerMoney(playerid), GetPlayerScore(playerid), GetPlayerPing(playerid), KillVar[playerid], DeathVar[playerid], ip);
  TextDrawSetString(Stats1, string);
  return 1;
}
Reply
#6

pawn Код:
forward StatsPlayer(playerid, playersid);
public StatsPlayer(playerid, playersid)
{
    new string[186];
    new ip[16];
    GetPlayerIp(playersid, ip, sizeof(ip));
    TextDrawShowForPlayer(playerid, Stats0);
    TextDrawShowForPlayer(playerid, Stats1);
    format(string, 186, "~r~Hes Statistics :~n~~n~~b~Money :~n~~w~($%d)~n~~b~Score :~n~~w~(%d)~n~~b~Ping :~n~~w~(%d)~n~~b~Kills :~n~~w~(%d)~n~~b~Deaths :~n~~w~(%d)~n~~b~IP Address :~n~~w~(%s)", GetPlayerMoney(playersid), GetPlayerScore(playersid), GetPlayerPing(playersid), KillVar[playersid], DeathVar[playersid], ip);
    TextDrawSetString(Stats1, string);
    return 1;
}

stats = SetTimerEx("StatsPlayer", 1000, true, "ii", playerid, playerid2);
Should work
Reply
#7

Still won't work.
Reply
#8

What error do you get?

EDIT:

pawn Код:
dcmd_stats(playerid, params[])
{
    new id;
    if(sscanf(params, "u", id)) return stats = SetTimerEx("Stats", 1000, true, "ii", playerid, playerid);
    else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, Red, "[Server] : Invalid Player ID! Player not connected");
    else if(id == playerid)
    {
        stats = SetTimerEx("Stats", 1000, true, "ii", playerid, playerid);
    }
    else
    {
        stats = SetTimerEx("Stats", 1000, true, "ii", playerid, id);
    }
    return 1;
}
Try this command...
Reply
#9

I'd think about making "stats" an array too because if two players use the stats command within a second of each other it might mess your timer ids up.
Reply
#10

I don't get any errors.
I just want the other player stats to show up to on the timer. (Playerid2)

@iggy1 Oh, okay. :3
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)