Problem with assigning an integer to the query
#1

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);
            }
        }
    }
Reply
#2

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);
        }
    }

Reply
#3

Thanks it worked, really appreciated the help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)