Omg this is going crazy -.-
#1

Ok,i've created the textdraws,set a global timer and forwarded with public,im stucked on this simple error now:

Error:

error 001: expected token: ";", but found "new"

Full string:

pawn Код:
new cashstring[128];
    format(cashstring,sizeof(cashstring),"%i");
    TextDrawSetString(Hp[i], cashstring);
Line error:

pawn Код:
new cashstring[128];
What's wrong??

I used the string to update a textdraw for the cash of the player,but i dont see any error on that.
Reply
#2

Put ; on the previous line..

pawn Код:
new cashstring[128];
format(cashstring,sizeof(cashstring),"%i",value);
TextDrawSetString(Hp[i], cashstring);
Reply
#3

It's the line above cash string. Can we see the entire function?
Reply
#4

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
Ok,i've created the textdraws,set a global timer and forwarded with public,im stucked on this simple error now:

Error:

error 001: expected token: ";", but found "new"

Full string:

pawn Код:
new cashstring[128];
    format(cashstring,sizeof(cashstring),"%i");
    TextDrawSetString(Hp[i], cashstring);
Line error:

pawn Код:
new cashstring[128];
What's wrong??

I used the string to update a textdraw for the cash of the player,but i dont see any error on that.
Look there is a problem in your format that is causing such error.

pawn Код:
new cashstring[128];
format(cashstring,sizeof(cashstring),"%i", SOMETHING); // put something there, maybe cash ?
TextDrawSetString(Hp[i], cashstring);
Original Link: https://sampwiki.blast.hk/wiki/Format
-FalconX
Reply
#5

Holy shit..i can't believe i stucked at this small point. Thanks guys.
Reply
#6

Like Viniborn said, the line just above the "new cashstring[128]" is missing a ;

If you still can't figure it out by then post a larger portion of the code. But basically what you have is
pawn Код:
new hi
new cashstring[128];
    format(cashstring,sizeof(cashstring),"%i");
    TextDrawSetString(Hp[i], cashstring);
Line 1 is incorrect (as it's missing a ";", but the warning is at line two.)
Reply
#7

Quote:
Originally Posted by FalconX
Посмотреть сообщение
Look there is a problem in your format that is causing such error.

pawn Код:
new cashstring[128];
format(cashstring,sizeof(cashstring),"%i", SOMETHING); // put something there, maybe cash ?
TextDrawSetString(Hp[i], cashstring);
Original Link: https://sampwiki.blast.hk/wiki/Format
-FalconX
that would not cause an error leaving it blank..

pawn Код:
new Text:Hello;

new cashstring[128];
    format(cashstring,sizeof(cashstring),"%i");
    TextDrawSetString(hello, cashstring);
Works perfectly fine. It's the line above it.
Reply
#8

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
Holy shit..i can't believe i stucked at this small point. Thanks guys.
No problem, I just realized we three posted at the same minute haha..
Reply
#9

Edit: I make like you guys said,same error at same line.Full function:

pawn Код:
public InfoUpdate()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
    new cashstring[128];
    format(cashstring,sizeof(cashstring),"%i",GetPlayerMoney(i));
    TextDrawSetString(Hp[i], cashstring);
    }
    return 1;
}
I dont need to do a "new:Text" because i've it already:


pawn Код:
new Text:Hp[MAX_PLAYERS];
Reply
#10

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
Edit: I make like you guys said,same error at same line.Full function:

pawn Код:
public InfoUpdate()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
    new cashstring[128];
    format(cashstring,sizeof(cashstring),"%i",GetPlayerMoney(i));
    TextDrawSetString(Hp[i], cashstring);
    }
    return 1;
}
I dont need to do a "new:Text" because i've it already:


pawn Код:
new Text:Hp[MAX_PLAYERS];
pawn Код:
public InfoUpdate( )
{
    new
        cashStr [ 128 ];
       
    for( new u; u < MAX_PLAYERS; u ++ )
    {
        format( cashStr, sizeof( cashStr ), "%i", GetPlayerMoney( i ) );
        TextDrawSetString( Hp [ u ], cashStr );
    }
    return true;
}
Try that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)