SA-MP Forums Archive
Omg this is going crazy -.- - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Omg this is going crazy -.- (/showthread.php?tid=339503)



Omg this is going crazy -.- - Face9000 - 03.05.2012

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.


Re: Omg this is going crazy -.- - ViniBorn - 03.05.2012

Put ; on the previous line..

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



Re: Omg this is going crazy -.- - 2KY - 03.05.2012

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


Re: Omg this is going crazy -.- - FalconX - 03.05.2012

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


Re: Omg this is going crazy -.- - Face9000 - 03.05.2012

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


Re: Omg this is going crazy -.- - Revo - 03.05.2012

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.)


Re: Omg this is going crazy -.- - 2KY - 03.05.2012

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.


Re: Omg this is going crazy -.- - FalconX - 03.05.2012

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..


Re: Omg this is going crazy -.- - Face9000 - 03.05.2012

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];



Re: Omg this is going crazy -.- - 2KY - 03.05.2012

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.