Some error help
#1

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
Reply
#2

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.
Reply
#3

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.")
Reply
#4

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
pawn Код:
GetPlayerPos(X,Y,Z);

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;
    }
Reply
#5

you forgot playerid in GetPlayerPos(playerid, X,Y,Z)

Oh yeah - Z axis = up and down.
Reply
#6

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
Reply
#7

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;
    }
Reply
#8

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
Reply
#9

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.
Reply
#10

What Tanush gave me worked. Also what you did before Antonio. Its working perfect now!

Thanks i gave you both rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)