SA-MP Forums Archive
Strval, Floatstr and for text? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Strval, Floatstr and for text? (/showthread.php?tid=165691)



Strval, Floatstr and for text? - Zafire1410 - 05.08.2010

Hi, i now strval(string) is used to convert a string into an interger.. floatstr(string) to convert into a float.. but i need a function to convert it to a "text".. strval is for a vriable of type number "1,2,3,4" .. floatstr for float "243.21450" but i need a function to convert to somthing like "hidhegr12"


Re: Strval, Floatstr and for text? - Kar - 05.08.2010

floatround.

pawn Код:
floatround(Variable Here)



Re: Strval, Floatstr and for text? - Hiddos - 05.08.2010

Text basically is a string already^^

strmid could help you
https://sampwiki.blast.hk/wiki/Strmid


Re: Strval, Floatstr and for text? - Sergei - 05.08.2010

Valstr?
https://sampwiki.blast.hk/wiki/Valstr


Re: Strval, Floatstr and for text? - Kar - 05.08.2010

i dont even understand what hes saying<.<

he wants a float to a string?


Re: Strval, Floatstr and for text? - Zafire1410 - 05.08.2010

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
Text basically is a string already^^

strmid could help you
https://sampwiki.blast.hk/wiki/Strmid
ok thx soo here is my function

Код:
public MysqlCargarDato(playerid, var[])
{
    new variable[128];
    new query[128];
    new pnombre[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pnombre, sizeof(pnombre));
    format(query, sizeof(query), "SELECT %s FROM `jugadores` WHERE nombre='%s'", var, pnombre);
    mysql_query(query);
    mysql_store_result();
    mysql_fetch_row(variable);
    mysql_free_result();
    if(strcmp(var, "id", true) == 0)
    {
        pinfo[playerid][id] = strval(variable);
    }
    if(strcmp(var, "nombre", true) == 0)
    {
        pinfo[playerid][nombre] = strval(variable);
    }
    if(strcmp(var, "pass", true) == 0)
    {
        pinfo[playerid][pass] = strval(variable);
    }
    if(strcmp(var, "cedula", true) == 0)
    {
        pinfo[playerid][cedula] = strval(variable);
    }
    if(strcmp(var, "edad", true) == 0)
    {
        pinfo[playerid][edad] = strval(variable);
    }
    if(strcmp(var, "sexo", true) == 0)
    {
        pinfo[playerid][sexo] = strval(variable);
    }
    if(strcmp(var, "nivel", true) == 0)
    {
        pinfo[playerid][nivel] = strval(variable);
    }
    if(strcmp(var, "dinero", true) == 0)
    {
        pinfo[playerid][dinero] = strval(variable);
    }
    if(strcmp(var, "trabajo", true) == 0)
    {
        pinfo[playerid][trabajo] = strval(variable);
    }
    if(strcmp(var, "lic1", true) == 0)
    {
        pinfo[playerid][lic1] = strval(variable);
    }
    if(strcmp(var, "lic2", true) == 0)
    {
        pinfo[playerid][lic2] = strval(variable);
    }
    if(strcmp(var, "lic3", true) == 0)
    {
        pinfo[playerid][lic3] = strval(variable);
    }
    if(strcmp(var, "lic4", true) == 0)
    {
        pinfo[playerid][lic4] = strval(variable);
    }
    if(strcmp(var, "lic5", true) == 0)
    {
        pinfo[playerid][lic5] = strval(variable);
    }
    if(strcmp(var, "admin", true) == 0)
    {
        pinfo[playerid][admin] = strval(variable);
    }
    if(strcmp(var, "phone", true) == 0)
    {
        pinfo[playerid][phone] = strval(variable);
    }
    if(strcmp(var, "banco", true) == 0)
    {
        pinfo[playerid][banco] = strval(variable);
    }
    if(strcmp(var, "skin", true) == 0)
    {
        pinfo[playerid][skin] = strval(variable);
    }
    if(strcmp(var, "px", true) == 0)
    {
        pinfo[playerid][px] = strval(variable);
    }
    if(strcmp(var, "py", true) == 0)
    {
        pinfo[playerid][py] = strval(variable);
    }
    if(strcmp(var, "pz", true) == 0)
    {
        pinfo[playerid][pz] = strval(variable);
    }
    if(strcmp(var, "vida", true) == 0)
    {
        pinfo[playerid][vida] = strval(variable);
    }
    if(strcmp(var, "armor", true) == 0)
    {
        pinfo[playerid][armor] = strval(variable);
    }
    if(strcmp(var, "spawned", true) == 0)
    {
        pinfo[playerid][spawned] = strval(variable);
    }
}
if the string is already a text i need only to change this for example?

