SA-MP Forums Archive
OnPlayerPickupPickup - Hidetextdraw - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnPlayerPickupPickup - Hidetextdraw (/showthread.php?tid=474179)



OnPlayerPickupPickup - Hidetextdraw - Chrillzen - 06.11.2013

Hey, I've fixed that whenever a player enters a pickup a textdraw shows. Now, I want the textdraws to hide whenever they leave the pickup.
Help, please.

pawn Код:
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
    new string[256];
    for(new b = 1;b < sizeof(BusinessInfo);b++)
    {
        if(pickupid == BusinessInfo[b][bOutsideIcon])
        {
           if(BusinessInfo[b][bOwned] == 0)
           {
                format(string, sizeof(string), "%s", BusinessType(b));
                TextDrawSetString(Textdraw7, string);
               
                format(string, sizeof(string), "%s", BusinessInfo[b][bName]);
                TextDrawSetString(Textdraw6, string);
               
                format(string, sizeof(string), "%d", BusinessInfo[b][bPrice]);
                TextDrawSetString(Textdraw8, string);
               
                format(string, sizeof(string), "%i", b);
                TextDrawSetString(Textdraw9, string);
               
                TextDrawShowForPlayer(playerid,Textdraw0);
                TextDrawShowForPlayer(playerid,Textdraw1);
                TextDrawShowForPlayer(playerid,Textdraw2);
                TextDrawShowForPlayer(playerid,Textdraw3);
                TextDrawShowForPlayer(playerid,Textdraw4);
                TextDrawShowForPlayer(playerid,Textdraw6);
                TextDrawShowForPlayer(playerid,Textdraw7);
                TextDrawShowForPlayer(playerid,Textdraw8);
                TextDrawShowForPlayer(playerid,Textdraw9);
                TextDrawShowForPlayer(playerid,Textdraw10);
                TextDrawShowForPlayer(playerid,Textdraw12);
                TextDrawShowForPlayer(playerid,Textdraw13);
           }
           if(BusinessInfo[b][bOwned] == 1)
           {
           
                format(string, sizeof(string), "%s", BusinessType(b));
                TextDrawSetString(Textdraw7, string);

                format(string, sizeof(string), "%s", BusinessInfo[b][bName]);
                TextDrawSetString(Textdraw6, string);

                format(string, sizeof(string), "%d", BusinessInfo[b][bPrice]);
                TextDrawSetString(Textdraw8, string);

                format(string, sizeof(string), "%i", b);
                TextDrawSetString(Textdraw9, string);
               
                TextDrawShowForPlayer(playerid,Textdraw0);
                TextDrawShowForPlayer(playerid,Textdraw1);
                TextDrawShowForPlayer(playerid,Textdraw2);
                TextDrawShowForPlayer(playerid,Textdraw3);
                TextDrawShowForPlayer(playerid,Textdraw4);
                TextDrawShowForPlayer(playerid,Textdraw6);
                TextDrawShowForPlayer(playerid,Textdraw7);
                TextDrawShowForPlayer(playerid,Textdraw8);
                TextDrawShowForPlayer(playerid,Textdraw9);
                TextDrawShowForPlayer(playerid,Textdraw10);
                TextDrawShowForPlayer(playerid,Textdraw12);
                TextDrawShowForPlayer(playerid,Textdraw13);
           }
        }
    }
    return 1;
}



Re: OnPlayerPickupPickup - Hidetextdraw - Pottus - 06.11.2013

Just use a timer to hide it.


Re: OnPlayerPickupPickup - Hidetextdraw - Chrillzen - 06.11.2013

Alright, thanks.


Re: OnPlayerPickupPickup - Hidetextdraw - Chrillzen - 06.11.2013

Hmm, it's pretty buggy. If you're standing at the pickup all the time it keeps reloading due to the timer hiding it.


Re: OnPlayerPickupPickup - Hidetextdraw - erminpr0 - 06.11.2013

pawn Код:
new bool: pickedUp[MAX_PLAYERS];
when 1st time pickup set pickedUp to true,

and add a check if pickedUp is true to return false, I mean not showing textdraws..


Re: OnPlayerPickupPickup - Hidetextdraw - Chrillzen - 06.11.2013

I don't get it..

This is what I got so far; setting it to true whenever he picks up the pickup. How do I check when he leaves it?

