Don' hide textdraw
#1

Helo! I make a speedometer and is work fine, but when i exit from car is don't hide .
Код HTML:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	// intra in masina
	if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER) 
    {
     killtimer[playerid] = SetTimerEx("speed", 100, true, "i", playerid); 
    }
	// IESE DIN MASINA GATA SPEEDU
	if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT) 
    {  
	   KillTimer(killtimer[playerid]);
    }
    return 1;
}
What is wrong?
Reply
#2

You must use "TextDrawHideForPlayer( playerid, textdraw );" to hide a textdraw.
* textdraw = your textdraw name, like: "new Text:abcd;"
* here textdraw = abcd, and you must use it like:
"TextDrawHideForPlayer( playerid, abcd );"

EDIT:
* Use this to know more about it: https://sampwiki.blast.hk/wiki/TextDrawHideForPlayer.
Reply
#3

Is don't work , is still here the textdraw : SPEED : (and the last speed)
and i'm out of vehicle.
Reply
#4

First, learn english, second show us more code. Provide us to know more about your problem, if you don't know
to give us more code, you can't be helped. This is a minor problem, you just have to add the function that i said into your code at "OnPlayerStateChange", in the moment that player is on foot.

PHP код:
public OnPlayerStateChangeplayeridnewstateoldstate )
{
    if( 
oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
    {
         
killtimerplayerid ] = SetTimerEx"speed"100true"i"playerid );
    }
    if( 
oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT )
    {
       
KillTimerkilltimerplayerid ] );
       
TextDrawHideForPlayerplayeridyour_textdraw_name_for_speedometer );
       
//you just have to edit "your_textdraw_name_for_speedometer" with your TD name.
    
}
    return 
1;

Reply
#5

Look
PHP код:
new killtimerr;
new 
PlayerText:TDEditor_PTD1[MAX_PLAYERS][2];
forward speed(playerid);
public 
speed(playerid)
{
    new 
name[128];
    
format(name,sizeof(name),"%i",GetSpeed(playerid));
    
PlayerTextDrawSetString(playerid,TDEditor_PTD1[playerid][1],name);
    
PlayerTextDrawShow(playerid,TDEditor_PTD1[playerid][0]);
    
PlayerTextDrawShow(playerid,TDEditor_PTD1[playerid][1]);
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    
//  speed
    
TDEditor_PTD[playerid][0] = CreatePlayerTextDraw(playerid552.000000338.312500"speed:");
    
PlayerTextDrawLetterSize(playeridTDEditor_PTD[playerid][0], 0.4000001.600000);
    
PlayerTextDrawAlignment(playeridTDEditor_PTD[playerid][0], 3);
    
PlayerTextDrawColor(playeridTDEditor_PTD[playerid][0], -1);
    
PlayerTextDrawSetShadow(playeridTDEditor_PTD[playerid][0], 0);
    
PlayerTextDrawSetOutline(playeridTDEditor_PTD[playerid][0], 0);
    
PlayerTextDrawBackgroundColor(playeridTDEditor_PTD[playerid][0], 255);
    
PlayerTextDrawFont(playeridTDEditor_PTD[playerid][0], 1);
    
PlayerTextDrawSetProportional(playeridTDEditor_PTD[playerid][0], 1);
    
PlayerTextDrawSetShadow(playeridTDEditor_PTD[playerid][0], 0);
    
TDEditor_PTD[playerid][1] = CreatePlayerTextDraw(playerid565.000000338.312500"x");
    
PlayerTextDrawLetterSize(playeridTDEditor_PTD[playerid][1], 0.4000001.600000);
    
PlayerTextDrawAlignment(playeridTDEditor_PTD[playerid][1], 1);
    
PlayerTextDrawColor(playeridTDEditor_PTD[playerid][1], -1);
    
PlayerTextDrawSetShadow(playeridTDEditor_PTD[playerid][1], 0);
    
PlayerTextDrawSetOutline(playeridTDEditor_PTD[playerid][1], 0);
    
PlayerTextDrawBackgroundColor(playeridTDEditor_PTD[playerid][1], 255);
    
PlayerTextDrawFont(playeridTDEditor_PTD[playerid][1], 1);
    
PlayerTextDrawSetProportional(playeridTDEditor_PTD[playerid][1], 1);
    
PlayerTextDrawSetShadow(playeridTDEditor_PTD[playerid][1], 0);
        return 
1;
}
public 
OnPlayerStateChange(playeridnewstateoldstate)
{
    
// intra in masina
    
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER
    {
     
killtimerr SetTimerEx("speed"100true"i"playerid); 
    }
    
// IESE DIN MASINA GATA SPEEDU
    
if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT
    {  
       
KillTimer(killtimerr);
       
TextDrawHideForPlayer(TDEditor_PTD1[playerid][0]);
       
TextDrawHideForPlayer(TDEditor_PTD1[playerid][1]);
    }
    return 
1;
}  
Current directoryD:\Server de samp\gamemodes
mama
.pwn(302) : warning 213tag mismatch
mama
.pwn(302) : warning 202number of arguments does not match definition
mama
.pwn(303) : warning 213tag mismatch
mama
.pwn(303) : warning 202number of arguments does not match definition
Pawn compiler 3.2.3664              Copyright 
(c1997-2006ITB CompuPhase
4 Warnings
.
================ 
READY ================ 
Reply
#6

Try this:

PHP код:
if( newstate == PLAYER_STATE_DRIVER )
{
    
killtimerrplayerid ] = SetTimerEx"speed"100true"i"playerid );
}
else
{
    
KillTimerkilltimerr );
    
TextDrawHideForPlayerTDEditor_PTD1playerid ][ ] );
    
TextDrawHideForPlayerTDEditor_PTD1playerid ][ ] );

Reply
#7

Don't work
Reply
#8

I see if i destroy the textdraw is gone, if i try to hide is stil here.
Reply
#9

Quote:
Originally Posted by Calinut200
Посмотреть сообщение
I see if i destroy the textdraw is gone, if i try to hide is stil here.
It's because you are using "PlayerText:" and not a regular "Text:"

Use this function "PlayerTextDrawHide " to hide the text for the player : )
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)