SA-MP Forums Archive
Problem with assigning an integer to the query - 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: Problem with assigning an integer to the query (/showthread.php?tid=577363)



Problem with assigning an integer to the query - DarkLored - 11.06.2015

Hello, I have been trying to figure out how to get a player to write his Integer for a skin that he wants but I am having trouble figuring it out, I have tried a few different ways but I can't seem to find a good way to do it.

Here is my code:

pawn Код:
if(dialogid == selectskin)
    {
        if(response)
        {
            new skinselected[MAX_PLAYERS]; //If I remove MAX PLAYERS it will give me an error claiming it must be assigned to a variable
            format(skinselected, 100, "%d", inputtext);
            if(strlen(skinselected) <= 100)
            {
                new string[128], Query[256];
                format(string, sizeof(string), "You have chosen skin %d.", skinselected);
                SendClientMessage(playerid, -1, string);
                format(Query, sizeof(Query), "UPDATE users SET skin = %d WHERE username = '%s'", pInfo[playerid][USER_SKIN], DB_Escape(pInfo[playerid][USER_NAME]));
                db_query(Database, Query);
            }
        }
    }



Re: Problem with assigning an integer to the query - Banana_Ghost - 11.06.2015

If you're trying to get a numeric value from the input text, use strval
PHP код:
if(dialogid == selectskin)
{
    if(
response)
    {
        if(
strval(inputtext) <= 100)
        {
            new 
string[128], Query[256];
            
format(stringsizeof(string), "You have chosen skin %d."strval(inputtext));
            
SendClientMessage(playerid, -1string);
            
format(Querysizeof(Query), "UPDATE users SET skin = %d WHERE username = '%s'"pInfo[playerid][USER_SKIN], DB_Escape(pInfo[playerid][USER_NAME]));
            
db_query(DatabaseQuery);
        }
    }




Re: Problem with assigning an integer to the query - DarkLored - 11.06.2015

Thanks it worked, really appreciated the help.