24.10.2011, 15:58
Hello, ima making a script, who shows the vehicle's health with TextDraw commands. The problem is when i get in car , the text dont appear and nothing shows, i maked it if the car health is more than 0,250, 500 and 750 to have different colours at the text. Here is the code: I put that in public OnPlayerConnect(playerid):
And that is in public OnPlayerEnterVehicle and public OnPlayerExitVehicle:
I puted that at the begin of script :
Код:
public OnPlayerConnect(playerid) { SendClientMessage(playerid, 0x9955DEEE, "Welcome to Ex7r3m3 pLaY Bulgaria!Type /help for more information!"); new pNam[30], string[128]; GetPlayerName(playerid, pNam, 30); format(string, 256, "%s влезна в сървара.", pNam); SendClientMessageToAll(0xAFAFAFAA,string); new Float:vehiclehealth; new VehHealth; new vehicleid = GetPlayerVehicleID(playerid); VehHealth = GetVehicleHealth(vehicleid, vehiclehealth); format(string, sizeof(string), "Vehicle Health %i",VehHealth); VehicleHealthText = TextDrawCreate(240.0, 580.0, string); TextDrawTextSize(VehicleHealthText, 12.0, 13.6); TextDrawFont(VehicleHealthText, 1); TextDrawSetString(VehicleHealthText, string); TextDrawAlignment(VehicleHealthText,0); TextDrawBackgroundColor(VehicleHealthText,0x000000ff); TextDrawLetterSize(VehicleHealthText,0.499999,0.899999); TextDrawColor(VehicleHealthText,0xffffffff); TextDrawSetOutline(VehicleHealthText,1); TextDrawSetProportional(VehicleHealthText,1); TextDrawSetShadow(VehicleHealthText,1); if(VehHealth > 0) { TextDrawColor(VehicleHealthText, 0xFF0000FF); return 0; } if(VehHealth > 250) { TextDrawColor(VehicleHealthText, 0xFD7E00FF); return 0; } if(VehHealth > 500) { TextDrawColor(VehicleHealthText, 0xF2FF00FF); return 0; } if(VehHealth > 750) { TextDrawColor(VehicleHealthText, 0x05E600FF); return 0; } return 1; }
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { new vNam, string[128]; vNam = GetVehicleModel(vehicleid); format(string, sizeof(string), "Качихте се в %i",vNam); SendClientMessage(playerid, 0x0039FFFF, string); TextDrawShowForPlayer(playerid, VehicleHealthText); return 1; } public OnPlayerExitVehicle(playerid, vehicleid) { new vNam, string[128]; vNam = GetVehicleModel(vehicleid); format(string, sizeof(string), "Слязохте от %i",vNam); SendClientMessage(playerid, 0x0039FFFF, string); TextDrawHideForPlayer(playerid, VehicleHealthText); return 1; }
Код:
new Text:VehicleHealthText;