Displaying position?
#1

Код:
	if (strcmp("/mypos", cmdtext, true, 10) == 0)
	{
  		new Float:x, Float:y, Float:z;
 		GetPlayerPos(playerid, x, y, z);
 		SendClientMessage(playerid, COLOR_REDTRANS, "Displaying position... Loaded...");
		format(string, sizeof(string), "Your position: %s, %s, %s.", x, y, z);
		return 1;
	}
That's my code, but I get this:
Quote:

C:\Users\James\Desktop\SAMP Server\gamemodes\ReelWurld.pwn(124) : error 017: undefined symbol "string"
C:\Users\James\Desktop\SAMP Server\gamemodes\ReelWurld.pwn(124) : error 017: undefined symbol "string"
C:\Users\James\Desktop\SAMP Server\gamemodes\ReelWurld.pwn(124) : error 029: invalid expression, assumed zero
C:\Users\James\Desktop\SAMP Server\gamemodes\ReelWurld.pwn(124) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

Reply
#2

pawn Код:
if (strcmp("/mypos", cmdtext, true, 10) == 0)
{
    new Float:x, Float:y, Float:z, string[128];
    GetPlayerPos(playerid, x, y, z);
    SendClientMessage(playerid, COLOR_REDTRANS, "Displaying position... Loaded...");
    format(string, sizeof(string), "Your position: %f, %f, %f.", x, y, z);
    SendClientMessage(playerid, COLOR_REDTRANS, string);
    return 1;
}
Edit tabs..
Reply
#3

Maybe you should make it like this:

Код:
//under
OnPlayerCommandText(playerid, cmdtext[])

  new string[256];

//then your code here
	if (strcmp("/mypos", cmdtext, true, 6) == 0) //should be 6 not 10
	{
  		new Float:x, Float:y, Float:z;
 		GetPlayerPos(playerid, x, y, z);
 		SendClientMessage(playerid, COLOR_REDTRANS, "Displaying position... Loaded...");
		format(string, sizeof(string), "Your position: %s, %s, %s.", x, y, z);
        SendClientMessage(playerid,COLOR_REDTRANS,string);
		return 1;
	}
And then do whatever you have to do...Cheers

AF1
Reply
#4

Quote:
Originally Posted by AF1-4-LIFE
Maybe you should make it like this:

Код:
//under
OnPlayerCommandText(playerid, cmdtext[])

  new string[256];

//then your code here
	if (strcmp("/mypos", cmdtext, true, 6) == 0) //should be 6 not 10
	{
  		new Float:x, Float:y, Float:z;
 		GetPlayerPos(playerid, x, y, z);
 		SendClientMessage(playerid, COLOR_REDTRANS, "Displaying position... Loaded...");
		format(string, sizeof(string), "Your position: %s, %s, %s.", x, y, z);
        SendClientMessage(playerid,COLOR_REDTRANS,string);
		return 1;
	}
And then do whatever you have to do...Cheers

AF1
No, use the one CAR made, although personally I would make it (strcmp("/mypos", cmdtext, true) == 0). Actually I wouldn't use strcmp, but whatever.
Reply
#5

Yea i usually use it like this strcmp("/ ", cmdtext, true) == 0) and yea CAR's is prob better and shorter but defining the string from under OnPlayerCommandText is easier than every time adding a new command you gotta define the string. But anyways whichever is better should work, haven't tested anything, just helping out...

Cheers,
AF1
Reply
#6

Define string with a size of 128, NOT 256.
Reply
#7

Quote:
Originally Posted by Brendan_Thomson
Define string with a size of 128, NOT 256.
Exactly. I'd also use zcmd.
Reply
#8

Quote:
Originally Posted by radhakr
Quote:
Originally Posted by Brendan_Thomson
Define string with a size of 128, NOT 256.
Exactly. I'd also use zcmd.
Seconded, using ZCMD:

pawn Код:
cmd(mypos, playerid, params[])
{
new string[128], Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
format(string, sizeof(string), "* You are at: %f, %f, %f.");
SendClientMessage(playerid, COLOR, string);
return 1;
}
Reply
#9

Quote:
Originally Posted by Brendan_Thomson
Define string with a size of 128, NOT 256.
would you mind explaining that? because i see no reason why you could not define it to be 62 big, and that has margin for error.
Reply
#10

Quote:
Originally Posted by Daren_Jacobson
Quote:
Originally Posted by Brendan_Thomson
Define string with a size of 128, NOT 256.
would you mind explaining that? because i see no reason why you could not define it to be 62 big, and that has margin for error.
256 is too big, 128 is all that is needed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)