Vehicle hud error
#1

Hello,
i have a problem with my hud.
It shows up perfectly fine, but EVERYONE gets this hud, but we only need to see our hud the vehicle you are in.
How do you do this?
pawn Код:
GetPlayerPos(i, x, y, z);
                distance = floatsqroot(floatpower(floatabs(floatsub(x,SavePlayerPos[i][LastX])),2)+floatpower(floatabs(floatsub(y,SavePlayerPos[i][LastY])),2)+floatpower(floatabs(floatsub(z,SavePlayerPos[i][LastZ])),2));
                value = floatround(distance * 5600);
                new Float:tmph;
                GetVehicleHealth(GetPlayerVehicleID(i), tmph);
                //format(string, sizeof(string), "~r~Health:~w~ %.0f%%  ~n~~r~Time:~w~ %02d:%02d~n~~r~Weapon:~w~%s~n~~r~Money: ~w~пїЅ%s~n~~r~Vehicle: ~w~%s~n~~r~Fuel:~w~ %d%%~n~~r~Speed: ~w~%d", aWeaponNames[GetPlayerWeapon(i)], number_format(PlayerTemp[i][sm]), GetVehicleName(GetPlayerVehicleID(i)), Gas[GetPlayerVehicleID(i)], floatround(value/600));
                format(string, sizeof(string), "~r~Speed: ~w~%d KM/H~n~~r~Fuel: ~w~%d%%~n~~r~Health: ~w~%d%", floatround(value/600), Gas[GetPlayerVehicleID(i)], floatround(floatdiv(tmph,10)));
                TextDrawSetString(PlayerTemp[i][Status], string);
                if(Gas[GetPlayerVehicleID(i)] <= 10 && IsPlayerDriver(i)) TDWarning(i, "you are running out of fuel!", 1400);
                if(Gas[GetPlayerVehicleID(i)] <= 0 && IsPlayerDriver(i)) RemovePlayerFromVehicle(i), SendClientInfo(i, "No fuel!");
                SavePlayerPos[i][LastX] = x;
                SavePlayerPos[i][LastY] = y;
                SavePlayerPos[i][LastZ] = z;
Reply
#2

If this is what you need. It does something like if you are in vehicle then you will be visible with that textdraw. When you exit it hides.
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{

	GetPlayerPos(i, x, y, z);
	distance = floatsqroot(floatpower(floatabs(floatsub(x,SavePlayerPos[i][LastX])),2)+floatpower(floatabs(floatsub(y,SavePlayerPos[i][LastY])),2)+floatpower(floatabs(floatsub(z,SavePlayerPos[i][LastZ])),2));
	value = floatround(distance * 5600);
	new Float:tmph;
	GetVehicleHealth(GetPlayerVehicleID(i), tmph);
	//format(string, sizeof(string), "~r~Health:~w~ %.0f%%  ~n~~r~Time:~w~ %02d:%02d~n~~r~Weapon:~w~%s~n~~r~Money: ~w~пїЅ%s~n~~r~Vehicle: ~w~%s~n~~r~Fuel:~w~ %d%%~n~~r~Speed: ~w~%d", aWeaponNames[GetPlayerWeapon(i)], number_format(PlayerTemp[i][sm]), GetVehicleName(GetPlayerVehicleID(i)), Gas[GetPlayerVehicleID(i)], floatround(value/600));
	format(string, sizeof(string), "~r~Speed: ~w~%d KM/H~n~~r~Fuel: ~w~%d%%~n~~r~Health: ~w~%d%", floatround(value/600), Gas[GetPlayerVehicleID(i)], floatround(floatdiv(tmph,10)));
	TextDrawSetString(PlayerTemp[i][Status], string);
	if(Gas[GetPlayerVehicleID(i)] <= 10 && IsPlayerDriver(i)) TDWarning(i, "you are running out of fuel!", 1400);
	if(Gas[GetPlayerVehicleID(i)] <= 0 && IsPlayerDriver(i)) RemovePlayerFromVehicle(i), SendClientInfo(i, "No fuel!");
	SavePlayerPos[i][LastX] = x;
	SavePlayerPos[i][LastY] = y;
	SavePlayerPos[i][LastZ] = z;
	return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	TextDrawHideForPlayer(playerid,PlayerTemp[playerid][Status]);
	return 1;
}
Reply
#3