pawn Код:
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
    new string[256];
    for(new b = 1;b < sizeof(BusinessInfo);b++)
    {
        if(pickupid == BusinessInfo[b][bOutsideIcon])
        {
           if(BusinessInfo[b][bOwned] == 0)
           {
                pickedUp = true;
                format(string, sizeof(string), "%s", BusinessType(b));
                TextDrawSetString(Textdraw7, string);
               
                format(string, sizeof(string), "%s", BusinessInfo[b][bName]);
                TextDrawSetString(Textdraw6, string);
               
                format(string, sizeof(string), "%d", BusinessInfo[b][bPrice]);
                TextDrawSetString(Textdraw8, string);
               
                format(string, sizeof(string), "%i", b);
                TextDrawSetString(Textdraw9, string);
               
                TextDrawShowForPlayer(playerid,Textdraw0);
                TextDrawShowForPlayer(playerid,Textdraw1);
                TextDrawShowForPlayer(playerid,Textdraw2);
                TextDrawShowForPlayer(playerid,Textdraw3);
                TextDrawShowForPlayer(playerid,Textdraw4);
                TextDrawShowForPlayer(playerid,Textdraw6);
                TextDrawShowForPlayer(playerid,Textdraw7);
                TextDrawShowForPlayer(playerid,Textdraw8);
                TextDrawShowForPlayer(playerid,Textdraw9);
                TextDrawShowForPlayer(playerid,Textdraw10);
                TextDrawShowForPlayer(playerid,Textdraw12);
                TextDrawShowForPlayer(playerid,Textdraw13);
           }
           if(BusinessInfo[b][bOwned] == 1)
           {
                pickedUp = true;
                format(string, sizeof(string), "%s", BusinessType(b));
                TextDrawSetString(Textdraw7, string);

                format(string, sizeof(string), "%s", BusinessInfo[b][bName]);
                TextDrawSetString(Textdraw6, string);

                format(string, sizeof(string), "%d", BusinessInfo[b][bPrice]);
                TextDrawSetString(Textdraw8, string);

                format(string, sizeof(string), "%i", b);
                TextDrawSetString(Textdraw9, string);
               
                format(string, sizeof(string), "%s", BusinessInfo[b][bOwner]);
                TextDrawSetString(Textdraw11, string);
               
                TextDrawShowForPlayer(playerid,Textdraw0);
                TextDrawShowForPlayer(playerid,Textdraw1);
                TextDrawShowForPlayer(playerid,Textdraw2);
                TextDrawShowForPlayer(playerid,Textdraw3);
                TextDrawShowForPlayer(playerid,Textdraw4);
                TextDrawShowForPlayer(playerid,Textdraw6);
                TextDrawShowForPlayer(playerid,Textdraw7);
                TextDrawShowForPlayer(playerid,Textdraw8);
                TextDrawShowForPlayer(playerid,Textdraw9);
                TextDrawShowForPlayer(playerid,Textdraw10);
                TextDrawShowForPlayer(playerid,Textdraw11);
                TextDrawShowForPlayer(playerid,Textdraw5);
           }
        }
    }
    return 1;
}



Re: OnPlayerPickupPickup - Hidetextdraw - erminpr0 - 06.11.2013

