PDA

View Full Version : Textdraw doesn't show?


[HK]Ryder[AN]
02/10/2012, 01:37 PM
Hello Guys,
I am working on a Speedometer script. I have created Textdraws using iPLEOMAX's textdraw editor but the textdraw dont show ingame.
Code -

#include <a_samp>
new Text:Textdraw0 = Text:INVALID_TEXT_DRAW;
new Text:Textdraw1 = Text:INVALID_TEXT_DRAW;
new Text:Textdraw2 = Text:INVALID_TEXT_DRAW;
new Text:Textdraw3 = Text:INVALID_TEXT_DRAW;
new Float:carspeed[3];
new VehNames[][] = {
"Landstalker","Bravura","Buffalo","Linerunner","Pereniel","Sentinel","Dumper","Firetruck","Trashmaster",
"Stretch","Manana","Infernus","Voodoo","Pony","Mule","Cheetah","Ambulance","Leviathan","Moonbeam","Esperanto",
"Taxi","Washington","Bobcat","Mr Whoopee","BF Injection","Hunter","Premier","Enforcer","Securicar","Banshee",
"Predator","Bus","Rhino","Barracks","Hotknife","Trailer","Previon","Coach","Cabbie","Stallion","Rumpo",
"RC Bandit","Romero","Packer","Monster","Admiral","Squalo","Seasparrow","Pizzaboy","Tram","Trailer",
"Turismo","Speeder","Reefer","Tropic","Flatbed","Yankee","Caddy","Solair","Berkley's RC Van","Skimmer",
"PCJ-600","Faggio","Freeway","RC Baron","RC Raider","Glendale","Oceanic","Sanchez","Sparrow","Patriot",
"Quad","Coastguard","Dinghy","Hermes","Sabre","Rustler","ZR3 50","Walton","Regina","Comet","BMX",
"Burrito","Camper","Marquis","Baggage","Dozer","Maverick","News Chopper","Rancher","FBI Rancher","Virgo",
"Greenwood","Jetmax","Hotring","Sandking","Blista Compact","Police Maverick","Boxville","Benson","Mesa",
"RC Goblin","Hotring Racer A","Hotring Racer B","Bloodring Banger","Rancher","Super GT","Elegant",
"Journey","Bike","Mountain Bike","Beagle","Cropdust","Stunt","Tanker","RoadTrain","Nebula","Majestic",
"Buccaneer","Shamal","Hydra","FCR-900","NRG-500","HPV1000","Cement Truck","Tow Truck","Fortune","Cadrona",
"FBI Truck","Willard","Forklift","Tractor","Combine","Feltzer","Remington","Slamvan","Blade","Freight",
"Streak","Vortex","Vincent","Bullet","Clover","Sadler","Firetruck","Hustler","Intruder","Primo","Cargobob",
"Tampa","Sunrise","Merit","Utility","Nevada","Yosemite","Windsor","Monster A","Monster B","Uranus",
"Jester","Sultan","Stratum","Elegy","Raindance","RC Tiger","Flash","Tahoma","Savanna","Bandito","Freight",
"Trailer","Kart","Mower","Duneride","Sweeper","Broadway","Tornado","AT-400","DFT-30","Huntley","Stafford",
"BF-400","Newsvan","Tug","Trailer A","Emperor","Wayfarer","Euros","Hotdog","Club","Trailer B","Trailer C",
"Andromada","Dodo","RC Cam","Launch","Police Car (LSPD)","Police Car (SFPD)","Police Car (LVPD)","Police Ranger",
"Picador","S.W.A.T. Van","Alpha","Phoenix","Glendale","Sadler","Luggage Trailer A","Luggage Trailer B",
"Stair Trailer","Boxville","Farm Plow","Utility Trailer" };
public OnFilterScriptInit()
{
print("Speedometer Loaded<!>");
print("made by [HK]Ryder[AN]");
Textdraw0 = TextDrawCreate(641.200, 324.805, "box");
TextDrawLetterSize(Textdraw0, 0.000, 9.795);
TextDrawTextSize(Textdraw0, 489.199, 0.000);
TextDrawAlignment(Textdraw0, 1);
TextDrawColor(Textdraw0, 0);
TextDrawUseBox(Textdraw0, 1);
TextDrawBoxColor(Textdraw0, 102);
TextDrawFont(Textdraw0, 0);

Textdraw1 = TextDrawCreate(495.200, 324.799, "Vehicle: Loading..");
TextDrawLetterSize(Textdraw1, 0.335, 2.174);
TextDrawTextSize(Textdraw1, -280.000, 247.145);
TextDrawAlignment(Textdraw1, 1);
TextDrawColor(Textdraw1, -8781569);
TextDrawSetOutline(Textdraw1, 1);
TextDrawBackgroundColor(Textdraw1, 51);
TextDrawFont(Textdraw1, 2);
TextDrawSetProportional(Textdraw1, 1);

Textdraw2 = TextDrawCreate(496.000, 356.906, "Health: -=-");
TextDrawLetterSize(Textdraw2, 0.430, 1.927);
TextDrawAlignment(Textdraw2, 1);
TextDrawColor(Textdraw2, 0x00FF00FF);
TextDrawSetOutline(Textdraw2, 1);
TextDrawBackgroundColor(Textdraw2, 51);
TextDrawFont(Textdraw2, 2);
TextDrawSetProportional(Textdraw2, 1);

Textdraw3 = TextDrawCreate(496.799, 389.760, "Speed: -=-");
TextDrawLetterSize(Textdraw3, 0.469, 1.988);
TextDrawAlignment(Textdraw3, 1);
TextDrawColor(Textdraw3, -1);
TextDrawSetOutline(Textdraw3, 1);
TextDrawBackgroundColor(Textdraw3, 51);
TextDrawFont(Textdraw3, 2);
TextDrawSetProportional(Textdraw3, 1);

return 1;
}

