Need Help - argument type missmatch on if
#1

I got some error while I was compiling this code

pawn Код:
new string[128], gethour, getmin, getsec; //line 22663
    gettime(thour, tmin, tsec);//line 22664
    new Day, Month, Year;//line 22665
    getdate(Year, Month, Day);//line 22666
    if(thour <= 9){format(gethour, sizeof(gethour), "0%d", thour);} else {format(gethour, sizeof(gethour), "%d", thour);} //line 22667
    if(tmin <= 9){format(getmin, sizeof(getmin), "0%d", tmin);} else {format(getmin, sizeof(getmin), "%d", tmin);}
    if(tsec <= 9){format(getsec, sizeof(getsec), "0%d", tsec);} else {format(getsec, sizeof(getsec), "%d", tsec);}
    format(string, sizeof(string), "~b~~h~~h~Game Time: ~w~%s:%s:%s", gethour, getmin, getsec);
    TextDrawSetString(TimeTD, string);
This is the error,
Код:
D:\Program Files\SAMP\SAMP SERVER\zRP 0.3e\gamemodes\ZRP.pwn(22667) : error 035: argument type mismatch (argument 1)
D:\Program Files\SAMP\SAMP SERVER\zRP 0.3e\gamemodes\ZRP.pwn(22667) : error 035: argument type mismatch (argument 1)
D:\Program Files\SAMP\SAMP SERVER\zRP 0.3e\gamemodes\ZRP.pwn(22667) : error 035: argument type mismatch (argument 1)
D:\Program Files\SAMP\SAMP SERVER\zRP 0.3e\gamemodes\ZRP.pwn(22667) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Please tell my mistakes, thanks
Reply
#2

- Removed - Or that..
Reply
#3

The variable 'gethour' is an integer, and you're trying to format it as if it's a string.


Quote:
Originally Posted by Kindred
Посмотреть сообщение
Add spaces after brackets, is that your problem?

Like so
pawn Код:
{something //wrong
{ something //right

}something //wrong
} something //right
That's all I see that MIGHT be wrong with it.
The compiler ignores spaces it's just common practice to keep it neat with spaces.
Reply
#4

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
The variable 'gethour' is an integer, and you're trying to format it as if it's a string.



The compiler ignores spaces it's just common practice to keep it neat with spaces.
But I convert the thour(integer) to gethour(string) using the format right?
Reply
#5

You aren't even trying to convert it to a string by what I'm looking at.

You can easily do this:

pawn Код:
format(gethour, sizeof(gethour), "0%d", thour);
// That^ to this:
gethour = thour;
Reply
#6

Quote:
Originally Posted by Kindred
Посмотреть сообщение
You aren't even trying to convert it to a string by what I'm looking at.

You can easily do this:

pawn Код:
format(gethour, sizeof(gethour), "0%d", thour);
// That^ to this:
gethour = thour;
If I use that, if the time is 02:03:05, it will show the time like 2:3:5 not 02:03:05.

So, if I am wrong, how to convert the thour become a string?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)