Some error help -
SnG.Scot_MisCuDI - 25.01.2012
Im trying to make a /up (amount) command again..
pawn Код:
CMD:up(playerid, params[])
{
if(IsPlayerLuxAdmin(playerid))
new amount[12], str[128];
new Float:X, Float:Y, Float:Z;
GetPlayerPos(X,Y,Z);
SetPlayerPos(playerid,X+%s,Y,Z);
format(str,sizeof(str), "** Moved up %s feet.",amount);
SendClientMessage(playerid,COL_ADMIN,str);
return 1;
)
Errors
pawn Код:
(359) : error 003: declaration of a local variable must appear in a compound block
(359) : error 017: undefined symbol "amount"
(359) : warning 215: expression has no effect
(359) : error 001: expected token: ";", but found "]"
(359) : fatal error 107: too many error messages on one line
Line 359
pawn Код:
new amount[12], str[128];
Reppin' for some help
Re: Some error help -
Lilcuete - 26.01.2012
Quote:
Originally Posted by googamalugafoo
Im trying to make a /up (amount) command again..
pawn Код:
CMD:up(playerid, params[]) { if(IsPlayerLuxAdmin(playerid)) new amount[12], str[128]; new Float:X, Float:Y, Float:Z; GetPlayerPos(X,Y,Z); SetPlayerPos(playerid,X+%s,Y,Z); format(str,sizeof(str), "** Moved up %s feet.",amount); SendClientMessage(playerid,COL_ADMIN,str); return 1; )
Errors
pawn Код:
(359) : error 003: declaration of a local variable must appear in a compound block (359) : error 017: undefined symbol "amount" (359) : warning 215: expression has no effect (359) : error 001: expected token: ";", but found "]" (359) : fatal error 107: too many error messages on one line
Line 359
pawn Код:
new amount[12], str[128];
Reppin' for some help
|
Here you go
pawn Код:
CMD:up(playerid, params[])
{
if ((IsPlayerLuxAdmin(playerid))
{
new Float:slx, Float:sly, Float:slz;
GetPlayerPos(playerid, slx, sly, slz);
SetPlayerPos(playerid, slx, sly, slz+2);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, " You Are Not An Admin");
}
return 1;
}
Sorry for loose indentation see if it works,i edited this from my code.
Re: Some error help -
[ABK]Antonio - 26.01.2012
I'm not sure if this will work, but worth a shot.
pawn Код:
if(isnull(params)) return SendClientMessage(playerid, 0xCC0000AA, "Please enter an amount.")
new Float:Amount = floatstr(params);
SetPlayerPos(playerid,X+Amount,Y,Z);
EDIT: lmao just noticed i did (playerid, 0xCC0000AA, "Please enter a message.")
Re: Some error help -
SnG.Scot_MisCuDI - 26.01.2012
Quote:
Originally Posted by Lilcuete
Here you go
pawn Код:
CMD:up(playerid, params[])
{ if ((IsPlayerLuxAdmin(playerid)) { new Float:slx, Float:sly, Float:slz; GetPlayerPos(playerid, slx, sly, slz); SetPlayerPos(playerid, slx, sly, slz+2); return 1; } else { SendClientMessage(playerid, COLOR_GRAD1, " You Are Not An Admin"); } return 1; }
Sorry for loose indentation see if it works,i edited this from my code.
|
Not what i need.
Quote:
Originally Posted by [ABK]Antonio
I'm not sure if this will work, but worth a shot.
pawn Код:
if(isnull(params)) return SendClientMessage(playerid, 0xCC0000AA, "Please enter an amount.") new Float:Amount = floatstr(params); SetPlayerPos(playerid,X+Amount,Y,Z);
EDIT: lmao just noticed i did (playerid, 0xCC0000AA, "Please enter a message.")
|
I used part of that but now i get:
pawn Код:
(362) : warning 213: tag mismatch
(362) : warning 202: number of arguments does not match definition
Line 362
whole code for review
pawn Код:
CMD:up(playerid, params[])
{
new str[128];
new Float:Amount = floatstr(params);
new Float:X,Float:Y,Float:Z;
if(IsPlayerLuxAdmin(playerid))
GetPlayerPos(X,Y,Z);
SetPlayerPos(playerid,X+Amount,Y,Z);
format(str,sizeof(str), "** Moved up %s feet.",Amount);
SendClientMessage(playerid,COL_ADMIN,str);
return 1;
}
Re: Some error help -
[ABK]Antonio - 26.01.2012
you forgot playerid in GetPlayerPos(playerid, X,Y,Z)
Oh yeah - Z axis = up and down.
Re: Some error help -
SnG.Scot_MisCuDI - 26.01.2012
Quote:
Originally Posted by [ABK]Antonio
you forgot playerid in GetPlayerPos(playerid, X,Y,Z)
|
Oh sweet. Thanks, and how can i make it so it says: Moved up %s feet?
And yeah i realized it was Y after i tested :P
Re: Some error help -
Tanush123 - 26.01.2012
umm moving up? if you want to make player must enter a number use
pawn Код:
CMD:up(playerid, params[])
{
new str[128];
new Amount;
new Float:X,Float:Y,Float:Z;
if(IsPlayerLuxAdmin(playerid))
if(sscanf(params,"d",Amount)) return SendClientMessage(playerid,-1,"USAGE: /up [number]");
GetPlayerPos(X,Y,Z);
SetPlayerPos(playerid,X+Amount,Y,Z);
format(str,sizeof(str), "** Moved up %d feet.",Amount);
SendClientMessage(playerid,COL_ADMIN,str);
return 1;
}
Re: Some error help -
[ABK]Antonio - 26.01.2012
It would be,
pawn Код:
format(str,sizeof(str), "** Moved up %f feet.",Amount);
- if you want to only show a certain amount of decimal values do,
pawn Код:
format(str,sizeof(str), "** Moved up %0.2f feet.",Amount);
as an example, you would change the 2 to how many decimal places you want to show. for no decimal values,
pawn Код:
format(str,sizeof(str), "** Moved up %d feet.",floatround(Amount));
Also, Tanush, floatstr(params) takes the float from params and converts it to a float. What you did isn't a float at all but a normal number anyway
Re: Some error help -
Tanush123 - 26.01.2012
Quote:
Originally Posted by [ABK]Antonio
It would be,
pawn Код:
format(str,sizeof(str), "** Moved up %f feet.",Amount);
- if you want to only show a certain amount of decimal values do,
pawn Код:
format(str,sizeof(str), "** Moved up %0.2f feet.",Amount);
as an example, you would change the 2 to how many decimal places you want to show. for no decimal values,
pawn Код:
format(str,sizeof(str), "** Moved up %d feet.",floatround(Amount));
Also, Tanush, floatstr(params) takes the float from params and converts it to a float. What you did isn't a float at all but a normal number anyway
|
Well sorry about my mistake.
Re: Some error help -
SnG.Scot_MisCuDI - 26.01.2012
What Tanush gave me worked. Also what you did before Antonio. Its working perfect now!
Thanks i gave you both rep