Speedo Problem - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Speedo Problem (
/showthread.php?tid=256826)
Speedo Problem -
ScottCFR - 22.05.2011
I'm not sure if I'm doing this right, a pointer or two would be nice. Here's the part that's erroring.
Код:
(1240) : error 035: argument type mismatch (argument 2)
(1237) : warning 204: symbol is assigned a value that is never used: "pSpeed"
forward UpdateSpeedo();
public UpdateSpeedo()
{
for(new i; i < MAX_PLAYERS; i ++)
{
new PlayerState = GetPlayerState(i);
new pSpeed = GetPlayerSpeed(i); // LINE 1237
if(PlayerState == PLAYER_STATE_DRIVER)
{
TextDrawSetString(PlayerSpeedo[i], pSpeed); // LINE 1240
}
}
return 1;
}
I have it setup on a timer to update, it shows when OnPlayerStateChange is called. Any additional tips would be nice.
(If you post to ask me to use your filterscript, NO!)
AW: Speedo Problem -
Nero_3D - 22.05.2011
Quote:
Originally Posted by ScottCFR
I'm not sure if I'm doing this right, a pointer or two would be nice. Here's the part that's erroring.
I have it setup on a timer to update, it shows when OnPlayerStateChange is called. Any additional tips would be nice.
(If you post to ask me to use your filterscript, NO!)
|
Everything alright but this isnt like VB or any other language in which the variable type gets auto converted
And its enough to have it in a timer and at the moment of the first appearance (OnPlayerStateChange)
Additionally I would create the variable before the loop, would be a waste to create / destroy it 500 (MAX_PLAYER) times
So some minor changes and done
pawn Код:
forward UpdateSpeedo();
public UpdateSpeedo()
{
for(new i, string[16]; i != MAX_PLAYERS; ++i)
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
valstr(string, GetPlayerSpeed(i), false);
TextDrawSetString(PlayerSpeedo[i], string);
}
}
}
Valstr converts an integer into a string
Re: Speedo Problem -
ScottCFR - 22.05.2011
I fixed the error, realized I wasn't formating the string before adding it to the textdraw. However the speed isn't showing right. When I'm in a car it says "0 km/h".
AW: Re: Speedo Problem -
Nero_3D - 22.05.2011
Quote:
Originally Posted by ScottCFR
I fixed the error, realized I wasn't formating the string before adding it to the textdraw. However the speed isn't showing right. When I'm in a car it says "0 km/h".
|
how does your code looks like, now ? maybe you put the wrong placeholder %f instead of %d