String Bug with TextDraws
#1

Good Morning,

I've been busy working on a GUI for my vehicle system, and I recently uncovered a bug regarding the fuel...
I'm not too sure whether or not it's a String bug or some common bug that I'm unaware of, but if anyone recognizes this, it would be a great deal of relief to know the solution!



As you see, the fuel is exponentially large, although in the script it's max is 100.

I won't be giving away any of the code unless it's needed, because I think it has to do with the string.

Thanks!

[EDIT]:

Here is the code, because I understand how difficult it can be without getting a picture in your head.

pawn Код:
new speedstring[20],locationstring[56],fuelstring[56];
format(speedstring, sizeof(speedstring), "%i MPH", GetVehicleSpeed(GetPlayerVehicleID(playerid), true));
PlayerTextDrawSetString(playerid, Speed, speedstring);
format(locationstring, sizeof(locationstring), "%s", GetPlayer3DZone(playerid));
PlayerTextDrawSetString(playerid, Location, locationstring);
Fuel[vehicleid] -= GetPlayerSpeed(playerid)/1000.0;
format(fuelstring, sizeof(fuelstring), "%i/100", Fuel[vehicleid]);
PlayerTextDrawSetString(playerid, FuelAmount, fuelstring);
That is all under OnPlayerUpdate(); of course.
Reply
#2

Change %d in format to %.0f
Reply
#3

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Change %d in format to %.0f
Thank you so much! Definitely solved that issue!
Reply
#4

I am wondering... why do you have that under OnPlayerUpdate?
OnPlayerUpdate is called everything you press 1 key which performs something in-game.
So, in 10 seconds, for active gamers, OnPlayerUpdate can be called 100 times, making 100 times the updates of the textdraws[sending the packet from server to client] and vice-versa, it can create lag.
Create a timer, which updates every 2 seconds, it would be better for this, really.

@Edit, just noticed that your issue was been resolved, however, think about the timer.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)