PROBLEM WITH DIALOG_STYLE_INPUT
#1

Код:
if(dialogid==MENUCARROS2){

				if(response==1){
					new num;
                                        new string[5];
                                        format(string,sizeof(string),"%d",inputtext);
  					num=strval(string);
						if(num  == strval(string)){
   							GetPlayerPos(playerid,x,y,z);
							CreateVehicle(num, x+2,y+2,z, 0, 0, 0, 6000);
}
}
}
I've got the next problem, i want know їWhy dont works this code IN THE TOP? and this code does works ON THE DOWN .

Код:
if(dialogid==MENUCARROS2){

				if(response==1){
					new num;
                                                                  
  					num=strval(inputtext);
						if(num  == strval(inputtext)){
   							GetPlayerPos(playerid,x,y,z);
							CreateVehicle(num, x+2,y+2,z, 0, 0, 0, 6000);
}
}
}
Reply
#2

What are you trying to check there?

Actually you check
PHP код:
if == 
Reply
#3

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
What are you trying to check there?

Actually you check
PHP код:
if == 
Hey, i'm new in the world of the pawn language, just i need that you answer me the problem that i present.


The conclusion that i think is the 'format' just take variables and inputtext not is a variable.

Correct me please, if i'm wrong.
Reply
#4

Both are Variables.

Actually Array Variables, that are used in that case for string storing.

Here is a good Tutorial for you: https://sampforum.blast.hk/showthread.php?tid=654471

With strval you convert that string to an integer.

And format with %d tries to interpret the Variable like an Integer.

So if you pass an A it gets to 65, because ASCII Values are taken.

So in that case you should directly use strval(inputtext), to get the integer values (if that is your target).

I dont know why the first one is not working, you can check that easily out.

Just make:

PHP код:
printf("%d == %d",num,strval(string)); 
Before the if.

Then you know, what the exact values are and why it is not working
Reply
#5

PHP код:
new string[5];
format(string,sizeof(string),"%d",inputtext); 
This doesnt work cus inputtext is string yet you try to format it using integer format

PHP код:
new string[5];
 
format(string,sizeof(string),"%s",inputtext); 
Reply
#6

thank you mate ♥♥♥♥♥♥!
Reply
#7

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
What are you trying to check there?

Actually you check
PHP код:
if == 
You forgot a colon.

Oh sorry I thought you were coding in python.

You need brackets in an if statement in pawn lang, don't make him grasp wrong stuff.
Reply
#8

Its obviously nothing, but Pseudo-Code.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)