Quote:
Originally Posted by JohnBlaze1971
Посмотреть сообщение
If this is what you need. It does something like if you are in vehicle then you will be visible with that textdraw. When you exit it hides.
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{

	GetPlayerPos(i, x, y, z);
	distance = floatsqroot(floatpower(floatabs(floatsub(x,SavePlayerPos[i][LastX])),2)+floatpower(floatabs(floatsub(y,SavePlayerPos[i][LastY])),2)+floatpower(floatabs(floatsub(z,SavePlayerPos[i][LastZ])),2));
	value = floatround(distance * 5600);
	new Float:tmph;
	GetVehicleHealth(GetPlayerVehicleID(i), tmph);
	//format(string, sizeof(string), "~r~Health:~w~ %.0f%%  ~n~~r~Time:~w~ %02d:%02d~n~~r~Weapon:~w~%s~n~~r~Money: ~w~пїЅ%s~n~~r~Vehicle: ~w~%s~n~~r~Fuel:~w~ %d%%~n~~r~Speed: ~w~%d", aWeaponNames[GetPlayerWeapon(i)], number_format(PlayerTemp[i][sm]), GetVehicleName(GetPlayerVehicleID(i)), Gas[GetPlayerVehicleID(i)], floatround(value/600));
	format(string, sizeof(string), "~r~Speed: ~w~%d KM/H~n~~r~Fuel: ~w~%d%%~n~~r~Health: ~w~%d%", floatround(value/600), Gas[GetPlayerVehicleID(i)], floatround(floatdiv(tmph,10)));
	TextDrawSetString(PlayerTemp[i][Status], string);
	if(Gas[GetPlayerVehicleID(i)] <= 10 && IsPlayerDriver(i)) TDWarning(i, "you are running out of fuel!", 1400);
	if(Gas[GetPlayerVehicleID(i)] <= 0 && IsPlayerDriver(i)) RemovePlayerFromVehicle(i), SendClientInfo(i, "No fuel!");
	SavePlayerPos[i][LastX] = x;
	SavePlayerPos[i][LastY] = y;
	SavePlayerPos[i][LastZ] = z;
	return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	TextDrawHideForPlayer(playerid,PlayerTemp[playerid][Status]);
	return 1;
}
No that's not what i mean.
The whole public is this
pawn Код:
public CheckGas()
{
    new string[164];
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if(IsPlayerConnected(i))
        {
            if(     GetPlayerState(i) == PLAYER_STATE_DRIVER
                ||  IsPlayerInAnyVehicle(i) && GetPlayerWeapon(i) == 24) SetPlayerArmedWeapon(i, 0);
            if(!PlayerTemp[i][adminduty])
            {
                if(PlayerTemp[i][oocmode]) SetPlayerChatBubble(i, "(( OOC MODE - DO NOT ROLEPLAY WITH THIS PERSON ))", COLOR_ADMIN_SPYREPORT, 40.0, 2000);
                if(PlayerTemp[i][helperduty])
                {
                    format(iStr, sizeof(iStr), "(( HELPERDUTY ))");
                    SetPlayerChatBubble(i, iStr, 0xe70909AA, 50.0, 10000);
                }
            }
            else
            {
                format(iStr, sizeof(iStr), "(( ADMINDUTY ))");
                SetPlayerChatBubble(i, iStr, 0xe70909AA, 50.0, 10000);
            }
            GetPlayerPos(i,X250[i],Y250[i],Z250[i]);
            new Float:pH, Float:pA;
            GetPlayerHealth(i, pH);
            GetPlayerArmour(i, pA);
            new Float:x,Float:y,Float:z;
            new Float:distance,value;
            if(!IsPlayerInAnyVehicle(i))
            {
                //format(string, sizeof(string), "~r~Health:~w~ %.0f%%  ~n~~r~Time:~w~ %02d:%02d~n~~r~Weapon: ~w~%s~n~~r~Money: ~w~пїЅ%s",pH, t[0], t[1], aWeaponNames[GetPlayerWeapon(i)], number_format(PlayerTemp[i][sm]));
                //format(string, sizeof(string), "~g~Health:~w~ %.0f%%~n~~g~Weapon: ~w~%s~n~~g~Money: ~w~$%s", pH, aWeaponNames[GetPlayerWeapon(i)], number_format(PlayerTemp[i][sm]));
                TextDrawSetString(PlayerTemp[i][Status], string);
                if(tazed[ i ]) ApplyAnimation(i,"CRACK", "crckdeth2", 4.1, 0, 0, 0, 1, 1); // irl crack!
            }
            else
            {
                GetPlayerPos(i, x, y, z);
                distance = floatsqroot(floatpower(floatabs(floatsub(x,SavePlayerPos[i][LastX])),2)+floatpower(floatabs(floatsub(y,SavePlayerPos[i][LastY])),2)+floatpower(floatabs(floatsub(z,SavePlayerPos[i][LastZ])),2));
                value = floatround(distance * 5600);
                new Float:tmph;
                GetVehicleHealth(GetPlayerVehicleID(i), tmph);
                //format(string, sizeof(string), "~r~Health:~w~ %.0f%%  ~n~~r~Time:~w~ %02d:%02d~n~~r~Weapon:~w~%s~n~~r~Money: ~w~пїЅ%s~n~~r~Vehicle: ~w~%s~n~~r~Fuel:~w~ %d%%~n~~r~Speed: ~w~%d", aWeaponNames[GetPlayerWeapon(i)], number_format(PlayerTemp[i][sm]), GetVehicleName(GetPlayerVehicleID(i)), Gas[GetPlayerVehicleID(i)], floatround(value/600));
                format(string, sizeof(string), "~r~Speed: ~w~%d KM/H~n~~r~Fuel: ~w~%d%%~n~~r~Health: ~w~%d%", floatround(value/600), Gas[GetPlayerVehicleID(i)], floatround(floatdiv(tmph,10)));
                TextDrawSetString(PlayerTemp[i][Status], string);
                if(Gas[GetPlayerVehicleID(i)] <= 10 && IsPlayerDriver(i)) TDWarning(i, "you are running out of fuel!", 1400);
                if(Gas[GetPlayerVehicleID(i)] <= 0 && IsPlayerDriver(i)) RemovePlayerFromVehicle(i), SendClientInfo(i, "No fuel!");
                SavePlayerPos[i][LastX] = x;
                SavePlayerPos[i][LastY] = y;
                SavePlayerPos[i][LastZ] = z;
            }
        }
    }
    return 1;
}
Reply
#4