pawn Код:
new bool: pickedUp[MAX_PLAYERS];
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
    new string[256];
    for(new b = 1;b < sizeof(BusinessInfo);b++)
    {
        if(pickupid == BusinessInfo[b][bOutsideIcon])
        {
           if( pickedUp [ playerid ] == true ) return false;
           if(BusinessInfo[b][bOwned] == 0)
           {
                pickedUp[ playerid ] = true;
                format(string, sizeof(string), "%s", BusinessType(b));
                TextDrawSetString(Textdraw7, string);
               
                format(string, sizeof(string), "%s", BusinessInfo[b][bName]);
                TextDrawSetString(Textdraw6, string);
               
                format(string, sizeof(string), "%d", BusinessInfo[b][bPrice]);
                TextDrawSetString(Textdraw8, string);
               
                format(string, sizeof(string), "%i", b);
                TextDrawSetString(Textdraw9, string);
               
                TextDrawShowForPlayer(playerid,Textdraw0);
                TextDrawShowForPlayer(playerid,Textdraw1);
                TextDrawShowForPlayer(playerid,Textdraw2);
                TextDrawShowForPlayer(playerid,Textdraw3);
                TextDrawShowForPlayer(playerid,Textdraw4);
                TextDrawShowForPlayer(playerid,Textdraw6);
                TextDrawShowForPlayer(playerid,Textdraw7);
                TextDrawShowForPlayer(playerid,Textdraw8);
                TextDrawShowForPlayer(playerid,Textdraw9);
                TextDrawShowForPlayer(playerid,Textdraw10);
                TextDrawShowForPlayer(playerid,Textdraw12);
                TextDrawShowForPlayer(playerid,Textdraw13);
           }
           if(BusinessInfo[b][bOwned] == 1)
           {
                pickedUp[ playerid ] = true;
                format(string, sizeof(string), "%s", BusinessType(b));
                TextDrawSetString(Textdraw7, string);

                format(string, sizeof(string), "%s", BusinessInfo[b][bName]);
                TextDrawSetString(Textdraw6, string);

                format(string, sizeof(string), "%d", BusinessInfo[b][bPrice]);
                TextDrawSetString(Textdraw8, string);

                format(string, sizeof(string), "%i", b);
                TextDrawSetString(Textdraw9, string);
               
                format(string, sizeof(string), "%s", BusinessInfo[b][bOwner]);
                TextDrawSetString(Textdraw11, string);
               
                TextDrawShowForPlayer(playerid,Textdraw0);
                TextDrawShowForPlayer(playerid,Textdraw1);
                TextDrawShowForPlayer(playerid,Textdraw2);
                TextDrawShowForPlayer(playerid,Textdraw3);
                TextDrawShowForPlayer(playerid,Textdraw4);
                TextDrawShowForPlayer(playerid,Textdraw6);
                TextDrawShowForPlayer(playerid,Textdraw7);
                TextDrawShowForPlayer(playerid,Textdraw8);
                TextDrawShowForPlayer(playerid,Textdraw9);
                TextDrawShowForPlayer(playerid,Textdraw10);
                TextDrawShowForPlayer(playerid,Textdraw11);
                TextDrawShowForPlayer(playerid,Textdraw5);
           }
        }
    }
    return 1;
}

public OnPlayerUpdate(playerid)
{
   if(IsPlayerInRangeOfPoint(playerid, 1.5, X, Y, Z)) // coords of your pickup
   {
        pickedUp[ playerid ] = true;
   }
   else if(!IsPlayerInRangeOfPoint(playerid, 1.5, X, Y, Z)) // same here
   {
        nearPickup[ playerid ] = false;
   }
   return 1;
}



Re: OnPlayerPickupPickup - Hidetextdraw - Chrillzen - 06.11.2013

I'll test it.


Re: OnPlayerPickupPickup - Hidetextdraw - Chrillzen - 06.11.2013

It keeps updating, it dissapears and appears.. (flickering)

pawn Код:
public OnPlayerUpdate(playerid)
{
    for(new b = 1; b < sizeof(BusinessInfo); b++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 5.0, BusinessInfo[b][bEntranceX], BusinessInfo[b][bEntranceY], BusinessInfo[b][bEntranceZ]))
        {
            pickedUp[ playerid ] = true;
        }
        if(!IsPlayerInRangeOfPoint(playerid, 5.0, BusinessInfo[b][bEntranceX], BusinessInfo[b][bEntranceY], BusinessInfo[b][bEntranceZ]))
        {
            pickedUp[ playerid ] = false;
            TextDrawHideForPlayer(playerid,Textdraw0);
            TextDrawHideForPlayer(playerid,Textdraw1);
            TextDrawHideForPlayer(playerid,Textdraw2);
            TextDrawHideForPlayer(playerid,Textdraw3);
            TextDrawHideForPlayer(playerid,Textdraw5);
            TextDrawHideForPlayer(playerid,Textdraw4);
            TextDrawHideForPlayer(playerid,Textdraw6);
            TextDrawHideForPlayer(playerid,Textdraw7);
            TextDrawHideForPlayer(playerid,Textdraw8);
            TextDrawHideForPlayer(playerid,Textdraw9);
            TextDrawHideForPlayer(playerid,Textdraw10);
            TextDrawHideForPlayer(playerid,Textdraw11);
            TextDrawHideForPlayer(playerid,Textdraw12);
            TextDrawHideForPlayer(playerid,Textdraw13);
        }
    }
    return 1;
}