Help with my ping command
#1

It shows 0 ping all time

Код:
CMD:ping(playerid,params[])
{
	if(PInfo[playerid][Level] < 1)
    return SendClientMessage(playerid,STEALTH_BLUE,"You need to be level 1 to get ping of players.");
    new id, string[128];
    if(sscanf(params,"us",id))
	return SendClientMessage(playerid,STEALTH_BLUE,"USAGE: /ping [id]");
	if(!IsPlayerConnected(id))
	return SendClientMessage(playerid,STEALTH_BLUE,"That player is not connected!");
	new pPing[10],pName[25];
	GetPlayerPing(id,pPing,sizeof(pPing));
	GetPlayerName(id, pName, sizeof(pName));
	format(string, sizeof(string), "%s:[%d]", pName, pPing);
	SendClientMessage(playerid,COLOR_SIENNA,string);
	return 1;
}
Reply
#2

Variable 'pPing' doesn't need a size since it's an integer and not a string.

pawn Код:
new pPing, pName[24];
EDIT: That's not how you use GetPlayerPing!
Reread the following article please: https://sampwiki.blast.hk/wiki/GetPlayerPing

EDIT2: In your case it would look something like this:
pawn Код:
pPing = GetPlayerPing(id);
Reply
#3

Read the wiki page of GetPlayerPing (and sscanf2 maybe).
pawn Код:
CMD:ping(playerid,params[])
{
    if(PInfo[playerid][Level] < 1)
    return SendClientMessage(playerid,STEALTH_BLUE,"You need to be level 1 to get ping of players.");
    new id, string[128];
    if(sscanf(params,"u",id))
    return SendClientMessage(playerid,STEALTH_BLUE,"USAGE: /ping [id]");
    if(!IsPlayerConnected(id))
    return SendClientMessage(playerid,STEALTH_BLUE,"That player is not connected!");
    new pPing,pName[25];
    pPing = GetPlayerPing(id);
    GetPlayerName(id, pName, sizeof(pName));
    format(string, sizeof(string), "%s:[%d]", pName, pPing);
    SendClientMessage(playerid,COLOR_SIENNA,string);
    return 1;
}
Reply
#4

Alright thanks for your help guys
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)