SA-MP Forums Archive
Argument type mismatch - 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: Argument type mismatch (/showthread.php?tid=354079)



Argument type mismatch - Jstylezzz - 25.06.2012

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


Re: Argument type mismatch - iggy1 - 25.06.2012

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


Re: Argument type mismatch - JaTochNietDan - 25.06.2012

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


Re: Argument type mismatch - Jstylezzz - 25.06.2012

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


Re: Argument type mismatch - ViniBorn - 25.06.2012

Is 'Fuel' a float number ?


Re: Argument type mismatch - JaTochNietDan - 25.06.2012

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);



Re: Argument type mismatch - Jstylezzz - 25.06.2012

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


Re: Argument type mismatch - ViniBorn - 25.06.2012

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



Re: Argument type mismatch - Jstylezzz - 26.06.2012

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