inputtext to a variable problem
#1

Hello,
How save a string from inputtext to variable?
Code:
pawn Код:
strcat(Player[playerid][cClanNameForCreate], inputtext);
           
            printf("D1. %s",inputtext);
            printf("D2. %s",Player[playerid][cClanNameForCreate]);
Log:
pawn Код:
[23:53:10] D1. SdSDS
[23:53:10] D2.
Reply
#2

In the 'Player' enum change "cClanNameForCreate" to "cClanNameForCreate[50]"
Reply
#3

Quote:
Originally Posted by K0P
Посмотреть сообщение
In the 'Player' enum change "cClanNameForCreate" to "cClanNameForCreate[50]"
Does not work.

Quote:
Originally Posted by Axxe
Посмотреть сообщение
Код:
//new string[] ..
strcat(string, inputtext);

Player[playerid][cClanNameForCreate] = string; //The size of the array(cClanNameForCreate) and the string should be the same.
Worked.

But:

Code:
pawn Код:
Player[playerid][cClanNamePlayer] = Player[playerid][cClanNameForCreate];
printf("1. %s",Player[playerid][cClanNamePlayer]);
printf("2. %s",Player[playerid][cClanNameForCreate]);
Log:
[00:12:52] 1. 2
[00:12:52] 2. 2sDSAfgasfghhh
Reply
#4

Код:
new bla[50];
format(bla,sizeof(bla),"%s",inputtext);
Player[playerid][cClanNameForCreate] = bla;
Reply
#5

That's not how you're supposed to copy strings.

Reset the string, and then use strcat.
If it's in an enum, you have to enter the size.

Код:
Player[playerid][cClanNameForCreate][0] = '\0'; // Resetting
strcat(Player[playerid][cClanNameForCreate], inputtext, SIZE HERE);
Or you can use this macro:
Код:
#define strcpy(%0,%1) strcat((%0[0] = '\0', %0), %1)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)