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



TextDraw - Ro[X]y - 08.08.2009

I did 4 TextDraws of the Vehicle State
1| "Vehicle State"
2| "Engine"
3| "Fuel"
4| "Vehicle"
How can I do a textdraw for player and not for everyone.
Because I want if the player's vehicle health will be 50 it will be like that:
----------
but if my friend car going to explode so it's write to me or to the other players his engine state.


Re: TextDraw - Chrham_2 - 08.08.2009

Quote:
Originally Posted by Ro[X
y ]
I did 4 TextDraws of the Vehicle State
1| "Vehicle State"
2| "Engine"
3| "Fuel"
4| "Vehicle"
How can I do a textdraw for player and not for everyone.
Because I want if the player's vehicle health will be 50 it will be like that:
----------
but if my friend car going to explode so it's write to me or to the other players his engine state.
If you show me the code it would be easier to figure it out, so we can see what
is wrong.


Re: TextDraw - Ro[X]y - 08.08.2009

OnPlayerEnterVehicle
Код:
 
format(string,sizeof(string),"~w~Vehicle: ~b~%s",VehicleName[GetVehicleModel(vehicleid)-400]);
TextDrawSetString(Textdraw3,string);
TextDrawShowForPlayer(playerid,Textdraw0);
TextDrawShowForPlayer(playerid,Textdraw1);
TextDrawShowForPlayer(playerid,Textdraw2);
TextDrawShowForPlayer(playerid,Textdraw3);
Fuel = SetTimerEx("FuelUpdate", 300, true, "i", playerid);
Engine = SetTimerEx("EngineUpdate", 300,true, "i", playerid);
new public: FuelUpdate
Код:
public FuelUpdate(playerid)
{
  	if(IsPlayerConnected(playerid))
    	{
		  new vehicle = GetPlayerVehicleID(playerid);
			if(IsPlayerInAnyVehicle(playerid) == 1)
			{
	    	if(Gas[vehicle] >= 1)
		  		{
					if(Gas[vehicle] >= 0 && Gas[vehicle] <= 0)
					{
						TextDrawSetString(Textdraw2,"~w~Fuel: ----------");
						SendClientMessage(playerid,COLOR_LIGHTRED,"There is no fuel in the fuel's tank please fill your car or /exit");
						TogglePlayerControllable(playerid, 0);
					}
					if(Gas[vehicle] >= 0 && Gas[vehicle] <= 10)
					{
		   			TextDrawSetString(Textdraw2,"~w~Fuel:~r~ -~w~---------");
					}
					if(Gas[vehicle] >= 10 && Gas[vehicle] <= 20)
					{
		   			TextDrawSetString(Textdraw2,"~w~Fuel:~r~ --~w~--------");
					}
					else if(Gas[vehicle] >= 20 && Gas[vehicle] <= 30)
					{
		   			TextDrawSetString(Textdraw2,"~w~Fuel:~r~ ---~w~-------");
					}
					else if(Gas[vehicle] >= 30 && Gas[vehicle] <= 40)
					{
		   			TextDrawSetString(Textdraw2,"~w~Fuel:~r~ ----~w~------");
					}
					else if(Gas[vehicle] >= 40 && Gas[vehicle] <= 50)
					{
		   			TextDrawSetString(Textdraw2,"~w~Fuel:~r~ -----~w~-----");
					}
					else if(Gas[vehicle] >= 50 && Gas[vehicle] <= 60)
					{
		   			TextDrawSetString(Textdraw2,"~w~Fuel:~r~ ------~w~----");
					}
					else if(Gas[vehicle] >= 60 && Gas[vehicle] <= 70)
					{
		   			TextDrawSetString(Textdraw2,"~w~Fuel:~r~ -------~w~---");
					}
					else if(Gas[vehicle] >= 70 && Gas[vehicle] <= 80)
					{
		   			TextDrawSetString(Textdraw2,"~w~Fuel:~r~ --------~w~--");
					}
					else if(Gas[vehicle] >= 80 && Gas[vehicle] <= 90)
					{
		   			TextDrawSetString(Textdraw2,"~w~Fuel:~r~ ---------~w~-");
					}
					else if(Gas[vehicle] >= 90 && Gas[vehicle] <= 100)
					{
		   			TextDrawSetString(Textdraw2,"~w~Fuel:~r~ ----------");
					}
		  		}
			}
  	}
		return 1;
}
new public: EngineUpdate
Код:
public EngineUpdate(playerid)
{
	new Float:health;
	GetVehicleHealth(GetPlayerVehicleID(playerid),health);
	if (IsPlayerConnected(playerid) && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
 	{
	if(health >= 0 && health <= 0)
 	{
		TextDrawSetString(Textdraw1,"~w~Engine: ----------");
 	}
 	else if(health >= 0 && health <= 100)
 	{
		TextDrawSetString(Textdraw1,"~w~Engine: ~r~-~w~---------");
 	}
 	else if(health >= 100 && health <= 200)
 	{
		TextDrawSetString(Textdraw1,"~w~Engine: ~r~--~w~--------");
 	}
	else if(health >= 200 && health <= 300)
 	{
		TextDrawSetString(Textdraw1,"~w~Engine: ~r~---~w~-------");
 	}
 	else if(health >= 300 && health <= 400)
 	{
		TextDrawSetString(Textdraw1,"~w~Engine: ~r~----~w~------");
 	}
 	else if(health >= 400 && health <= 500)
 	{
		TextDrawSetString(Textdraw1,"~w~Engine: ~r~-----~w~-----");
 	}
 	else if(health >= 500 && health <= 600)
 	{
		TextDrawSetString(Textdraw1,"~w~Engine: ~r~------~w~----");
 	}
 	else if(health >= 600 && health <= 700)
 	{
		TextDrawSetString(Textdraw1,"~w~Engine: ~r~-------~w~---");
	}
	else if(health >= 700 && health <= 800)
 	{
 		TextDrawSetString(Textdraw1,"~w~Engine: ~r~--------~w~--");
	}
 	else if(health >= 800 && health <= 900)
 	{
 		TextDrawSetString(Textdraw1,"~w~Engine: ~r~---------~w~-");
 	}
 	else if(health >= 900 && health <= 1000)
 	{
		TextDrawSetString(Textdraw1,"~w~Engine: ~r~----------");
 	}
 	}
 	return 1;
}



Re: TextDraw - Ro[X]y - 09.08.2009

Anyone..
I need this


Re: TextDraw - ev0lution - 09.08.2009

Change the textdraw variables to Textdraw0[MAX_PLAYERS], Textdraw1[MAX_PLAYERS], etc., then use Textdraw0[playerid], Textdraw1[playerid] to use the textdraws specific to that player.
You will also need add a loop to loop through all players and create those textdraws at the start.
Eg.
Код:
OnFilterScriptInit() {
  for(new i=0;i<MAX_PLAYERS;i++) {
    Textdraw0[i] = TextDrawCreate(....);
  }
}