Insert a string into a variable
#1

Ergh.. It's late and I am forgetting the simplest of all things.. Ahh..

How would I put 'inputtext' into 'Businessname'?

example
pawn Код:
Business[playerid][bName] = inputtext;
As the line above produces this error
Код:
error 047: array sizes do not match, or destination array is too small
Reply
#2

Use format

Ex:
pawn Код:
format(Business[playerid][bName],sizeof Business[playerid][bName], "%s", inputtext);
Reply
#3

Ahh of course, Cheers.

This gave me too many errors
pawn Код:
format(Business[playerid][bName],sizeof Business[playerid][bName], "%s", inputtext);
So I just used this instead
pawn Код:
format(Business[playerid][bName],50,inputtext);
Also when checking if the input was empty, how would I do that?

This gives me an error but must be something similar
pawn Код:
if(!strcmp(inputtext, 0, false))
                {
                    SendClientMessage(playerid, COLOR_GREY, "Please insert a name or return to the menu.");
                }
Guess I'd just use
pawn Код:
if(isnull(inputtext))
                {
                    SendClientMessage(playerid, COLOR_GREY, "Please insert a name or return to the menu.");
                }
Reply
#4

Use strcat() instead of the format method, works better. (had problems myself with format)

Also, to check the input: strlen().
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)