SA-MP Forums Archive
WHAT?! - 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)
+--- Thread: WHAT?! (/showthread.php?tid=607370)



WHAT?! - Micko123 - 18.05.2016

Can someone help me with this warns
PHP код:
new Text:hdisplay[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
        
hdisplay[playerid] = TextDrawCreate(505.625000427.583404"Health:");
    
TextDrawLetterSize(hdisplay[playerid], 0.4693752.020000);
    
TextDrawAlignment(hdisplay[playerid], 1);
    
TextDrawColor(hdisplay[playerid], -5963521);
    
TextDrawSetShadow(hdisplay[playerid], 0);
    
TextDrawSetOutline(hdisplay[playerid], 1);
    
TextDrawBackgroundColor(hdisplay[playerid], 51);
    
TextDrawFont(hdisplay[playerid], 1);
    
TextDrawSetProportional(hdisplay[playerid], 1);
        return 
1;
}
public 
OnPlayerEnterVehicle(playeridvehicleid)
{
        new 
FloathealthszText[10];
    
GetVehicleHealth(vehicleidhealth);
    
format(szTextsizeof (szText), "%.2f"health);
    
PlayerTextDrawSetString(playeridhdisplay[playerid], szText);
    
PlayerTextDrawShow(playeridhdisplay[playerid]);
        return 
1;
}
public 
OnPlayerExitVehicle(playeridvehicleid)
{
     
PlayerTextDrawHide(playeridhdisplay[playerid]);
        return 
1;

And i get these
PHP код:
C:\Users\Admin\Desktop\Moj SRV\gamemodes\MojMod.pwn(3008) : warning 213tag mismatch
C
:\Users\Admin\Desktop\Moj SRV\gamemodes\MojMod.pwn(3009) : warning 213tag mismatch
C
:\Users\Admin\Desktop\Moj SRV\gamemodes\MojMod.pwn(3020) : warning 213tag mismatch
Pawn compiler 3.2.3664              Copyright 
(c1997-2006ITB CompuPhase
3 Warnings

These are the lines of warns
PHP код:
        PlayerTextDrawSetString(playeridhdisplay[playerid], szText);
    
PlayerTextDrawShow(playeridhdisplay[playerid]);
        
PlayerTextDrawHide(playeridhdisplay[playerid]); 



Re: WHAT?! - RedRex - 18.05.2016

PHP код:
public OnPlayerConnect(playerid

        
hdisplay[playerid] = TextDrawCreate(505.625000427.583404"Health:"); 
    
TextDrawLetterSize(hdisplay[playerid], 0.4693752.020000); 
    
TextDrawAlignment(hdisplay[playerid], 1); 
    
TextDrawColor(hdisplay[playerid], -5963521); 
    
TextDrawSetShadow(hdisplay[playerid], 0); 
    
TextDrawSetOutline(hdisplay[playerid], 1); 
    
TextDrawBackgroundColor(hdisplay[playerid], 51); 
    
TextDrawFont(hdisplay[playerid], 1); 
    
TextDrawSetProportional(hdisplay[playerid], 1); 
        return 
1

Try this

Код:
public OnPlayerConnect(playerid) 
{ 
    hdisplay[playerid] = TextDrawCreate(505.625000, 427.583404, "Health:"); 
    TextDrawLetterSize(hdisplay[playerid], 0.469375, 2.020000); 
    TextDrawAlignment(hdisplay[playerid], 1); 
    TextDrawColor(hdisplay[playerid], -5963521); 
    TextDrawSetShadow(hdisplay[playerid], 0); 
    TextDrawSetOutline(hdisplay[playerid], 1); 
    TextDrawBackgroundColor(hdisplay[playerid], 51); 
    TextDrawFont(hdisplay[playerid], 1); 
    TextDrawSetProportional(hdisplay[playerid], 1); 
    return 1; 
}
PHP код:
public OnPlayerEnterVehicle(playeridvehicleid

        new 
FloathealthszText[10]; 
    
GetVehicleHealth(vehicleidhealth); 
    
format(szTextsizeof (szText), "%.2f"health); 
    
PlayerTextDrawSetString(playeridhdisplay[playerid], szText); 
    
PlayerTextDrawShow(playeridhdisplay[playerid]); 
        return 
1

tryy
Код:
public OnPlayerEnterVehicle(playerid, vehicleid) 
{ 
    new Float: health, szText[10]; 
    GetVehicleHealth(vehicleid, health); 
    format(szText, sizeof (szText), "%.2f", health); 
    PlayerTextDrawSetString(playerid, hdisplay[playerid], szText); 
    PlayerTextDrawShow(playerid, hdisplay[playerid]); 
    return 1; 
}



Re: WHAT?! - J0sh... - 18.05.2016

Half of your code is a global txd and the other half is a player txd.

PHP код:
new PlayerText:hdisplay[MAX_PLAYERS];

PlayerText...(...); 



Re: WHAT?! - Micko123 - 18.05.2016

Rly??

By the way i fixed it

I replaced warn lines with this
PHP код:
TextDrawSetString(hdisplay[playerid], szText);
    
TextDrawShowForPlayer(playeridhdisplay[playerid]);
TextDrawHideForPlayer(playeridhdisplay[playerid]); 



Re: WHAT?! - J0sh... - 18.05.2016

Right but you shouldn't do that.

Once you create enough, the TXD's will stop. Use player textdraws for players.


Re: WHAT?! - Sjn - 18.05.2016

Also, you need to fetch the health, format string and set the string to the textdraw inside a timer function that repeats. With your code, it will only get the vehicle health when a player enters a vehicle and won't be updated upon vehicle damage.


Re: WHAT?! - Micko123 - 18.05.2016

Yup that is what happened. I fixed it