/getco ( Getting Player ID's Coordinates )
#1

Here's my code and its not working, it gives me numbers with no DECIAL stuff and its not the Coordinate of the target.


Quote:

new Float: poscord[3];

Quote:

CMD:getco(playerid, params[])
{
new giveplayerid;
if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /getco [playerid]");
GetPlayerPos(giveplayerid, poscord[0], poscord[1], poscord[2]);
if(IsPlayerInRangeOfPoint(playerid, 700, poscord[0], poscord[1], poscord[2]))
{
if(IsPlayerConnected(giveplayerid))
{
SetTimer("GetLocation", 4000, 0);
SendClientMessage(playerid, COLOR_GRAD4, "Analizing and Calculating Target Coordinates ( 4 Seconds )");
// SendClientMessage(playerid, COLOR_GRAD4, "Target Coordinates X - %d | Y - %d | Z - %d", poscord[0], poscord[1], poscord[2]);
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD4, "Target Coordinates cannot be taken, range from target is too far");
}
return 1;
}

Quote:

forward GetLocation(playerid);
public GetLocation(playerid)
{
new giveplayerid;
GetPlayerPos(giveplayerid, poscord[0], poscord[1], poscord[2]);
SendClientMessage(playerid, COLOR_GRAD4, "Target Coordinates successfully recieved");
SendClientMessage(playerid, COLOR_GRAD4, "Target Coordinates X - %d | Y - %d | Z - %d", poscord[0], poscord[1], poscord[2]);
return 1;
}

Reply
#2

SendClientMessage does not accept all of those additional parameters and cannot be used to format a string, you need to use a function such as format for that, for example:

pawn Код:
new string[128];
format(string, sizeof(string), "Target Coordinates X - %f | Y - %f | Z - %f", poscord[0], poscord[1], poscord[2]);

SendClientMessage(playerid, COLOR_GRAD4, string);
Reply
#3

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
SendClientMessage does not accept all of those additional parameters and cannot be used to format a string, you need to use a function such as format for that, for example:

pawn Код:
new string[128];
format(string, sizeof(string), "Target Coordinates X - %f | Y - %f | Z - %f", poscord[0], poscord[1], poscord[2]);

SendClientMessage(playerid, COLOR_GRAD4, string);
Atleast it does remove the Errors, now my code is

pawn Код:
forward GetLocation(playerid);
public GetLocation(playerid)
{
    new giveplayerid;
    new string[128];
    GetPlayerPos(giveplayerid, poscord[0], poscord[1], poscord[2]);
    SendClientMessage(playerid, COLOR_GRAD4, "Target Coordinates successfully recieved");
    format(string, sizeof(string), "Target Coordinates X - %f | Y - %f | Z - %f", poscord[0], poscord[1], poscord[2]);
    SendClientMessage(playerid, COLOR_GRAD4, string);
    return 1;
}
Works, Thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)