Textdraw ID Mess up
#3

Код:
enum pTDInfo
{
	PlayerText:InfoBoxHeader,
	PlayerText:InfoBoxInfo,
	PlayerText:TachoInfo1,
	PlayerText:TachoInfo2,
	PlayerText:TachoInfo3
}

new pTextDraw[MAX_PLAYERS][pTDInfo];
Код:
public CreateSpeedo(playerid)
{
	/*new str[1000];
	format(str,sizeof(str),"{008400}%s\n",cInfo[GetVehicleModel(GetPlayerVehicleID(playerid))-400][cName]);
	format(str,sizeof(str),"%s\n{0000B2}Geschwindigkeit:      {FFFFFF}000 Km/h",str);
	format(str,sizeof(str),"%s\n{0000B2}Tempomat:               {FFFFFF}000 Km/h",str);
	format(str,sizeof(str),"%s\n{0000B2}Status:                    {FFFFFF}1000 / 1000",str);
	format(str,sizeof(str),"%s\n{0000B2}Tank:                        {FFFFFF}000 / 000L",str);
	Tachotext[playerid] = CreateDynamic3DTextLabel(str,0xFFFFFFFF,0.0,0.0,0.0,10.0,INVALID_PLAYER_ID,GetPlayerVehicleID(playerid),0,0,0,playerid,15.0);*/

	//Tacho:
	pTextDraw[playerid][TachoInfo1] = CreatePlayerTextDraw(playerid, 320.000000, 391.000000, "_");
	PlayerTextDrawAlignment(playerid, pTextDraw[playerid][TachoInfo1], 2);
	PlayerTextDrawBackgroundColor(playerid, pTextDraw[playerid][TachoInfo1], 255);
	PlayerTextDrawFont(playerid, pTextDraw[playerid][TachoInfo1], 2);
	PlayerTextDrawLetterSize(playerid, pTextDraw[playerid][TachoInfo1], 0.180000, 0.800000);
	PlayerTextDrawColor(playerid, pTextDraw[playerid][TachoInfo1], -1);
	PlayerTextDrawSetOutline(playerid, pTextDraw[playerid][TachoInfo1], 0);
	PlayerTextDrawSetProportional(playerid, pTextDraw[playerid][TachoInfo1], 1);
	PlayerTextDrawSetShadow(playerid, pTextDraw[playerid][TachoInfo1], 1);

	pTextDraw[playerid][TachoInfo2] = CreatePlayerTextDraw(playerid, 223.0, 403.0, "Geschwindigkeit: 000 Km/h~n~~n~Tank: 000/000L");
	PlayerTextDrawBackgroundColor(playerid, pTextDraw[playerid][TachoInfo2], 255);
	PlayerTextDrawFont(playerid, pTextDraw[playerid][TachoInfo2], 2);
	PlayerTextDrawLetterSize(playerid, pTextDraw[playerid][TachoInfo2], 0.155000, 0.760000);
	PlayerTextDrawColor(playerid, pTextDraw[playerid][TachoInfo2], -1);
	PlayerTextDrawSetOutline(playerid, pTextDraw[playerid][TachoInfo2], 0);
	PlayerTextDrawSetProportional(playerid, pTextDraw[playerid][TachoInfo2], 1);
	PlayerTextDrawSetShadow(playerid, pTextDraw[playerid][TachoInfo2], 1);

	pTextDraw[playerid][TachoInfo3] = CreatePlayerTextDraw(playerid, 357.000000, 403.000000, "Tempomat: 000~n~~n~Status: 1000/1000");
	PlayerTextDrawBackgroundColor(playerid, pTextDraw[playerid][TachoInfo3], 255);
	PlayerTextDrawFont(playerid, pTextDraw[playerid][TachoInfo3], 2);
	PlayerTextDrawLetterSize(playerid, pTextDraw[playerid][TachoInfo3], 0.155000, 0.760000);
	PlayerTextDrawColor(playerid, pTextDraw[playerid][TachoInfo3], -1);
	PlayerTextDrawSetOutline(playerid, pTextDraw[playerid][TachoInfo3], 0);
	PlayerTextDrawSetProportional(playerid, pTextDraw[playerid][TachoInfo3], 1);
	PlayerTextDrawSetShadow(playerid, pTextDraw[playerid][TachoInfo3], 1);
	
	TextDrawShowForPlayer(playerid,gTextDraw[TachoMain1]);
	TextDrawShowForPlayer(playerid,gTextDraw[TachoMain2]);
	TextDrawShowForPlayer(playerid,gTextDraw[TachoMain3]);
	TextDrawShowForPlayer(playerid,gTextDraw[TachoMain4]);
	PlayerTextDrawShow(playerid,pTextDraw[playerid][TachoInfo1]);
	PlayerTextDrawShow(playerid,pTextDraw[playerid][TachoInfo2]);
	PlayerTextDrawShow(playerid,pTextDraw[playerid][TachoInfo3]);
	return 1;
}