public OnFilterScriptExit()
{
TextDrawDestroy(Textdraw0);
Textdraw0 = Text:INVALID_TEXT_DRAW;

TextDrawDestroy(Textdraw1);
Textdraw1 = Text:INVALID_TEXT_DRAW;

TextDrawDestroy(Textdraw2);
Textdraw2 = Text:INVALID_TEXT_DRAW;

TextDrawDestroy(Textdraw3);
Textdraw3 = Text:INVALID_TEXT_DRAW;
return 1;
}


public OnPlayerDisconnect(playerid, reason)
{
TextDrawHideForPlayer(playerid, Textdraw0);
TextDrawHideForPlayer(playerid, Textdraw1);
TextDrawHideForPlayer(playerid, Textdraw2);
TextDrawHideForPlayer(playerid, Textdraw3);
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new playerspeed[50];
new playercar[50];
new Float:health;
new vehhealth[50];
new veh;
veh = GetPlayerVehicleID(playerid);
format(playerspeed, sizeof(playerspeed), "Speed: %d KM/H", GetSpeed(playerid));
format(playercar, sizeof(playercar), "Vehicle: %s", VehNames[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
format(vehhealth, sizeof(vehhealth), "Health: %0.0f",GetVehicleHealth(veh, health));
TextDrawSetString(Textdraw1, playercar);
TextDrawSetString(Textdraw2, vehhealth);
TextDrawSetString(Textdraw3, playerspeed);
TextDrawShowForPlayer(playerid, Textdraw0);
TextDrawShowForPlayer(playerid, Textdraw1);
TextDrawShowForPlayer(playerid, Textdraw2);
TextDrawShowForPlayer(playerid, Textdraw3);
return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
TextDrawHideForPlayer(playerid, Textdraw0);
TextDrawHideForPlayer(playerid, Textdraw1);
TextDrawHideForPlayer(playerid, Textdraw2);
TextDrawHideForPlayer(playerid, Textdraw3);
return 1;
}
public OnPlayerUpdate(playerid)
{
if(IsPlayerInAnyVehicle(playerid) == 1)
{
new veh = GetPlayerVehicleID(playerid);
new Float:health;
GetVehicleHealth(veh, health);
if(health <= 1000 && health > 899) TextDrawColor(Textdraw2,0x00FF00FF);
if(health <= 899 && health > 799) TextDrawColor(Textdraw2,0x40FF00FF);
if(health <= 799 && health > 699) TextDrawColor(Textdraw2,0x80FF00FF);
if(health <=699 && health > 599) TextDrawColor(Textdraw2,0xC0FF00FF);
if(health <=599 && health > 499) TextDrawColor(Textdraw2,0xC0FF00FF);
if(health <=499 && health > 399) TextDrawColor(Textdraw2,0xC0FF00FF);
if(health <=399 && health > 299) TextDrawColor(Textdraw2,0xC0FF00FF);
if(health <=299 && health > 249) TextDrawColor(Textdraw2,0xC0FF00FF);
if(health <=249 && health > 0) TextDrawColor(Textdraw2,0xC0FF00FF);
}
return 1;
}
stock GetSpeed ( playerid , mode = 1 )//Credits to SlashPT
{
GetVehicleVelocity ( GetPlayerVehicleID ( playerid ) , carspeed [ 0 ] , carspeed [ 1 ] , carspeed [ 2 ] ) ;
return IsPlayerInAnyVehicle ( playerid ) ? floatround ( ( ( floatsqroot ( ( ( carspeed [ 0 ] * carspeed [ 0 ] ) + ( carspeed [ 1 ] * carspeed [ 1 ] ) + ( carspeed [ 2 ] * carspeed [ 2 ] ) ) ) * ( !mode ? 105.0 : 170.0 ) ) ) * 1 ) : 0;
}

[HK]Ryder[AN]
03/10/2012, 08:38 AM
bump..

Pro_Drifter
03/10/2012, 08:42 AM
go to on playerconnect and add:
TextDrawShowForPlayer(playerid,Textdraw0);
TextDrawShowForPlayer(playerid,Textdraw1);
TextDrawShowForPlayer(playerid,Textdraw2);
TextDrawShowForPlayer(playerid,Textdraw3);

[HK]Ryder[AN]
03/10/2012, 11:17 AM
Why would you display a speedometer on player connect?i am showing it in onplayerentervehicle..check it out