public OnPlayerCommandText(playerid, cmdtext[]) { dcmd(trace, 5, cmdtext); return 1; }
dcmd_trace(playerid, params[]) { if(!strlen(params)){ SendClientMessage(playerid, YOURCOLOR, "/trace [id]"); return 1; } new pid = strval(params); if(!IsPlayerConnected(pid)){ SendClientMessage(playerid, YOURCOLOR, "Player is not connected"); return 1; }else{ new string[256], name[MAX_PLAYER_NAME], Float:x, Float:y, Float:z; GetPlayerName(pid, name, sizeof(name)); GetPlayerPos(pid, x, y, z); format(string, sizeof(string), "%s's position: %f, %f, %f", name, x, y, z); SendClientMessage(playerid, YOURCOLOR, string); } } return 1; }
wn(86) : error 017: undefined symbol "dcmd"
C:\Documents and Settings\My Documents\Downloads\)\filterscripts\Tracefeature.pwn(246) : warning 203: symbol is never used: "dcmd_trace"
#pragma tabsize 0
public OnPlayerCommandText(playerid, cmdtext[])
{
line 86: dcmd(trace, 5, cmdtext);
return 1;
}
dcmd_trace(playerid, params[])
{
if(!strlen(params)){
SendClientMessage(playerid, YOURCOLOR, "/trace [id]");
return 1;
}
new pid = strval(params);
if(!IsPlayerConnected(pid)){
SendClientMessage(playerid, YOURCOLOR, "Player is not connected");
return 1;
}else{
new string[256], name[MAX_PLAYER_NAME], Float:x, Float:y, Float:z;
GetPlayerName(pid, name, sizeof(name));
GetPlayerPos(pid, x, y, z);
format(string, sizeof(string), "%s's position: %f, %f, %f", name, x, y, z);
SendClientMessage(playerid, YOURCOLOR, string);
}
}
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1 public OnPlayerCommandText(playerid, cmdtext[]) { dcmd(trace, 5, cmdtext); return 0; } dcmd_trace(playerid, params[]) { if(!strlen(params)){ SendClientMessage(playerid, YOURCOLOR, "/trace [id]"); return 1; } new pid = strval(params); if(!IsPlayerConnected(pid)){ SendClientMessage(playerid, YOURCOLOR, "Player is not connected"); return 1; }else{ new string[256], name[MAX_PLAYER_NAME], Float:x, Float:y, Float:z; GetPlayerName(pid, name, sizeof(name)); GetPlayerPos(pid, x, y, z); format(string, sizeof(string), "%s's position: %f, %f, %f", name, x, y, z); SendClientMessage(playerid, YOURCOLOR, string); } } return 1; }
I doubt the average player would be interested in knowing a players position to 5 decimal places.
|
format(string, sizeof(string), "%s's position: %f, %f, %f", name, x, y, z);
floatround(x, floatround_round); floatround(y, floatround_round); floatround(z, floatround_round); format(string, sizeof(string), "%s's positions: %.0f, %.0f, %.0f", name, x, y, z);
It works, first of all I'm so thankful, second of all, when I trace someone, it prints the result as:
test's positions: 301, 412, 510. Is there any way to change it into a name ? for example if the player is at the Grove street, the script will show that he is at Grove street. |