public DestroySpeedo(playerid)
{
    //DestroyDynamic3DTextLabel(Tachotext[playerid]);
    
    //Tacho:
	TextDrawHideForPlayer(playerid,gTextDraw[TachoMain1]);
	TextDrawHideForPlayer(playerid,gTextDraw[TachoMain2]);
	TextDrawHideForPlayer(playerid,gTextDraw[TachoMain3]);
	TextDrawHideForPlayer(playerid,gTextDraw[TachoMain4]);
	p_PlayerTextDrawDestroy(playerid, pTextDraw[playerid][TachoInfo1]);
	p_PlayerTextDrawDestroy(playerid, pTextDraw[playerid][TachoInfo2]);
	p_PlayerTextDrawDestroy(playerid, pTextDraw[playerid][TachoInfo3]);
    return 1;
}

public UpdateSpeedo()
{
	for(new v = 0; v < MAX_VEHICLES; v++)
	{
		if(!vInfo[v][vCreatet] || !IstFahrzeugMotorisiert(v)) continue;
	    new playerid, engine, light, alarm, door, bonnet, boot, objective;
	    GetVehicleDriver(v,playerid);
	    p_GetVehicleParamsEx(v, engine, light, alarm, door, bonnet, boot, objective);
		if(!engine)
        {
            p_SetVehicleParamsEx(v, engine, 0, alarm, door, bonnet, boot, objective);
			if(playerid != INVALID_PLAYER_ID) DestroySpeedo(playerid);
			continue;
        }
        if(vInfo[v][vTank] <= 0)
		{
			p_SetVehicleParamsEx(v,0,0,alarm,door,bonnet,boot,objective);
			if(playerid != INVALID_PLAYER_ID)
			{
				DestroySpeedo(playerid);
				SendClientMessage(playerid,rot,"Ihr Tank ist leer! Benutzen Sie einen Kanister oder rufen Sie den ADAC!");
			}
			continue;
		}
		if(sirenean[v])
		{
			if(light == 0) p_SetVehicleParamsEx(v, engine, 1, alarm, door, bonnet, boot, objective);
			else p_SetVehicleParamsEx(v, engine, 0, alarm, door, bonnet, boot, objective);
		}
		vInfo[v][vTankVerbrauch] ++;
		if(vInfo[v][vTankVerbrauch] >= cInfo[GetVehicleModel(v)-400][cVerbrauchSekunden] * 5)
		{
			vInfo[v][vTankVerbrauch] = 0;
		    vInfo[v][vTank]--;
		    if(vInfo[v][vTank] < cInfo[GetVehicleModel(v)-400][cMaxTank] / 12 && playerid != INVALID_PLAYER_ID) PlayerPlaySound(playerid, 1084, 0.0, 0.0, 4.0);
		}
		if(playerid == INVALID_PLAYER_ID) continue;
		new Float:Health, Float:Speed, DisplayedSpeed;
		GetVehicleHealth(v, Health);
	    GetVehicleSpeed(v, Speed);
		new Float:x, Float:y, Float:z, Float:angle, Float:heading;
		GetVehicleVelocity(v, x, y, z);
		GetVehicleZAngle(v, angle);
		GetVehicleHeadingAngle(v, heading);
		DisplayedSpeed = floatround(Speed);
		if(floatround(Speed) < vInfo[v][vTempo] || vInfo[v][vTempo] < 10 || z > 0.5 || (floatabs(angle - heading) > 50 && floatabs(angle - heading) < 310)) {}
		else
		{
			SetVehicleSpeed(v,vInfo[v][vTempo]);
			DisplayedSpeed = vInfo[v][vTempo];
		}
		UpdateTacho(playerid, cInfo[GetVehicleModel(v)-400][cName], DisplayedSpeed, vInfo[v][vTempo], vInfo[v][vTank], cInfo[GetVehicleModel(v)-400][cMaxTank], floatround(Health, floatround_ceil));
		//UpdateDynamic3DTextLabelText(Tachotext[playerid],0xFFFFFFFF,GetSpeedoString(vInfo[v][vTempo],DisplayedSpeed,floatround(Health,floatround_round),vInfo[v][vTank],cInfo[GetVehicleModel(v)-400][cMaxTank],cInfo[GetVehicleModel(v)-400][cName]));
	}
	return 1;
}

