[Question] - How to get String from inputtext -
xRyder - 01.05.2011
I'm trying to make something like register system where you need to insert some details about you ( in dialog).
And when I come to players origins where you need to write where are you from, seems that I can't get good function to get string from inputtext. So if they write "France" it will store France as a origin....
I tried with
strval() but it will get me only the value of that string if it's a numeric...
Please give me a hint...
Thank you.
Re: [Question] - How to get String from inputtext -
Joe Staff - 01.05.2011
Inputtext IS a string. Use format to save otherwise pawno will give you some error.
Edit* lul
Re: [Question] - How to get String from inputtext -
xRyder - 01.05.2011
Yeah, I knew it was a string. But it was always giving me some errors about how my PlayerEnum was too small to write that...So..Anyways, I'll try to format it now..
Thanks!
Re: [Question] - How to get String from inputtext -
xRyder - 01.05.2011
Hmm, I tried with strcat() and now I tried with format. But I always get an error. This is what I got:
pawn Код:
//enum
PlayersOrigins[255]
//In dialog
new string[40];
//This doesn't work.
format(string, 40, "%s", inputtext);
pInfo[playerid][PlayersOrigins] = string;
// But this works.
format(string, 40, "Okay, so you are from {FFFF00}%s{FFFFFF}.",inputtext);
SendClientMessage(playerid, WHITE, string);
So what am I doing wrong?
Edit: And ******, you mention that I shouldn't use format. Why not?
Re: [Question] - How to get String from inputtext -
Donya - 01.05.2011
******, you should do a tutorial on string copying
Re: [Question] - How to get String from inputtext -
Calgon - 01.05.2011
If you read his thread on optimization, there's a section elaborating on strcpy/strcat.
Re: [Question] - How to get String from inputtext -
Hayden_Almeida - 30.08.2012
I made this:
Код:
new senhaadministracao[256];
if(response)
{
if(strlen(inputtext) == 0)
return ShowPlayerDialog(playerid, 3, DIALOG_STYLE_INPUT, "Nova senha da administraзгo","Escreva abaixo a nova senha", "Concluir", "Cancelar");
new pass[256];
new string[256];
INI_Open("server/administracao.ini");
pass = INI_ReadString("SenhaAdministracao");
INI_Close();
if(!strcmp(pass,inputtext, false))
{
ShowPlayerDialog(playerid, 3, DIALOG_STYLE_INPUT, "Nova senha da administraзгo","Escreva abaixo a nova senha", "Concluir", "Cancelar");
GameTextForPlayer(playerid, "~r~Mesma senha!",3000, 3);
SendClientMessage(playerid, COLOR_RED, "Vocк digitou a mesma senha atual, escolha outra.");
return 1;
}
else
{
format(senhaadministracao, sizeof(senhaadministracao), "%s", inputtext); // VERY IMPORTANT
SetTimer("arqadmin",4000,false); // NOT IMPORTANT
GameTextForPlayer(playerid, "~g~Concluido!",4000, 3); // NOT IMPORTANT
format(string,sizeof(string), "Vocк modificou a senha do administrador para: %s", inputtext); // NOT IMPORTANT
SendClientMessage(playerid, COLOR_GREEN, string); // NOT IMPORTANT
}
return 1;
}
// SAVING:
INI_Open("server/administracao.ini");
INI_WriteString("SenhaAdministracao", senhaadministracao);
INI_Save();
INI_Close();
If i Help you , please REP +
Thank you so much , god bless.