Код:
    mysql_fetch_row(variable);
to this??

Код:
    mysql_fetch_row(pinfo[playerid][name]);



Re: Strval, Floatstr and for text? - Hiddos - 05.08.2010

I guess keep it that way?
pinfo[playerid][name] is already a string


Re: Strval, Floatstr and for text? - Zafire1410 - 05.08.2010

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
I guess keep it that way?
pinfo[playerid][name] is already a string
Ok.. i use this to take data from mysql and store in a variable like an INTEGER

Код:
    new variable[128];
    new query[128];
    new pnombre[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pnombre, sizeof(pnombre));
    format(query, sizeof(query), "SELECT %s FROM `jugadores` WHERE nombre='%s'", var, pnombre);
    mysql_query(query);
    mysql_store_result();
    mysql_fetch_row(variable);
    mysql_free_result();
    if(strcmp(var, "id", true) == 0)
    {
        pinfo[playerid][id] = strval(variable);
    }
but if i dont need to convert anything i se te mysql_fetch_row with the variablee direct??!.. example mysql_fetch_row(pinfo[playerid][name])


Re: Strval, Floatstr and for text? - Zafire1410 - 05.08.2010

OK i fix it.. here is my code

Код:
public MysqlCargarDato(playerid, var[])
{
    new variable[128];
    new query[128];
    new pnombre[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pnombre, sizeof(pnombre));
    format(query, sizeof(query), "SELECT %s FROM `jugadores` WHERE nombre='%s'", var, pnombre);
    mysql_query(query);
    mysql_store_result();
    if(strcmp(var, "id", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][id] = strval(variable);
    }
    if(strcmp(var, "nombre", true) == 0)
    {
        mysql_fetch_row(pinfo[playerid][nombre]);
    }
    if(strcmp(var, "pass", true) == 0)
    {
        mysql_fetch_row(pinfo[playerid][pass]);
    }
    if(strcmp(var, "cedula", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][cedula] = strval(variable);
    }
    if(strcmp(var, "edad", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][edad] = strval(variable);
    }
    if(strcmp(var, "sexo", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][sexo] = strval(variable);
    }
    if(strcmp(var, "nivel", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][nivel] = strval(variable);
    }
    if(strcmp(var, "dinero", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][dinero] = strval(variable);
    }
    if(strcmp(var, "trabajo", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][trabajo] = strval(variable);
    }
    if(strcmp(var, "lic1", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][lic1] = strval(variable);
    }
    if(strcmp(var, "lic2", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][lic2] = strval(variable);
    }
    if(strcmp(var, "lic3", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][lic3] = strval(variable);
    }
    if(strcmp(var, "lic4", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][lic4] = strval(variable);
    }
    if(strcmp(var, "lic5", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][lic5] = strval(variable);
    }
    if(strcmp(var, "admin", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][admin] = strval(variable);
    }
    if(strcmp(var, "phone", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][phone] = strval(variable);
    }
    if(strcmp(var, "banco", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][banco] = strval(variable);
    }
    if(strcmp(var, "skin", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][skin] = strval(variable);
    }
    if(strcmp(var, "px", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][px] = strval(variable);
    }
    if(strcmp(var, "py", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][py] = strval(variable);
    }
    if(strcmp(var, "pz", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][pz] = strval(variable);
    }
    if(strcmp(var, "vida", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][vida] = strval(variable);
    }
    if(strcmp(var, "armor", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][armor] = strval(variable);
    }
    if(strcmp(var, "spawned", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][spawned] = strval(variable);
    }
    mysql_free_result();
}
i use thiss for example for an interger

Код:
    if(strcmp(var, "spawned", true) == 0)
    {
        mysql_fetch_row(variable);
        pinfo[playerid][spawned] = strval(variable);
    }
and if a string i dont need to use strval so i use this

Код:
    if(strcmp(var, "pass", true) == 0)
    {
        mysql_fetch_row(pinfo[playerid][pass]);
    }