stock UpdateTacho(playerid, Auto[], Geschw, Tempo, Tank, MaxTank, Status)
{
    new TankStr[50], StatsStr[50], GeschStr[50], TempoStr[30], str1[100], str2[100];

    format(TankStr, 50, "Tank: %d/%dL", Tank, MaxTank);
    format(StatsStr, 50, "Status: %d/1000", Status);
    format(GeschStr, 50, "%03d Km/h", Geschw);
    format(TempoStr, 30, "%03d", Tempo);

    format(str1,sizeof(str1),"%s~n~~n~%s",GeschStr,TankStr);
    format(str2,sizeof(str2),"     Tempomat: %s~n~~n~%s",TempoStr,StatsStr);

    PlayerTextDrawSetString(playerid, pTextDraw[playerid][TachoInfo1], Auto);
    PlayerTextDrawSetString(playerid, pTextDraw[playerid][TachoInfo2], str1);
    PlayerTextDrawSetString(playerid, pTextDraw[playerid][TachoInfo3], str2);
    return 1;
}
Код:
stock CreatePetrolInfo(playerid)
{
    DestroyBincoInfo(playerid);
    DestroyRepairInfo(playerid);

	pTextDraw[playerid][InfoBoxHeader] = CreatePlayerTextDraw(playerid,555.000000, 361.000000, "Unbekannt");
	PlayerTextDrawAlignment(playerid,pTextDraw[playerid][InfoBoxHeader], 2);
	PlayerTextDrawBackgroundColor(playerid,pTextDraw[playerid][InfoBoxHeader], 255);
	PlayerTextDrawFont(playerid,pTextDraw[playerid][InfoBoxHeader], 2);
	PlayerTextDrawLetterSize(playerid,pTextDraw[playerid][InfoBoxHeader], 0.140000, 0.899999);
	PlayerTextDrawColor(playerid,pTextDraw[playerid][InfoBoxHeader], -1);
	PlayerTextDrawSetOutline(playerid,pTextDraw[playerid][InfoBoxHeader], 0);
	PlayerTextDrawSetProportional(playerid,pTextDraw[playerid][InfoBoxHeader], 1);
	PlayerTextDrawSetShadow(playerid,pTextDraw[playerid][InfoBoxHeader], 1);

	pTextDraw[playerid][InfoBoxInfo] = CreatePlayerTextDraw(playerid,600.000000, 376.000000, "_");
	PlayerTextDrawAlignment(playerid,pTextDraw[playerid][InfoBoxInfo], 3);
	PlayerTextDrawBackgroundColor(playerid,pTextDraw[playerid][InfoBoxInfo], 255);
	PlayerTextDrawFont(playerid,pTextDraw[playerid][InfoBoxInfo], 2);
	PlayerTextDrawLetterSize(playerid,pTextDraw[playerid][InfoBoxInfo], 0.129999, 0.899999);
	PlayerTextDrawColor(playerid,pTextDraw[playerid][InfoBoxInfo], -1);
	PlayerTextDrawSetOutline(playerid,pTextDraw[playerid][InfoBoxInfo], 0);
	PlayerTextDrawSetProportional(playerid,pTextDraw[playerid][InfoBoxInfo], 1);
	PlayerTextDrawSetShadow(playerid,pTextDraw[playerid][InfoBoxInfo], 1);
	
	TextDrawShowForPlayer(playerid,gTextDraw[InfoBox1]);
	TextDrawShowForPlayer(playerid,gTextDraw[InfoBox2]);
	TextDrawShowForPlayer(playerid,gTextDraw[InfoBox3]);
	TextDrawShowForPlayer(playerid,gTextDraw[PetrolInfo]);
	PlayerTextDrawShow(playerid,pTextDraw[playerid][InfoBoxHeader]);
	PlayerTextDrawShow(playerid,pTextDraw[playerid][InfoBoxInfo]);
	
	UpdatePetrolInfo(playerid,GetPetrolInfoString(playerid),true);
	return 1;
}

