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=111190)



TextDraw - lakierka - 30.11.2009

Hi all.. I'm doing my own car info script wich shows speed, health, gas and stuff.. But it's not working that I need. Info shows just for me. Here is the script:
Код:
public MasinosTextDraw(playerid)
{

		  new vehicleid = GetPlayerVehicleID(playerid);
		  new model = GetVehicleModel(vehicleid);
		  new Float:bukle;
		  GetVehicleHealth(vehicleid, bukle);

		  if(IsPlayerInAnyVehicle(playerid))
		  {
			  TextDrawShowForPlayer(playerid, Text:Degalai);
			  TextDrawShowForPlayer(playerid, Text:Greitis);
			  TextDrawShowForPlayer(playerid, Text:GreitisStr);
			  TextDrawShowForPlayer(playerid, Text:Bukle);
			  TextDrawShowForPlayer(playerid, Text:Atrakinta);
			  TextDrawShowForPlayer(playerid, Text:VModelis);
			  if(model != BMX || model != BIKE || model != MTBIKE || model != 537)
				{
				  TextDrawShowForPlayer(playerid, Text:DegalaiStr);
		      new GasStr[64];
					format(GasStr,128,"%d",vehicleDB[vehicleid][gas]);
					TextDrawSetString(Text:DegalaiStr,GasStr);
		    }
				if(model == BMX || model == BIKE || model == MTBIKE || model == 537)
				{
		      TextDrawHideForPlayer(playerid, DegalaiStr);
		    }
		    if(bukle > 800)
		    {
		      TextDrawHideForPlayer(playerid, Text:Gera);
		      TextDrawHideForPlayer(playerid, Text:Bloga);
		      TextDrawShowForPlayer(playerid, Text:Puiki);
				}
				else if(bukle < 800)
		    {
		      TextDrawHideForPlayer(playerid, Text:Puiki);
		      TextDrawHideForPlayer(playerid, Text:Bloga);
		      TextDrawShowForPlayer(playerid, Text:Gera);
				}
				else if(bukle < 470)
		    {
		      TextDrawHideForPlayer(playerid, Text:Puiki);
		      TextDrawHideForPlayer(playerid, Text:Gera);
		      TextDrawShowForPlayer(playerid, Text:Bloga);
				}
				new ModelStr[64];
				format(ModelStr,128,"%s",aVehicleNames[GetVehicleModel(vehicleid)-400]);
				TextDrawSetString(Text:VModelis,ModelStr);
				new Float:X, Float:Y, Float:Z, Float:Speed;
		    GetVehicleVelocity(GetPlayerVehicleID(playerid), X, Y, Z);
		    Speed = floatmul(floatsqroot(floatadd(floatadd(floatpower(X, 2), floatpower(Y, 2)), floatpower(Z, 2))), 100.0);
		    new GreicioStr[64];
				format(GreicioStr,128,"%i",floatround(Speed, floatround_floor));
				TextDrawSetString(Text:GreitisStr,GreicioStr);
				if(vehicleDB[vehicleid][locked] == true || motoDB[vehicleid][locked] == true)
				{
				  TextDrawHideForPlayer(playerid, Text:Atrakinta);
					TextDrawShowForPlayer(playerid, Text:Uzrakinta);
				}
				else if(vehicleDB[vehicleid][locked] == false || motoDB[vehicleid][locked] == false)
				{
				  TextDrawHideForPlayer(playerid, Text:Uzrakinta);
					TextDrawShowForPlayer(playerid, Text:Atrakinta);
				}
			}
			else
			{
				TextDrawHideForPlayer(playerid, Text:Degalai);
				TextDrawHideForPlayer(playerid, Text:DegalaiStr);
				TextDrawHideForPlayer(playerid, Text:Greitis);
				TextDrawHideForPlayer(playerid, Text:GreitisStr);
				TextDrawHideForPlayer(playerid, Text:Bukle);
				TextDrawHideForPlayer(playerid, Text:Atrakinta);
				TextDrawHideForPlayer(playerid, Text:Uzrakinta);
				TextDrawHideForPlayer(playerid, Text:VModelis);
				TextDrawHideForPlayer(playerid, Text:Gera);
				TextDrawHideForPlayer(playerid, Text:Puiki);
				TextDrawHideForPlayer(playerid, Text:Bloga);
			}
return 1;
}
When I do like that: for(new w = 0; w < MAX_PLAYERS; w++) it works, but has bug. When one player enter one veh all good. But when other player enter other car, car info shows first player info. Maybe someone know how to fix it?


Re: TextDraw - mascii - 30.11.2009

you have to make a textdraw for each player

example:

pawn Код:
new Text:Location[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    Location[playerid] = TextDrawCreate(86.000000,431.000000,"San Andreas");
    TextDrawAlignment(Location[playerid],2);
    TextDrawBackgroundColor(Location[playerid],0x000000ff);
    TextDrawFont(Location[playerid],2);
    TextDrawLetterSize(Location[playerid],0.199999,0.899999);
    TextDrawColor(Location[playerid],0xffffffff);
    TextDrawSetOutline(Location[playerid],1);
    TextDrawSetProportional(Location[playerid],1);
    TextDrawSetShadow(Location[playerid],1);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    TextDrawDestroy(Location[playerid]);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    new string[256];
    format(string, sizeof(string), "Location: %s", GetPlayerLocation(playerid));
    TextDrawSetString(Text:Location[playerid],string);
    TextDrawShowForPlayer(playerid, Text:Location[playerid]);
    return 1;
}
hope this helps


Re: TextDraw - lakierka - 30.11.2009

I've done like u said, but it's the same shit..


Re: TextDraw - mascii - 01.12.2009

i think you have to make floats for each player as well. but im not sure.. sorry