SA-MP Forums Archive
Inputtext 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 problem (/showthread.php?tid=597577)



Inputtext problem - Wex56 - 02.01.2016

Ok, so I tried to make something like police monitor and there I used select textdraw and other stuff, that doesn't matter right now.I have problem with geting string from dialog.I tried using inputtext and I'am getting errors so here is what I have done by now.
Код:
if(dialogid == DIALOG_RECORD)
    {
        if(response)
        {
            new id[MAX_PLAYERS], h, m, s, Name[MAX_PLAYER_NAME];
 
            gettime(h,m,s);
			RPName(playerid, Name);
			SCM(playerid, GRAD2, "_______________| {FFFFFF}MONITOR {BFC0C2}|_______________");
			format(CmdString, sizeof CmdString, "	Name: %s", CrimeInfo[inputtext][cDone]);
			SCM(playerid, WHITE, CmdString);
			format(CmdString, sizeof CmdString, "	Crime: %s", CrimeInfo[inputtext][cCrime]);
			SCM(playerid, WHITE, CmdString);
			format(CmdString, sizeof CmdString, "	Reported: %s", CrimeInfo[inputtext][cReported]);
			SCM(playerid, WHITE, CmdString);
			format(CmdString, sizeof CmdString, "	Your name: %s", hIme);
			SCM(playerid, WHITE, CmdString);
			format(CmdString, sizeof CmdString, "________________________________|{FFFFFF}%d:%d{BFC0C2}|__", h, m);
			SCM(playerid, WHITE, CmdString);
        }
If you need something else just post!


Re: Inputtext problem - IceBilizard - 02.01.2016

show the function or enum of CrimeInfo


Re: Inputtext problem - Wex56 - 02.01.2016

Here you go
Код:
enum crInfo
{
	cDone[MAX_PLAYER_NAME],
	cReported[MAX_PLAYER_NAME],
	cCrime[64],
};
new CrimeInfo[MAX_PLAYERS][crInfo];



Re: Inputtext problem - Lucky13 - 02.01.2016

I have a question: What you have to type in that dialog? the playerid or name?


Re: Inputtext problem - IceBilizard - 02.01.2016

try this
PHP код:
enum crInfo
{
    
cDone,
    
cReported,
    
cCrime[64],
};
new 
CrimeInfo[MAX_PLAYERS][crInfo];
if(
dialogid == DIALOG_RECORD)
{
        if(
response)
        {
            new 
ID strval(inputtext);
            new 
id[MAX_PLAYERS], hmsName[MAX_PLAYER_NAME];
            
gettime(h,m,s);
            
RPName(playeridName);
            
SCM(playeridGRAD2"_______________| {FFFFFF}MONITOR {BFC0C2}|_______________");
            
format(CmdStringsizeof CmdString"    Name: %s"CrimeInfo[ID][cDone]);
            
SCM(playeridWHITECmdString);
            
format(CmdStringsizeof CmdString"    Crime: %s"CrimeInfo[ID][cCrime]);
            
SCM(playeridWHITECmdString);
            
format(CmdStringsizeof CmdString"    Reported: %s"CrimeInfo[ID][cReported]);
            
SCM(playeridWHITECmdString);
            
format(CmdStringsizeof CmdString"    Your name: %s"hIme);
            
SCM(playeridWHITECmdString);
            
format(CmdStringsizeof CmdString"________________________________|{FFFFFF}%d:%d{BFC0C2}|__"hm);
            
SCM(playeridWHITECmdString);
        }




Re: Inputtext problem - Wex56 - 02.01.2016

Quote:
Originally Posted by Lucky13
Посмотреть сообщение
I have a question: What you have to type in that dialog? the playerid or name?
When dialog pop out I have to enter player name

Quote:
Originally Posted by IceBilizard
Посмотреть сообщение
try this
PHP код:
enum crInfo
{
    
cDone,
    
cReported,
    
cCrime[64],
};
new 
CrimeInfo[MAX_PLAYERS][crInfo];
if(
dialogid == DIALOG_RECORD)
{
        if(
response)
        {
            new 
ID strval(inputtext);
            new 
id[MAX_PLAYERS], hmsName[MAX_PLAYER_NAME];
            
gettime(h,m,s);
            
RPName(playeridName);
            
SCM(playeridGRAD2"_______________| {FFFFFF}MONITOR {BFC0C2}|_______________");
            
format(CmdStringsizeof CmdString"    Name: %s"CrimeInfo[ID][cDone]);
            
SCM(playeridWHITECmdString);
            
format(CmdStringsizeof CmdString"    Crime: %s"CrimeInfo[ID][cCrime]);
            
SCM(playeridWHITECmdString);
            
format(CmdStringsizeof CmdString"    Reported: %s"CrimeInfo[ID][cReported]);
            
SCM(playeridWHITECmdString);
            
format(CmdStringsizeof CmdString"    Your name: %s"hIme);
            
SCM(playeridWHITECmdString);
            
format(CmdStringsizeof CmdString"________________________________|{FFFFFF}%d:%d{BFC0C2}|__"hm);
            
SCM(playeridWHITECmdString);
        }

It's not working.There is no errors but when I type in name or ID in dialog it just show me blank text just like it did before.And as I know "strval" is used to convert string to integer


Re: Inputtext problem - Lucky13 - 02.01.2016

Try this one:

Код:
enum crInfo 
{ 
    cDone, 
    cReported, 
    cCrime[64], 
}; 
new CrimeInfo[MAX_PLAYERS][crInfo]; 


if(dialogid == DIALOG_RECORD) 
{ 
        if(response) 
        { 
            new pid = strval(inputtext); 
            new h, m, s, Name[MAX_PLAYER_NAME]; 

            gettime(h,m,s); 
            RPName(playerid, Name); 
            SCM(playerid, GRAD2, "_______________| {FFFFFF}MONITOR {BFC0C2}|_______________"); 
            format(CmdString, sizeof CmdString, "    Name: %s", CrimeInfo[pid][cDone]); 
            SCM(playerid, WHITE, CmdString); 
            format(CmdString, sizeof CmdString, "    Crime: %s", CrimeInfo[pid][cCrime]); 
            SCM(playerid, WHITE, CmdString); 
            format(CmdString, sizeof CmdString, "    Reported: %s", CrimeInfo[pid][cReported]); 
            SCM(playerid, WHITE, CmdString); 
            format(CmdString, sizeof CmdString, "    Your name: %s", hIme); 
            SCM(playerid, WHITE, CmdString); 
            format(CmdString, sizeof CmdString, "________________________________|{FFFFFF}%d:%d{BFC0C2}|__", h, m); 
            SCM(playerid, WHITE, CmdString); 
        } 
}



Re: Inputtext problem - Wex56 - 03.01.2016

Quote:
Originally Posted by Lucky13
Посмотреть сообщение
Try this one:

Код:
enum crInfo 
{ 
    cDone, 
    cReported, 
    cCrime[64], 
}; 
new CrimeInfo[MAX_PLAYERS][crInfo]; 


if(dialogid == DIALOG_RECORD) 
{ 
        if(response) 
        { 
            new pid = strval(inputtext); 
            new h, m, s, Name[MAX_PLAYER_NAME]; 

            gettime(h,m,s); 
            RPName(playerid, Name); 
            SCM(playerid, GRAD2, "_______________| {FFFFFF}MONITOR {BFC0C2}|_______________"); 
            format(CmdString, sizeof CmdString, "    Name: %s", CrimeInfo[pid][cDone]); 
            SCM(playerid, WHITE, CmdString); 
            format(CmdString, sizeof CmdString, "    Crime: %s", CrimeInfo[pid][cCrime]); 
            SCM(playerid, WHITE, CmdString); 
            format(CmdString, sizeof CmdString, "    Reported: %s", CrimeInfo[pid][cReported]); 
            SCM(playerid, WHITE, CmdString); 
            format(CmdString, sizeof CmdString, "    Your name: %s", hIme); 
            SCM(playerid, WHITE, CmdString); 
            format(CmdString, sizeof CmdString, "________________________________|{FFFFFF}%d:%d{BFC0C2}|__", h, m); 
            SCM(playerid, WHITE, CmdString); 
        } 
}
It's same thing that IceBilizard has done.

Strval is used to convert string to integer


Re: Inputtext problem - Lucky13 - 03.01.2016

Quote:
Originally Posted by Wex56
Посмотреть сообщение
It's same thing that IceBilizard has done.

Strval is used to convert string to integer
IceBilizard's:
Код:
enum crInfo 
{ 
    cDone, 
    cReported, 
    cCrime[64], 
}; 
new CrimeInfo[MAX_PLAYERS][crInfo]; 


if(dialogid == DIALOG_RECORD) 
{ 
        if(response) 
        { 
            new ID = strval(inputtext); 
            new id[MAX_PLAYERS], h, m, s, Name[MAX_PLAYER_NAME]; 

            gettime(h,m,s); 
            RPName(playerid, Name); 
            SCM(playerid, GRAD2, "_______________| {FFFFFF}MONITOR {BFC0C2}|_______________"); 
            format(CmdString, sizeof CmdString, "    Name: %s", CrimeInfo[ID][cDone]); 
            SCM(playerid, WHITE, CmdString); 
            format(CmdString, sizeof CmdString, "    Crime: %s", CrimeInfo[ID][cCrime]); 
            SCM(playerid, WHITE, CmdString); 
            format(CmdString, sizeof CmdString, "    Reported: %s", CrimeInfo[ID][cReported]); 
            SCM(playerid, WHITE, CmdString); 
            format(CmdString, sizeof CmdString, "    Your name: %s", hIme); 
            SCM(playerid, WHITE, CmdString); 
            format(CmdString, sizeof CmdString, "________________________________|{FFFFFF}%d:%d{BFC0C2}|__", h, m); 
            SCM(playerid, WHITE, CmdString); 
        } 
}
Mine:
Код:
enum crInfo 
{ 
    cDone, 
    cReported, 
    cCrime[64], 
}; 
new CrimeInfo[MAX_PLAYERS][crInfo]; 


if(dialogid == DIALOG_RECORD) 
{ 
        if(response) 
        { 
            new pid = strval(inputtext); 
            new h, m, s, Name[MAX_PLAYER_NAME]; 

            gettime(h,m,s); 
            RPName(playerid, Name); 
            SCM(playerid, GRAD2, "_______________| {FFFFFF}MONITOR {BFC0C2}|_______________"); 
            format(CmdString, sizeof CmdString, "    Name: %s", CrimeInfo[pid][cDone]); 
            SCM(playerid, WHITE, CmdString); 
            format(CmdString, sizeof CmdString, "    Crime: %s", CrimeInfo[pid][cCrime]); 
            SCM(playerid, WHITE, CmdString); 
            format(CmdString, sizeof CmdString, "    Reported: %s", CrimeInfo[pid][cReported]); 
            SCM(playerid, WHITE, CmdString); 
            format(CmdString, sizeof CmdString, "    Your name: %s", hIme); 
            SCM(playerid, WHITE, CmdString); 
            format(CmdString, sizeof CmdString, "________________________________|{FFFFFF}%d:%d{BFC0C2}|__", h, m); 
            SCM(playerid, WHITE, CmdString); 
        } 
}
See the difference? You define 2 times ( one time an integer & one time a string ) the same variable in IceBilizard's.

Did you test mine at least?


Re: Inputtext problem - vannesenn - 03.01.2016

Код:
if(dialogid == DIALOG_RECORD)
    {
        if(response)
        {
            new id, h, m, s, Name[MAX_PLAYER_NAME];
 
            gettime(h,m,s);
			RPName(playerid, Name);
			SCM(playerid, GRAD2, "_______________| {FFFFFF}MONITOR {BFC0C2}|_______________");
			format(CmdString, sizeof CmdString, "	Name: %s", CrimeInfo[id][cDone]);
			SCM(playerid, WHITE, CmdString);
			format(CmdString, sizeof CmdString, "	Crime: %s", CrimeInfo[id][cCrime]);
			SCM(playerid, WHITE, CmdString);
			format(CmdString, sizeof CmdString, "	Reported: %s", CrimeInfo[id][cReported]);
			SCM(playerid, WHITE, CmdString);
			format(CmdString, sizeof CmdString, "	Your name: %s", hIme);
			SCM(playerid, WHITE, CmdString);
			format(CmdString, sizeof CmdString, "________________________________|{FFFFFF}%d:%d{BFC0C2}|__", h, m);
			SCM(playerid, WHITE, CmdString);
        }