Fuel texdraw shows another textdraw too
#1

I am doing a tutorial on a fuel system, and i got no errors or warnings( i have been adding from a tutorial to my gamemode), and when i enter a vehicle, i get the login screen textdraw..

This is what i have when a player enters a vehicle:

pawn Код:
if (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        new vid = GetPlayerVehicleID(playerid);
        new string[125];format(string,sizeof string,"Fuel:%i",fuel[vid]); //quickly doing a small update on fuel (so it wont jump from 100 to its real value)
        TextDrawSetString(td_fuel[playerid],string);
        TextDrawShowForPlayer(playerid,td_fuel[playerid]); //showing if an player is a driver or passenger of the ar
    } else {
        TextDrawHideForPlayer(playerid,td_fuel[playerid]); //hiding if a player isnt driving/or an passenger
    }
This is what i beleave is the main menu textdraw, it is called OnPlayerLoggin, and thats where it comes when i see it.

pawn Код:
stock ShowMainMenuGUI(playerid) {
    InsideMainMenu[playerid] = 1;
    new string[22];

    format(string, sizeof(string), "Players online: %d", Iter_Count(Player));
    TextDrawSetString(MainMenuTxtdraw[7], string);

    for(new i = 0; i < 12; i++) {
        TextDrawShowForPlayer(playerid, MainMenuTxtdraw[i]);
    }

    return 1;
}
EDIT: here is also the news:

pawn Код:
new fuel[MAX_VEHICLES]; //fuel per vehicle
forward timer_fuel_lower(); //timer for lowering the fuel value
forward timer_refuel(playerid); //timer to refuel vehicle
new isrefuelling[MAX_PLAYERS] = 0; //bool to check if player is already refuelling
new Text:td_fuel[MAX_PLAYERS]; //textdraw with fuel
I dont see why this would happen. Why the "stock ShowMainMenuGUI"? I am new to textdraw, and not very good at scripting, so please explain carefully. Thanks!
Reply
#2

Try to hide the Loggin TD when TDFuel is called .

pawn Код:
if (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        new vid = GetPlayerVehicleID(playerid);
        for( new i = 0; i < 12; i++ )
        {
            TextDrawHideForPlayer(playerid, MainMenuTextdraw[i])
        }
        new string[125];format(string,sizeof string,"Fuel:%i",fuel[vid]); //quickly doing a small update on fuel (so it wont jump from 100 to its real value)
        TextDrawSetString(td_fuel[playerid],string);
        TextDrawShowForPlayer(playerid,td_fuel[playerid]); //showing if an player is a driver or passenger of the ar
    } else {
        TextDrawHideForPlayer(playerid,td_fuel[playerid]);
        TextDrawShowForPlayer(playerid, TDLogin etc...);  //hiding if a player isnt driving/or an passenger
    }
// If not works , tell me !
Reply
#3

Did not work, the same thing again:



I have:

pawn Код:
if (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        new vid = GetPlayerVehicleID(playerid);
        new string[125];format(string,sizeof string,"Fuel:%i",fuel[vid]); //quickly doing a small update on fuel (so it wont jump from 100 to its real value)
        TextDrawSetString(td_fuel[playerid],string);
        TextDrawShowForPlayer(playerid,td_fuel[playerid]); //showing if an player is a driver or passenger of the ar
        TextDrawHideForPlayer(playerid, MainMenuTxtdraw[playerid]);
    } else {
        TextDrawHideForPlayer(playerid,td_fuel[playerid]); //hiding if a player isnt driving/or an passenger
    }
So i added the one line:
pawn Код:
TextDrawHideForPlayer(playerid, MainMenuTxtdraw[playerid]);
This is the textdraw on the login screen:



Also, when i did /rcon changemode [TheSameGmName] the login texdraw was the same as the second picture, except only the text was there, not the black background behind the text. This happend at the bottom only. Just wanted to add that incase it helps, but when i restarted completely it was like the second picture. I have no idea what to do here.
Reply
#4

1.) Use the correct textdraw types as well your using textdraws when you need playertextdraw's.
2.) Avoid using any dynamic create/destroy textdraws there is no need for this
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)