SA-MP Forums Archive
Textdraw - 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: Textdraw (/showthread.php?tid=248294)



Textdraw - thimo - 13.04.2011

Hey i was making something for in the car but if i do /getcar and i click on i get spawned into the car and the textdraw doesnt show.... But i though if i added this code it would be gone:
pawn Код:
forward Fly(playerid);
public Fly(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        TextDrawShowForPlayer(playerid, MyTextDraw[playerid]);
    }
    else
    {
        TextDrawHideForPlayer(playerid, MyTextDraw[playerid]);
    }
}
at OnGamemodeInit i got this timer:
pawn Код:
SetTimer("Fly", 1000, true);



Re: Textdraw - Sascha - 13.04.2011

pawn Код:
forward Fly();
public Fly()
{
    for(new playerid=0; playerid<GetMaxPlayers(); playerid++)
    {
        if(IsPlayerConnected(playerid))
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                TextDrawShowForPlayer(playerid, MyTextDraw[playerid]);
            }
            else
            {
                TextDrawHideForPlayer(playerid, MyTextDraw[playerid]);
            }
        }
    }
    return 1;
}
edit: or this:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        TextDrawShowForPlayer(playerid, MyTextDraw[playerid]);
    }
    if(newstate == PLAYER_STATE_ONFOOT)
    {
        TextDrawHideForPlayer(playerid, MyTextDraw[playerid]);
    }
    return 1;
}