Argument type mismatch
#1

Hi everyone,

I have a problem, that explains is self i gues..

The error is:
pawn Код:
error 035: argument type mismatch (argument 2)
And this is the error line:
pawn Код:
TextDrawSetString(fuelvalue[playerid], Fuel[vehicleid]/4.0);
I don't understand what the problem is here...
Reply
#2

The second argument in your function is an int by the looks of it. It should be a string.
Reply
#3

You're trying to insert an integer/float where TextDrawSetString's second parameter requires a string, so you need to format it as a string first before entering it, for example:

pawn Код:
new string[10];
format(string, sizeof(string), "%i", Fuel[vehicleid]/4.0);

TextDrawSetString(fuelvalue[playerid], string);
Make sure you read the documentation on functions before using them so you understand what they require:
https://sampwiki.blast.hk/wiki/TextDrawSetString
Reply
#4

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
You're trying to insert an integer/float where TextDrawSetString's second parameter requires a string, so you need to format it as a string first before entering it, for example:

pawn Код:
new string[10];
format(string, sizeof(string), "%i", Fuel[vehicleid]/4.0);

TextDrawSetString(fuelvalue[playerid], string);
Make sure you read the documentation on functions before using them so you understand what they require:
https://sampwiki.blast.hk/wiki/TextDrawSetString
I knew the function required a string, I had exact the same code as JaTochNietDan, but when i did that it just screwed up more..
it displayed a very high amount, even though the max amount it can have is 100...
It showed like 1065 or something..
I will try it again, and I hope it solves my problem
Reply
#5

Is 'Fuel' a float number ?
Reply
#6

Quote:
Originally Posted by Jari_Johnson*
Посмотреть сообщение
I knew the function required a string, I had exact the same code as JaTochNietDan, but when i did that it just screwed up more..
it displayed a very high amount, even though the max amount it can have is 100...
It showed like 1065 or something..
I will try it again, and I hope it solves my problem
If you're dealing with floats you can simply format it as a float and hide some of the decimal places so it's not stupidly long, for example:

pawn Код:
format(string, sizeof(string), "%.2f", Fuel[vehicleid]/4.0);
Reply
#7

OK, just so i don't make any mistakes, a float is multiple numbers like 12345, and a integer is just 1 number?
If yes, i've done some things wrong
Thanks for telling me this..
Fuel is 100, 99, 98, and so on.. is that a float then?
I'm feeling kinda noobish now xD
Reply
#8

Integer = 1
Float = 1.5

Integer = 15500
Float = 15500.6
pawn Код:
format(string, sizeof(string), "%.2f", Fuel[vehicleid]/4.0); // if the value of Fuel[vehicleid] is 80, the result (20) is an integer
pawn Код:
format(string, sizeof(string), "%.2f", Fuel[vehicleid]/4.0); // if the value of Fuel[vehicleid] is 90, the result (22.5) is a float
Reply
#9

Wel,l, I have done this now, and It displays the correct value, but it doesn't drop..
It's as if the textdraw things doesn't read the values or something.
the strange thing is, the fuel IS dropping, because if i set my fuel to 1 for testing, after 1 minute the engine stops and it says out of fuel, but then the textdraw is still on the full value.
Same things for my engine on/off draw, the value's are good, because they are used constantly, but the textdraws don't seem to see/use them..
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)