IsPlayerconnected question - Whatwasit - 21.08.2015
Hello
QUESTION 1
Well, I did this code, but I would like to know if, thanks to this, we can type /stats [ID] and have the stats of the person that i type the id ?
Because, I typed /stats for test, it writes my stats, but if I type /stats myid. It don't work.
How can modificate it to do it for all players ?
Код:
CMD:stats(playerid,params[])
{
new id, tmp[50], string[1028];
sscanf(params, "u", id);
if (isnull(params))
{
format(tmp, sizeof(tmp), "Score: %d\n", GetPlayerScore(playerid));
strcat(string, tmp);
format(tmp, sizeof(tmp), "Money: $%d\n", GetPlayerMoney(playerid));
strcat(string, tmp);
ShowPlayerDialog(playerid, 325, DIALOG_STYLE_MSGBOX, "Stats", string, "Ok","");
}
return 1;
}
QUESTION 2.
Код:
CMD:stats(playerid,params[])
{
new id, tmp[50], string[1028];
sscanf(params, "u", id);
if (isnull(params))
{
format(tmp, sizeof(tmp), "Score: %d\n", GetPlayerScore(playerid));
strcat(string, tmp);
if(IsPlayerConnected(player1))
{
format(tmp, sizeof(tmp), "Money: $%d\n", GetPlayerMoney(playerid));
strcat(string, tmp);
ShowPlayerDialog(playerid, 325, DIALOG_STYLE_MSGBOX, "Stats", string, "Ok","");
} else
return
format(tmp, sizeof(tmp), "\n");
strcat(string, tmp);
}
return 1;
}
Is that is correct ? I want in this example, that only if the person where I want see stats, is register and logged, i can see the money of him. But I think its linked to question 1.
Thanks
Re: IsPlayerconnected question -
Inn0cent - 21.08.2015
Try, if(IsPlayerConnected(params[0]))
Re: IsPlayerconnected question -
Evocator - 21.08.2015
Q1:
Код:
CMD:stats(playerid,params[])
{
new
id,
tmp[50],
string[256]
;
if (sscanf(params, "u", id)) {
id = playerid;
}
if (!IsPlayerConnected(id))
return SendClientMessage(playerid, -1, "Not online.")
format(tmp, sizeof(tmp), "Score: %d\n", GetPlayerScore(playerid));
strcat(string, tmp);
format(tmp, sizeof(tmp), "Money: $%d\n", GetPlayerMoney(playerid));
strcat(string, tmp);
ShowPlayerDialog(id, 325, DIALOG_STYLE_MSGBOX, "Stats", string, "Ok","");
return 1;
}
Q2:
Код:
CMD:stats(playerid,params[])
{
new
id,
tmp[50],
string[256]
;
if (sscanf(params, "u", id)) {
id = playerid;
}
if (!IsPlayerConnected(id))
return SendClientMessage(playerid, -1, "Not online.");
//if (!IsPlayerLoggedIn(id))
// return SendClientMessage(playerid, -1, "Not loggedin.");
format(tmp, sizeof(tmp), "Score: %d\n", GetPlayerScore(playerid));
strcat(string, tmp);
format(tmp, sizeof(tmp), "Money: $%d\n", GetPlayerMoney(playerid));
strcat(string, tmp);
ShowPlayerDialog(id, 325, DIALOG_STYLE_MSGBOX, "Stats", string, "Ok","");
return 1;
}