Help with command to get player pos
#1

i'm trying to tell player's pos in the chat but it retrieves empty floats
any idia why this doesn't work?

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(strcmp(cmdtext, "/pos", true) == 0)
	{
	    new Float:x, Float:y, Float:z, string[50];
	    GetPlayerPos(playerid, x, y, z);
	    format(string, sizeof(string), "x: %f, y: %f, z: %f", x, y, z);
	    SendClientMessage(playerid, 0xFFFFFFAA, string);
	}
	return 1;
}
Reply
#2

Quote:
Originally Posted by Reiikz
Посмотреть сообщение
i'm trying to tell player's pos in the chat but it retrieves empty floats
any idia why this doesn't work?

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(strcmp(cmdtext, "/pos", true, 4) == 0)
	{
	    new Float:x, Float:y, Float:z, string[50];
	    GetPlayerPos(playerid, x, y, z);
	    format(string, sizeof(string), "x: %f, y: %f, z: %f", x, y, z);
	    SendClientMessage(playerid, 0xFFFFFFAA, string);
	}
	return 1;
}
Do these changes and tell me what it says on console
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(strcmp(cmdtext, "/pos", true) == 0)
	{
	    new Float:x, Float:y, Float:z, string[50];
	    GetPlayerPos(playerid, x, y, z);
            printf("x:%f, y:%f, z:%f", x, y, z);
	    format(string, sizeof(string), "x: %f, y: %f, z: %f", x, y, z);
	    SendClientMessage(playerid, 0xFFFFFFAA, string);
	}
	return 1;
}
Reply
#3

Use a larger string like 256 characters instead of 50.
Reply
#4

wired works for me!

Quote:
Originally Posted by insus100
Посмотреть сообщение
Use a larger string like 256 characters instead of 50.
No! 50 is enough theres no need for 256!

this req 44 cells

Код:
x: 1.11111111, y: 1.11111111, z: 1.11111111
also even if the cells wernt enough it would still display

for example instead off

Код:
x: 1.11111111, y: 1.11111111, z: 1.11111111
it would display

Код:
x: 1.11111111, y: 1.11111
Reply
#5

Quote:
Originally Posted by Lokii
Посмотреть сообщение
wired works for me!



No! 50 is enough theres no need for 256!

this req 44 cells

Код:
x: 1.11111111, y: 1.11111111, z: 1.11111111
also even if the cells wernt enough it would still display

for example instead off

Код:
x: 1.11111111, y: 1.11111111, z: 1.11111111
it would display

Код:
x: 1.11111111, y: 1.11111
i'm using a similar variable on a filterscript that was the problem, i removed temporarily the filterscript and it worked, thanks, i'm so stupid for creating a thread just for this
Reply
#6

Yeah, I thought his message displayed more characters like "Your pos is blahblahblah" but only displays the coords, I was wrong.
Reply
#7

Quote:
Originally Posted by Reiikz
Посмотреть сообщение
i'm using a similar variable on a filterscript that was the problem, i removed temporarily the filterscript and it worked, thanks, i'm so stupid for creating a thread just for this
We all started one day, there is no stupid question from a sensible person.
Reply
#8

Why people still use strcmp for commands, use ZCMD or YCMD.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)