Dialog inputtext help! -
Flyfishes - 23.11.2010
Hai. I'm trying to make the inputtext from a msgbox dialog to go into a function. But I get an error.
Код:
C:\nothing.dll(307) : error 035: argument type mismatch (argument 2)
Код:
SendRaceRequest(playerid, inputtext);
Re: Dialog inputtext help! -
Zh3r0 - 23.11.2010
Can you please show me where you used it and let me see the stock.
The code
SendRaceRequest(playerid, inputtext); has.
Re: Dialog inputtext help! -
[MWR]Blood - 23.11.2010
Most likely you will have to replace 'inputtext' with a message...
Re: Dialog inputtext help! -
Zh3r0 - 23.11.2010
Quote:
Originally Posted by Delux13
Most likely you will have to replace 'inputtext' with a message...
|
Actually that would give Undefined symbol error
Also, why did you hide the directory? We don't know if it is from include or gm.
Re: Dialog inputtext help! -
Flyfishes - 23.11.2010
Gamemode..
Код:
else if(dialogid == 3)
{
if(!response)
{
SendClientMessage(playerid, COLOR_GREY, "[Error:] You have cancelled the request!");
}
if (!strlen(inputtext))
{
ShowPlayerDialogEx(playerid, 3);
}
SendRaceRequest(playerid, inputtext);
}
Код:
public SendRaceRequest(playerid, toid)
{
if(IsPlayerConnected(toid))
{
if(InRace[toid] == 0)
{
new racer[MAX_PLAYER_NAME+60];
format(racer, sizeof(racer), "[Race:] %s (ID:%d) wants to challenge you in a race.", PlayerName(playerid), playerid);
SendClientMessage(toid, COLOR_WHITE, racer);
SendClientMessage(toid, COLOR_WHITE, "[Race:] Use /accept race to accept the challenge!");
SendClientMessage(playerid, COLOR_WHITE, "[Info:] Successfully sent a request to the other player!");
}
else
{
SendClientMessage(playerid, COLOR_GREY, "[Error:] The other player is already in a race!");
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "[Error:] The other player is not connected!");
}
return 1;
}
Re: Dialog inputtext help! -
TheXIII - 23.11.2010
toid = integer
inputtext = string
Re: Dialog inputtext help! -
Flyfishes - 23.11.2010
And how to solve it then?
Re: Dialog inputtext help! -
Zh3r0 - 23.11.2010
Quote:
Originally Posted by Flyfishes
And how to solve it then?
|
use strval( inputtext ) and IsNumeric
So a string doesn't get inserted in inputtext.
@RealCop, thast would change the whole structure of SendRaceRequest
Re: Dialog inputtext help! -
Scenario - 23.11.2010
Quote:
Originally Posted by Zh3r0
use strval( inputtext ) and IsNumeric
So a string doesn't get inserted in inputtext.
@RealCop, thast would change the whole structure of SendRaceRequest
|
I just reviewed his stock function and noticed it would of messed up the whole function, thanks for pointing that out!
Re: Dialog inputtext help! -
Flyfishes - 23.11.2010
Quote:
Originally Posted by Zh3r0
use strval( inputtext ) and IsNumeric
So a string doesn't get inserted in inputtext.
@RealCop, thast would change the whole structure of SendRaceRequest
|
So like:
Код:
new monkey = strval(inputtext);
and then an if statement with isnumeric?
Re: Dialog inputtext help! -
Flyfishes - 23.11.2010
Using strval in my example gave an error, how to do it?
Код:
C:\nothing.dll(325) : error 035: argument type mismatch (argument 1)
My code:
Код:
else if(dialogid == 3)
{
if(!response)
{
SendClientMessage(playerid, COLOR_GREY, "[Error:] You have cancelled the request!");
}
if (!strlen(inputtext))
{
ShowPlayerDialogEx(playerid, 3);
}
new inputtex = strval(inputtext);
if(IsNumeric(inputtex))
{
SendRaceRequest(playerid, inputtex);
}
}
where line 325:
EDIT: Sorry for doublepost! :/
Re: Dialog inputtext help! -
Jochemd - 23.11.2010
Actually you do not have to use IsNumeric when using strval(inputtext), cause strval makes the string numeric...
Re: Dialog inputtext help! -
Flyfishes - 23.11.2010
Ahh fuck. I love you Jochemd! I'll send a cookie via the mail to you.
Thanks for all help guys. Now can I proceed with my script. <3<3<3
Re: Dialog inputtext help! -
Jochemd - 23.11.2010
No problem :P
Re: Dialog inputtext help! -
Zh3r0 - 23.11.2010
Quote:
Originally Posted by Jochemd
No problem :P
|
Actually it is, IsNumeric it's not for converting a string to integer, it checks if the input is numeric!
Insert ABCD, and using strval on the ABCD string may result in a strange long number.
So i suggest you to use IsNumeric, because the one who is gonna send you the Race Reqeust, he might wanna insert
3e by accident. So guess what happens. Error, or crash.
Here , use this.
pawn Код:
else if(dialogid == 3)
{
if ( response ){
if ( !IsNumeric ( inputtext ) ) return SendClientMessage(...); //ERROR No-Number inserted.
if ( !strlen ( inputtext ) ) return ShowPlayerDialogEx(playerid, 3);}
else SendClientMessage(playerid, COLOR_GREY, "[Error:] You have cancelled the request!");
}
You can also try using sscanf, which will check if the player is connected, and it will ease your job by almost 60%.
Re: Dialog inputtext help! -
Jochemd - 23.11.2010
Yes, that code is better. I have not read all the posts, only he had a problem with IsNumeric (I saw he was using strval before, so it was useless)
Re: Dialog inputtext help! -
Zh3r0 - 23.11.2010
Quote:
Originally Posted by Jochemd
Yes, that code is better. I have not read all the posts, only he had a problem with IsNumeric (I saw he was using strval before, so it was useless)
|
Also, he spelled inputtext wrong! This can be cause the error too!
IsNumeric it's never useless, until you use a string, with EX:"Hello Word" and not just a number, integer.
Re: Dialog inputtext help! -
Jochemd - 23.11.2010
As you see he did this
pawn Код:
new inputtex = strval(inputtext);
Re: Dialog inputtext help! -
Zh3r0 - 23.11.2010
Quote:
Originally Posted by Jochemd
As you see he did this
pawn Код:
new inputtex = strval(inputtext);
|
I get what you mean, and if the text inserted is "ABD123#!@$", show me what's the result using strval please.
With IsNumeric you can check instantly if the input is numeric and show the dialog again.