Don't you want to explain what you actually need? Say the problem pls.
Reply
#5

Quote:
Originally Posted by fuckingcruse
Посмотреть сообщение
Don't you want to explain what you actually need? Say the problem pls.
Okay, so, this system works, BUT, i want a system that shows the vehicle health, gas etc, PER CAR.
This one shows one particular car, even if you arn't in a car, so there is a bug.
How do i fix this?
Reply
#6

You mean if he exits car it still shows the textdraw?
Reply
#7

Quote:
Originally Posted by fuckingcruse
Посмотреть сообщение
You mean if he exits car it still shows the textdraw?
No, if my friend drives a car, i can still see his textdraw
Reply
#8

Quote:

public OnPlayerStateChange(playerid, newstate, oldstate)
{
for(new i=0;i<MAX_PLAYERS;i++)
{
if(GetPlayerState(i) == PLAYER_STATE_ONFOOT)
{
TextDrawHideForPlayer(i,PlayerTemp[playerid][Status]);
return 1;
}
}
}

Try this
Reply
#9

Quote:
Originally Posted by OmegaKiller72
Посмотреть сообщение
Try this
Can you imploment it in the "public checkgas?"
this:
pawn Код:
public CheckGas()
{
    new string[164];
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if(IsPlayerConnected(i))
        {
            if(     GetPlayerState(i) == PLAYER_STATE_DRIVER
                ||  IsPlayerInAnyVehicle(i) && GetPlayerWeapon(i) == 24) SetPlayerArmedWeapon(i, 0);
            if(!PlayerTemp[i][adminduty])
            {
                if(PlayerTemp[i][oocmode]) SetPlayerChatBubble(i, "(( OOC MODE - DO NOT ROLEPLAY WITH THIS PERSON ))", COLOR_ADMIN_SPYREPORT, 40.0, 2000);
                if(PlayerTemp[i][helperduty])
                {
                    format(iStr, sizeof(iStr), "(( HELPERDUTY ))");
                    SetPlayerChatBubble(i, iStr, 0xe70909AA, 50.0, 10000);
                }
            }
            else
            {
                format(iStr, sizeof(iStr), "(( ADMINDUTY ))");
                SetPlayerChatBubble(i, iStr, 0xe70909AA, 50.0, 10000);
            }
            GetPlayerPos(i,X250[i],Y250[i],Z250[i]);
            new Float:pH, Float:pA;
            GetPlayerHealth(i, pH);
            GetPlayerArmour(i, pA);
            new Float:x,Float:y,Float:z;
            new Float:distance,value;
            if(!IsPlayerInAnyVehicle(i))
            {
                //format(string, sizeof(string), "~r~Health:~w~ %.0f%%  ~n~~r~Time:~w~ %02d:%02d~n~~r~Weapon: ~w~%s~n~~r~Money: ~w~пїЅ%s",pH, t[0], t[1], aWeaponNames[GetPlayerWeapon(i)], number_format(PlayerTemp[i][sm]));
                //format(string, sizeof(string), "~g~Health:~w~ %.0f%%~n~~g~Weapon: ~w~%s~n~~g~Money: ~w~$%s", pH, aWeaponNames[GetPlayerWeapon(i)], number_format(PlayerTemp[i][sm]));
                TextDrawSetString(PlayerTemp[i][Status], string);
                if(tazed[ i ]) ApplyAnimation(i,"CRACK", "crckdeth2", 4.1, 0, 0, 0, 1, 1); // irl crack!
            }
            else
            {
                GetPlayerPos(i, x, y, z);
                distance = floatsqroot(floatpower(floatabs(floatsub(x,SavePlayerPos[i][LastX])),2)+floatpower(floatabs(floatsub(y,SavePlayerPos[i][LastY])),2)+floatpower(floatabs(floatsub(z,SavePlayerPos[i][LastZ])),2));
                value = floatround(distance * 5600);
                new Float:tmph;
                GetVehicleHealth(GetPlayerVehicleID(i), tmph);
                //format(string, sizeof(string), "~r~Health:~w~ %.0f%%  ~n~~r~Time:~w~ %02d:%02d~n~~r~Weapon:~w~%s~n~~r~Money: ~w~пїЅ%s~n~~r~Vehicle: ~w~%s~n~~r~Fuel:~w~ %d%%~n~~r~Speed: ~w~%d", aWeaponNames[GetPlayerWeapon(i)], number_format(PlayerTemp[i][sm]), GetVehicleName(GetPlayerVehicleID(i)), Gas[GetPlayerVehicleID(i)], floatround(value/600));
                format(string, sizeof(string), "~r~Speed: ~w~%d KM/H~n~~r~Fuel: ~w~%d%%~n~~r~Health: ~w~%d%", floatround(value/600), Gas[GetPlayerVehicleID(i)], floatround(floatdiv(tmph,10)));
                TextDrawSetString(PlayerTemp[i][Status], string);
                if(Gas[GetPlayerVehicleID(i)] <= 10 && IsPlayerDriver(i)) TDWarning(i, "you are running out of fuel!", 1400);
                if(Gas[GetPlayerVehicleID(i)] <= 0 && IsPlayerDriver(i)) RemovePlayerFromVehicle(i), SendClientInfo(i, "No fuel!");
                SavePlayerPos[i][LastX] = x;
                SavePlayerPos[i][LastY] = y;
                SavePlayerPos[i][LastZ] = z;
            }
        }
    }
    return 1;
}
Reply
#10

Quote:

if(GetPlayerState(i) == PLAYER_STATE_DRIVER || GetPlayerWeapon(i) == 24) SetPlayerArmedWeapon(i, 0);

Remove IsPlayerInAnyVehicle(i)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)