13.06.2013, 01:36
What I wanted to do is I wanted a command /ping, with that player could enable a textdraw on the botton of the screen showing his ping "Ping: 234". The /ping command first checks if the player's ping text draw is on or not, if on then hide if not on then bring it on. Below is my attempt, but it doesn't do anything when I type /ping except for the SERVER: Unknown command notice.
Could someone help me out there please?
pawn Код:
// On top of the script
new bool:ping[MAX_PLAYERS];
new Text:PingText[MAX_PLAYERS];
// OnPlayerConnect
ping[playerid] = false;
TextDrawFont(PingText[playerid], 2);
TextDrawColor(PingText[playerid], 0xB0A32DFF);
TextDrawSetProportional(PingText[playerid], true);
TextDrawSetShadow(PingText[playerid], 1);
// OnGameModeInit
for(new i=0; i<MAX_PLAYERS; i++)
{
PingText[i] = TextDrawCreate(222.5, 386, " ");
}
// Command /ping
CMD:ping(playerid,params[])
{
if(ping[playerid] == false)
{
new string[128];
format(string,sizeof(string),"Ping: ~w~%s",GetPlayerPing(playerid));
TextDrawSetString(PingText[playerid],string);
ping[playerid] = true;
return 1;
}
else
{
TextDrawHideForPlayer(playerid,PingText[playerid]);
ping[playerid] = false;
return 1;
}
}