stock UpdatePetrolInfo(playerid, tdstr[], bool:tankanzeige)
{
	new hstr[50];
	format(hstr,sizeof(hstr),"Unbekannt");
	for(new t = 0; t < sizeof Tanken; t++)
	{
        if(!IsPlayerInRangeOfPoint(playerid,15.0,Tanken[t][psx],Tanken[t][psy],Tanken[t][psz])) continue;
        format(hstr,sizeof(hstr),"~g~%s",Tanken[t][PSName]);
        break;
	}
	for(new t = 0; t < sizeof Flugzeugtanken; t++)
	{
        if(!IsAHelicopter(GetPlayerVehicleID(playerid)))
	    {
	        if(!IsPlayerInRangeOfPoint(playerid,15.0,Flugzeugtanken[t][psx1],Flugzeugtanken[t][psy1],Flugzeugtanken[t][psz1])) continue;
	    }
	    else
	    {
	        if(!IsPlayerInRangeOfPoint(playerid,15.0,Flugzeugtanken[t][psx2],Flugzeugtanken[t][psy2],Flugzeugtanken[t][psz2])) continue;
	    }
        format(hstr,sizeof(hstr),"~g~%s",Flugzeugtanken[t][PSName]);
        break;
	}
	PlayerTextDrawSetString(playerid,pTextDraw[playerid][InfoBoxHeader],hstr);
	PlayerTextDrawSetString(playerid,pTextDraw[playerid][InfoBoxInfo],tdstr);
	if(!tankanzeige) TextDrawHideForPlayer(playerid,gTextDraw[PetrolInfo]);
	return 1;
}

stock GetPetrolInfoString(playerid)
{
	new str[150], Float:lpreis, vehicleid = GetPlayerVehicleID(playerid);
	new model = GetVehicleModel(vehicleid)-400;
	for(new t = 0; t < sizeof Tanken; t++)
	{
        if(!IsPlayerInRangeOfPoint(playerid,15.0,Tanken[t][psx],Tanken[t][psy],Tanken[t][psz])) continue;
        lpreis = Tanken[t][Literpreis];
        break;
	}
	for(new t = 0; t < sizeof Flugzeugtanken; t++)
	{
        if(!IsAHelicopter(vehicleid))
	    {
	        if(!IsPlayerInRangeOfPoint(playerid,15.0,Flugzeugtanken[t][psx1],Flugzeugtanken[t][psy1],Flugzeugtanken[t][psz1])) continue;
	    }
	    else
	    {
	        if(!IsPlayerInRangeOfPoint(playerid,15.0,Flugzeugtanken[t][psx2],Flugzeugtanken[t][psy2],Flugzeugtanken[t][psz2])) continue;
	    }
        lpreis = Tanken[t][Literpreis];
        break;
	}
	format(str,sizeof(str),"%d / %dL~n~$%0.2f~n~~n~$%0.2f",vInfo[vehicleid][vTank],cInfo[model][cMaxTank],lpreis,GetPVarFloat(playerid,"tanksumme"));
	return str;
}

stock DestroyPetrolInfo(playerid)
{
    TextDrawHideForPlayer(playerid,gTextDraw[InfoBox1]);
	TextDrawHideForPlayer(playerid,gTextDraw[InfoBox2]);
	TextDrawHideForPlayer(playerid,gTextDraw[InfoBox3]);
	TextDrawHideForPlayer(playerid,gTextDraw[PetrolInfo]);
	p_PlayerTextDrawDestroy(playerid,pTextDraw[playerid][InfoBoxHeader]);
	p_PlayerTextDrawDestroy(playerid,pTextDraw[playerid][InfoBoxInfo]);
	return 1;
}
//edit:

p_PlayerTextDrawDestroy = PlayerTextDrawDestroy.

I try to reset the ID so i write a own function:

Код:
stock p_PlayerTextDrawDestroy(playerid, PlayerText:text)
{
	PlayerTextDrawDestroy(playerid, text);
        //reset id;
	return 1;
}
Reply


Messages In This Thread
Textdraw ID Mess up - by Psycho77 - 04.04.2012, 11:32
Re: Textdraw ID Mess up - by Unte99 - 04.04.2012, 11:53
Re: Textdraw ID Mess up - by Psycho77 - 04.04.2012, 11:59
Re: Textdraw ID Mess up - by SpiritEvil - 04.04.2012, 12:03
Re: Textdraw ID Mess up - by Psycho77 - 04.04.2012, 12:04
Re: Textdraw ID Mess up - by SpiritEvil - 04.04.2012, 12:12
Re: Textdraw ID Mess up - by Psycho77 - 04.04.2012, 12:14
Re: Textdraw ID Mess up - by Unte99 - 04.04.2012, 12:16
Re: Textdraw ID Mess up - by SpiritEvil - 04.04.2012, 12:17
Re: Textdraw ID Mess up - by Psycho77 - 04.04.2012, 12:23

Forum Jump:


Users browsing this thread: 1 Guest(s)