Dialog inputtext help!
#1

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);
Reply
#2

Can you please show me where you used it and let me see the stock.
The code SendRaceRequest(playerid, inputtext); has.
Reply
#3

Most likely you will have to replace 'inputtext' with a message...
Reply
#4

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.
Reply
#5

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;
}
Reply
#6

toid = integer
inputtext = string
Reply
#7

And how to solve it then?
Reply
#8

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
Reply
#9

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!
Reply
#10

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?
Reply
#11

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:
Quote:

if(IsNumeric(inputtex))

EDIT: Sorry for doublepost! :/
Reply
#12

Actually you do not have to use IsNumeric when using strval(inputtext), cause strval makes the string numeric...
Reply
#13

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
Reply
#14

No problem :P
Reply
#15

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%.
Reply
#16

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)
Reply
#17

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!

pawn Код:
if(IsNumeric(inputtex))

IsNumeric it's never useless, until you use a string, with EX:"Hello Word" and not just a number, integer.
Reply
#18

As you see he did this

pawn Код:
new inputtex = strval(inputtext);
Reply
#19

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)