inputtext to a variable problem - 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: inputtext to a variable problem (
/showthread.php?tid=612430)
inputtext to a variable problem -
MRM - 17.07.2016
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.
Re: inputtext to a variable problem -
K0P - 17.07.2016
In the 'Player' enum change "cClanNameForCreate" to "cClanNameForCreate[50]"
Re: inputtext to a variable problem -
MRM - 17.07.2016
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
Re: inputtext to a variable problem -
sampkinq - 17.07.2016
Код:
new bla[50];
format(bla,sizeof(bla),"%s",inputtext);
Player[playerid][cClanNameForCreate] = bla;
Re: inputtext to a variable problem -
Stinged - 17.07.2016
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)