TextDrawSetString, IsPlayerInArea, and more bugs!
#3

Quote:
Originally Posted by Dreftas
Why don't you show the code?
I don't know why that must be needed, but here it is:
pawn Код:
new Text:CarBar[MAX_PLAYERS];
new Text:CarBarBG;
new Text:CarBarBorder;
new Text:HealthBarBG;
new Text:ArmourBarBG;
new Text:TextdrawMoney[MAX_PLAYERS];
new Text:HealthBar[MAX_PLAYERS];
new Text:ArmourBar[MAX_PLAYERS];

forward PlayerStats(playerid);
forward AreaCheck(playerid);
forward MoneyCheck(playerid);

public OnGameModeInit()
{
  //CarHealth Border
    CarBarBorder = TextDrawCreate(546.000000,41.000000,".");
    TextDrawAlignment(CarBarBorder,1);
    TextDrawBackgroundColor(CarBarBorder,BLACK);
    TextDrawFont(CarBarBorder,3);
    TextDrawLetterSize(CarBarBorder,0.06,2.9);
    TextDrawColor(CarBarBorder,BLACK);
    TextDrawSetOutline(CarBarBorder,1);
    TextDrawSetProportional(CarBarBorder,1);
    TextDrawSetShadow(CarBarBorder,1);

    //CarHealth BackGround
    CarBarBG = TextDrawCreate(548.000000,42.000000,".");
    TextDrawAlignment(CarBarBG,1);
    TextDrawBackgroundColor(CarBarBG,GRAY);
    TextDrawFont(CarBarBG,3);
    TextDrawLetterSize(CarBarBG,0.058,2.549999);
    TextDrawColor(CarBarBG,GRAY);
    TextDrawSetOutline(CarBarBG,1);
    TextDrawSetProportional(CarBarBG,1);
    TextDrawSetShadow(CarBarBG,1);
    //Health BackGround
    HealthBarBG = TextDrawCreate(548.000000,52.000000,"...................................................................................................");
    TextDrawAlignment(HealthBarBG,1);
    TextDrawBackgroundColor(HealthBarBG,GRAY);
    TextDrawFont(HealthBarBG,3);
    TextDrawLetterSize(HealthBarBG,0.058,2.549999);
    TextDrawColor(HealthBarBG,GRAY);
    TextDrawSetOutline(HealthBarBG,1);
    TextDrawSetProportional(HealthBarBG,1);
    TextDrawSetShadow(HealthBarBG,1);

    //Armour BackGround
    ArmourBarBG = TextDrawCreate(548.000000,30.500000,"...................................................................................................");
    TextDrawAlignment(ArmourBarBG,1);
    TextDrawBackgroundColor(ArmourBarBG,GRAY);
    TextDrawFont(ArmourBarBG,3);
    TextDrawLetterSize(ArmourBarBG,0.058,2.549999);
    TextDrawColor(ArmourBarBG,GRAY);
    TextDrawSetOutline(ArmourBarBG,1);
    TextDrawSetProportional(ArmourBarBG,1);
    TextDrawSetShadow(ArmourBarBG,1);

    SetTimer("PlayerStats", 1000, true);
    SetTimer("AreaCheck", 1000, true);
    SetTimer("MoneyCheck", 500, true);
}

public OnPlayerConnect(playerid)
{
//Money TextDraw
    TextdrawMoney[playerid] = TextDrawCreate(498.600000,76.000000,"$00000000");
    TextDrawAlignment(TextdrawMoney[playerid],0);
    TextDrawBackgroundColor(TextdrawMoney[playerid],BLACK);
    TextDrawFont(TextdrawMoney[playerid],3);
    TextDrawLetterSize(TextdrawMoney[playerid],0.59,2.45);
    TextDrawColor(TextdrawMoney[playerid],WHITE);
    TextDrawSetOutline(TextdrawMoney[playerid],1);
    TextDrawSetProportional(TextdrawMoney[playerid],1);

    //HealthBar
    HealthBar[playerid] = TextDrawCreate(548.000000,52.000000,"...................................................................................................");
    TextDrawAlignment(HealthBar[playerid],1);
    TextDrawBackgroundColor(HealthBar[playerid],WHITE);
    TextDrawFont(HealthBar[playerid],3);
    TextDrawLetterSize(HealthBar[playerid],0.058,2.549999);
    TextDrawColor(HealthBar[playerid],WHITE);
    TextDrawSetOutline(HealthBar[playerid],1);
    TextDrawSetProportional(HealthBar[playerid],1);
    TextDrawSetShadow(HealthBar[playerid],1);

    //ArmourBar
    ArmourBar[playerid] = TextDrawCreate(548.000000,30.500000,"...................................................................................................");
    TextDrawAlignment(ArmourBar[playerid],1);
    TextDrawBackgroundColor(ArmourBar[playerid],WHITE);
    TextDrawFont(ArmourBar[playerid],3);
    TextDrawLetterSize(ArmourBar[playerid],0.058,2.549999);
    TextDrawColor(ArmourBar[playerid],WHITE);
    TextDrawSetOutline(ArmourBar[playerid],1);
    TextDrawSetProportional(ArmourBar[playerid],1);
    TextDrawSetShadow(ArmourBar[playerid],1);
   
    //CarHealthBar
    CarBar[playerid] = TextDrawCreate(548.000000,42.000000,"...................................................................................................");
    TextDrawAlignment(CarBar[playerid],1);
    TextDrawBackgroundColor(CarBar[playerid],WHITE);
    TextDrawFont(CarBar[playerid],3);
    TextDrawLetterSize(CarBar[playerid],0.058,2.549999);
    TextDrawColor(CarBar[playerid],WHITE);
    TextDrawSetOutline(CarBar[playerid],1);
    TextDrawSetProportional(CarBar[playerid],1);
    TextDrawSetShadow(CarBar[playerid],1);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    TextDrawHideForPlayer(playerid,ArmourBarBG);
    TextDrawDestroy(CarBar[playerid]);
    TextDrawHideForPlayer(playerid,CarBarBorder);
    TextDrawHideForPlayer(playerid,CarBarBG);
    TextDrawDestroy(TextdrawMoney[playerid]);
    TextDrawDestroy(HealthBar[playerid]);
    TextDrawDestroy(ArmourBar[playerid]);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer(playerid,HealthBarBG);
    TextDrawShowForPlayer(playerid,ArmourBarBG);
    TextDrawHideForPlayer(playerid,CarBar[playerid]);
    TextDrawHideForPlayer(playerid,CarBarBorder);
    TextDrawHideForPlayer(playerid,CarBarBG);
    TextDrawShowForPlayer(playerid,TextdrawMoney[playerid]);
    TextDrawSetString(HealthBar[playerid],"...................................................................................................");
    TextDrawSetString(ArmourBar[playerid],"...................................................................................................");
    TextDrawShowForPlayer(playerid,HealthBar[playerid]);
    TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
    return 1;
}

