is it possible to direct change a float to a string? -
Frede - 28.01.2013
is it possible to change a float direct to a sting. I mean instead of first convert to integer and then to string via valstr?
Re: is it possible to direct change a float to a string? -
Glad2BeHere - 28.01.2013
pawn Код:
new Float: X, Float: Y, Float: Z, Float:a, string[256];
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, a);
format(string, sizeof(string) "X: %f, Y: %f, Z: %f, A: %f", X,Y,Z, a);
Is this what u mean
Re: is it possible to direct change a float to a string? -
Frede - 28.01.2013
Код:
CMD:createbiz(playerid, params[])
{
new tmp[30], tmp2[256], index;
tmp = strtok(params, index);
tmp2 = strtok(params, index);
if(isnull(tmp)) return SendClientMessage(playerid, 0xFF00AA, "Usage: /createbiz [NAME (no spaces)] [price]");
if(isnull(tmp2)) return SendClientMessage(playerid, 0xFF00AA, "Usage: /createbiz [NAME (no spaces)] [price]");
new mprice = strval(tmp2);
new File:ftw=fopen(BUSINESS_FILE_PATH, io_append);
if(ftw)
{
new mytext[256], plstring[256];
new Float:mx, Float:my, Float:mz;
GetPlayerPos(playerid, mx,my,mz);
new mworld = GetPlayerVirtualWorld(playerid);
new into = GetPlayerInterior(playerid);
new string[25];
strcat(plstring, "You have added biz: ");
strcat(mytext, tmp);
strcat(mytext, ", ");
strcat(mytext, tmp2);
strcat(mytext, ", ");
valstr(string, mx);
strcat(mytext, string);
strcat(mytext, ", ");
valstr(string, my);
strcat(mytext, string);
strcat(mytext, ", ");
valstr(string, mz);
strcat(mytext, string);
strcat(mytext, ", ");
strcat(mytext, mworld);
strcat(mytext, ", ");
strcat(mytext, into);
strcat(plstring, mytext);
SendClientMessageToAll(0xFFFFFFFF,plstring);
new mystring[30];
format(mystring, 30, "%s\r\n", mytext);
fwrite(ftw, mystring);
fclose(ftw);
return 1;
}
return 1;
}
No it is all my valstr. The values of them is a float, but valstr convert integers to strings.
I am looking after a funktion that work directly oppesit as Floatstr.
I just made it, and now i try fix it sooo...
Re: is it possible to direct change a float to a string? -
Glad2BeHere - 28.01.2013
y dont u write it in 1 straight string that thing is just confusing stract is recommended u can do a string to make things easier
y r u writing codes like that u still end up with bugs
Re: is it possible to direct change a float to a string? -
Frede - 28.01.2013
no i mean the mx, my, mz, anyway as i said im fixing all my bugs i made in this xD
Re: is it possible to direct change a float to a string? -
ikey07 - 28.01.2013
String to float = floatstr()
Float to string = format(string,sizeof(string),"%f",Float);
Re: is it possible to direct change a float to a string? -
Frede - 28.01.2013
okay thank you dude
Re: is it possible to direct change a float to a string? -
Glad2BeHere - 28.01.2013
And if u look up i kinda showed him how to float a string already
so show him an example cuz he is not 100% sure
pawn Код:
new string[256];
format(string, sizeof(string), "%f | %f | %f, | %d| %d\r\n" mx,my,mz,mworld,into);
//this is how to do it in your terms
//it is written in order of its values
Re: is it possible to direct change a float to a string? -
Frede - 28.01.2013
oh, then i misunderstood you +1 rep to you too xD