26.11.2012, 12:43
Necesito reemplazar los textdraws que lleva este velocнmetro:
Por йstos textdraws y progress bars:
Gracias de antemano.
Код:
#include <a_samp>
#pragma tabsize 0
new Text:Textdraw[MAX_PLAYERS];
new Text:TextdrawG[MAX_PLAYERS];
new TimerAct[MAX_PLAYERS];
new Fuel[MAX_VEHICLES];
new FuelTimer[MAX_PLAYERS];
forward Actu(playerid);
forward Gasolina(playerid);
public OnFilterScriptInit()
{
for(new i; i<GetMaxPlayers(); i++)
{
Textdraw[i] = TextDrawCreate(542.000000, 400.000000, "Velocidad: 250Km/h");
TextDrawBackgroundColor(Textdraw[i], 255);
TextDrawFont(Textdraw[i], 1);
TextDrawLetterSize(Textdraw[i], 0.500000, 1.000000);
TextDrawColor(Textdraw[i], -1);
TextDrawSetOutline(Textdraw[i], 0);
TextDrawSetProportional(Textdraw[i], 1);
TextDrawSetShadow(Textdraw[i], 1);
TextDrawUseBox(Textdraw[i], 1);
TextDrawBoxColor(Textdraw[i], 65535);
TextDrawTextSize(Textdraw[i], 628.000000, -141.000000);
//---------------------------------------------------------------//
TextdrawG[i] = TextDrawCreate(542.000000, 423.000000, "Gasolina: 1000");
TextDrawBackgroundColor(TextdrawG[i], 255);
TextDrawFont(TextdrawG[i], 1);
TextDrawLetterSize(TextdrawG[i], 0.500000, 1.000000);
TextDrawColor(TextdrawG[i], -1);
TextDrawSetOutline(TextdrawG[i], 0);
TextDrawSetProportional(TextdrawG[i], 1);
TextDrawSetShadow(TextdrawG[i], 1);
TextDrawUseBox(TextdrawG[i], 1);
TextDrawBoxColor(TextdrawG[i], 16711935);
TextDrawTextSize(TextdrawG[i], 628.000000, 0.000000);
for(new v=0;v<MAX_VEHICLES;v++)
{
Fuel[v] = 100;
}
}
return 1;
}
public OnFilterScriptExit()
{
for(new i; i<GetMaxPlayers(); i++)
{
TextDrawHideForAll(Textdraw[i]);
TextDrawDestroy(Textdraw[i]);
TextDrawHideForAll(TextdrawG[i]);
TextDrawDestroy(TextdrawG[i]);
}
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
TextDrawShowForPlayer(playerid, Textdraw[playerid]);
TextDrawShowForPlayer(playerid, TextdrawG[playerid]);
TimerAct[playerid] = SetTimerEx("Actu", 100, true, "u", playerid);
FuelTimer[playerid] = SetTimerEx("Gasolina", 10000, true, "i", playerid); //
}
else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
{
TextDrawHideForPlayer(playerid, Textdraw[playerid]);
KillTimer(TimerAct[playerid]);
KillTimer(FuelTimer[playerid]);
TextDrawHideForPlayer(playerid, TextdrawG[playerid]);
if(GetPVarInt(playerid, "CheckOn") == 1)
{
SetPVarInt(playerid, "CheckOn", 0);
DisablePlayerCheckpoint(playerid);
}
}
return 1;
}
public OnVehicleSpawn(vehicleid)
{
for(new v = 0; v < MAX_VEHICLES; v++)
{
Fuel[v] = 100;
}
return 1;
}
public Gasolina(playerid)
{
new veh = GetPlayerVehicleID(playerid);
{
new lights,alarm,engine, doors,bonnet,boot,objective;
GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
if(Fuel[veh] > 0)
{
Fuel[veh] -= 1;
}
if(Fuel[veh] < 1 && GetPVarInt(playerid, "CheckOn") == 0)
{
SetPlayerCheckpoint(playerid, 1938.0389,-1773.1208,13.0801, 5.0);
GameTextForPlayer(playerid, "Vehiculo sin Gasolina", 3000, 3);
SetPVarInt(playerid, "CheckOn", 1);
SetVehicleParamsEx(veh,0,lights,alarm,doors,bonnet,boot,objective);
}
}
return 1;
}
public Actu(playerid)
{
new string[256];
new vspeed = GetVehicleSpeed(GetPlayerVehicleID(playerid));
format(string, sizeof(string), "Velocidad: %d Kmh", vspeed);
TextDrawSetString(Textdraw[playerid], string);
TextDrawShowForPlayer(playerid, Textdraw[playerid]);
//-------------------//
new string2[256];
new Gasoil = Fuel[GetPlayerVehicleID(playerid)];
format(string2, sizeof(string2), "Gasolina: %d", Gasoil);
TextDrawSetString(TextdrawG[playerid], string2);
TextDrawShowForPlayer(playerid, TextdrawG[playerid]);
}
public OnPlayerEnterCheckpoint(playerid)
{
if(GetPVarInt(playerid, "CheckOn") == 1)
{
if(IsPlayerInAnyVehicle(playerid))
{
new veh = GetPlayerVehicleID(playerid);
Fuel[veh] += 100;
SendClientMessage(playerid, -1, "{9BA8B7}Aviso: {FFFFFF}Gasolina del coche rellenada");
SetPVarInt(playerid, "CheckOn", 0);
DisablePlayerCheckpoint(playerid);
}
return 1;
}
return 1;
}
stock GetVehicleSpeed(vehicleid)
{
if(vehicleid != INVALID_VEHICLE_ID)
{
new Float:Pos[3],Float:VS ;
GetVehicleVelocity(vehicleid, Pos[0], Pos[1], Pos[2]);
VS = floatsqroot(Pos[0]*Pos[0] + Pos[1]*Pos[1] + Pos[2]*Pos[2])*200;
return floatround(VS,floatround_round);
}
return INVALID_VEHICLE_ID;
}
Код:
new Text:TextdrawA; new Text:TextdrawB; new Text:TextdrawC; new Text:TextdrawD; new Text:TextdrawE; new Text:TextdrawF; new Text:TextdrawG; new Bar:Combustible; new Bar:Vehlocimetro; Combustible = CreateProgressBar(552.00, 370.00, 68.50, 3.20, 128822783, 100.0); Vehlocimetro = CreateProgressBar(552.00, 427.00, 69.50, 4.19, -1131993857, 100.0); TextdrawA = TextDrawCreate(547.000000, 389.000000, "-"); TextDrawBackgroundColor(TextdrawA, 255); TextDrawFont(TextdrawA, 1); TextDrawLetterSize(TextdrawA, 6.199995, 5.599997); TextDrawColor(TextdrawA, 255); TextDrawSetOutline(TextdrawA, 0); TextDrawSetProportional(TextdrawA, 1); TextDrawSetShadow(TextdrawA, 3); TextDrawUseBox(TextdrawA, 1); TextDrawBoxColor(TextdrawA, 255); TextDrawTextSize(TextdrawA, 628.000000, -91.000000); TextdrawB = TextDrawCreate(551.000000, 389.000000, "Velocimetro"); TextDrawBackgroundColor(TextdrawB, 255); TextDrawFont(TextdrawB, 1); TextDrawLetterSize(TextdrawB, 0.360000, 1.200000); TextDrawColor(TextdrawB, -1); TextDrawSetOutline(TextdrawB, 0); TextDrawSetProportional(TextdrawB, 1); TextDrawSetShadow(TextdrawB, 1); TextdrawC = TextDrawCreate(590.000000, 404.000000, "0"); TextDrawAlignment(TextdrawC, 3); TextDrawBackgroundColor(TextdrawC, 255); TextDrawFont(TextdrawC, 1); TextDrawLetterSize(TextdrawC, 0.500000, 1.700000); TextDrawColor(TextdrawC, -1); TextDrawSetOutline(TextdrawC, 0); TextDrawSetProportional(TextdrawC, 1); TextDrawSetShadow(TextdrawC, 1); TextdrawD = TextDrawCreate(593.000000, 407.000000, "KM/h"); TextDrawBackgroundColor(TextdrawD, 255); TextDrawFont(TextdrawD, 1); TextDrawLetterSize(TextdrawD, 0.349999, 1.200000); TextDrawColor(TextdrawD, -1); TextDrawSetOutline(TextdrawD, 0); TextDrawSetProportional(TextdrawD, 1); TextDrawSetShadow(TextdrawD, 1); TextdrawE = TextDrawCreate(547.000000, 329.000000, "-"); TextDrawBackgroundColor(TextdrawE, 255); TextDrawFont(TextdrawE, 1); TextDrawLetterSize(TextdrawE, 6.199995, 5.599997); TextDrawColor(TextdrawE, 255); TextDrawSetOutline(TextdrawE, 0); TextDrawSetProportional(TextdrawE, 1); TextDrawSetShadow(TextdrawE, 3); TextDrawUseBox(TextdrawE, 1); TextDrawBoxColor(TextdrawE, 255); TextDrawTextSize(TextdrawE, 628.000000, -91.000000); TextdrawF = TextDrawCreate(551.000000, 327.000000, "Combustible"); TextDrawBackgroundColor(TextdrawF, 255); TextDrawFont(TextdrawF, 1); TextDrawLetterSize(TextdrawF, 0.360000, 1.200000); TextDrawColor(TextdrawF, -1); TextDrawSetOutline(TextdrawF, 0); TextDrawSetProportional(TextdrawF, 1); TextDrawSetShadow(TextdrawF, 1); TextdrawG = TextDrawCreate(623.000000, 342.000000, "0/140"); TextDrawAlignment(TextdrawG, 3); TextDrawBackgroundColor(TextdrawG, 255); TextDrawFont(TextdrawG, 1); TextDrawLetterSize(TextdrawG, 0.549998, 2.199999); TextDrawColor(TextdrawG, -1); TextDrawSetOutline(TextdrawG, 0); TextDrawSetProportional(TextdrawG, 1); TextDrawSetShadow(TextdrawG, 1);