public PlayerStats(playerid)
{
    new Float:Health[MAX_PLAYERS];
    new Float:Armour[MAX_PLAYERS];
    GetPlayerHealth(playerid, Health[playerid]);
    GetPlayerArmour(playerid, Armour[playerid]);

    //HealthBar
    if(Health[playerid] == 100){TextDrawSetString(HealthBar[playerid],"...................................................................................................");}
    else if(Health[playerid] >= 99){TextDrawSetString(HealthBar[playerid],"...................................................................................................");}
    else if(Health[playerid] >= 98){TextDrawSetString(HealthBar[playerid],"..................................................................................................");}
//blah
    else if(Health[playerid] >= 2){TextDrawSetString(HealthBar[playerid],"..");}
    else if(Health[playerid] >= 1){TextDrawSetString(HealthBar[playerid],".");}
    else if(Health[playerid] >= 0){TextDrawHideForPlayer(playerid,HealthBar[playerid]);}

    //ArmourBar
    if(Armour[playerid] >= 100){TextDrawSetString(ArmourBar[playerid],"...................................................................................................");}
    else if(Armour[playerid] >= 99){TextDrawSetString(ArmourBar[playerid],"...................................................................................................");}
//blah
    else if(Armour[playerid] >= 3){TextDrawSetString(ArmourBar[playerid],"...");}
    else if(Armour[playerid] >= 2){TextDrawSetString(ArmourBar[playerid],"..");}
    else if(Armour[playerid] >= 1){TextDrawSetString(ArmourBar[playerid],".");}

    //Health adding
    if(Health[playerid] < 100.0)
    {
        SetPlayerHealth(playerid,Health[playerid]+1.0);
    }

    if(IsPlayerInAnyVehicle(playerid))
    {
        new Float:CarHealth[MAX_PLAYERS];
        GetVehicleHealth(GetPlayerVehicleID(playerid), CarHealth[playerid]);

        //CarHealthBar
        if(CarHealth[playerid] >= 1000.0){TextDrawSetString(CarBar[playerid],"...................................................................................................");}
        else if(CarHealth[playerid] >= 990.0){TextDrawSetString(CarBar[playerid],"...................................................................................................");}
//Blah
        else if(CarHealth[playerid] >= 20.0){TextDrawSetString(CarBar[playerid],"..");}
        else if(CarHealth[playerid] >= 10.0){TextDrawSetString(CarBar[playerid],".");}
        else if(CarHealth[playerid] >= 0.0)
        {
            TextDrawHideForPlayer(playerid,CarBar[playerid]);
            TextDrawHideForPlayer(playerid,CarBarBorder);
            TextDrawHideForPlayer(playerid,CarBarBG);
        }

        //SetHealth
        if(InArea[playerid] == false)
        {
            if(CarHealth[playerid] < 1000.0)
            {
                SetVehicleHealth(GetPlayerVehicleID(playerid), 1000.0);
            }
        }
    }
    return 1;
}

public AreaCheck(playerid)
{
    new Float:px, Float:py, Float:pz;
    GetPlayerPos(playerid, px, py, pz);
    if(px <= 435.8742 && px >= -69.6844 && py <= 2145.3838 && py >= 1632.2196)
    {
        InArea[playerid] = true;
        if(WeaponGived[playerid] == false)
        {
            GivePlayerWeapon(playerid, 29, 1000);
            GivePlayerWeapon(playerid, 31, 500);
            WeaponGived[playerid] = true;
        }
    }
}

public MoneyCheck(playerid)
{
    new PlayerMoneyCheck[MAX_PLAYERS];
    new string[256];
    PlayerMoneyCheck[playerid] = GetPlayerMoney(playerid);
    format(string, sizeof(string), "$%08d", PlayerMoneyCheck[playerid]);
    TextDrawSetString(TextdrawMoney[playerid], string);
}
So, that was a lot of code. TextDrawSetString, Health Adding and cargod, and IsPlayerInArea only works for playerid 0, all players above 0 will not have all this things. They see only the textdraws, but it never changes.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)