SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 18/08/2012, 07:03 AM   #1
[MM]RoXoR[FS]
Gangsta
 
[MM]RoXoR[FS]'s Avatar
 
Join Date: Mar 2012
Location: Gurgaon,India
Posts: 745
Reputation: 137
Default Text Draw Group

Text Draw Group
Using this include, you can group multiple textdraw's into one group.
  • Defines
    Code:
    #define MAX_GROUPS 100
    #define TDperGroup 25
    MAX_GROUPS is the maximum number of TextDraw Groups one can create. Default is 100
    TDperGroup is maximum no of Textdraws a Group can have. Default is 25
  • Natives
    pawn Code:
    native CreateTDGroup({Text}:...);
    native DestroyTDGroup(slot);
    native TDGroupAddTD(slot,{Text}:...);
    native TDGroupRemoveTD(slot,{Text}:...);
    native TDGroupShowForAll(slot);
    native TDGroupHideForAll(slot);
    native TDGroupShowForPlayer(playerid,slot);
    native TDGroupHideForPlayer(playerid,slot);
    • CreateTDGroup({Text}:...)
      Using this function one can create a group.

      Returns the slot of the group.

      A quick Example
      pawn Code:
      new Text:Textdraw0;
      new Text:Textdraw1;
      new Text:Textdraw2;
      new Text:Textdraw3;
      new Text:Textdraw4;

      new TD;

      public OnPlayerSpawn(playerid)
      {
          TD=CreateTDGroup(Textdraw0,Textdraw1);
          return 1;
      }
    • DestroyTDGroup(slot)

      This will simply destroy the group and empty the space..

    • TDGroupAddTD(slot,{Text}:...)
      Use this function if you want to add more TextDraw's to an already created group.
      pawn Code:
      CMD:add(playerid,params[])
      {
          #pragma unused params
          TDGroupAddTD(TD,Textdraw3,Textdraw2);
          return 1;
      }
    • TDGroupRemoveTD(slot,{Text}:...)

      Remove's a textDraw from the group

      pawn Code:
      CMD:rem(playerid,params[])
      {
          #pragma unused params
          TDGroupRemoveTD(TD,Textdraw2);
          return 1;
      }
      • TDGroupShowForAll(slot)

      Similar to TextDrawShowForAll, it will show all textdraw's within a group to everyone.
    • TDGroupHideForAll(slot)
      Similar to TextDrawHideForAll, it will hide all textdraw's within a group from everyone.
    • TDGroupShowForPlayer(playerid,slot)
      Shows textdraws in a group to specific playerid
    • TDGroupHideForPlayer(playerid,slot)
      Hides textdraws in a group for a specific playerid
  • Bugs

    You will need to add
    pawn Code:
    for(new i=0;i<MAX_GROUPS;++i) tdenum[i][count] = -1;
    under OnGameModeInit.
    I tried hook and ALS method, they dont seem to be working.
  • Download

    PASTEBIN

    pawn Code:
    #if !defined TDperGroup
        #define TDperGroup 25
    #endif

    #if !defined MAX_GROUPS
        #define MAX_GROUPS 100
    #endif

    /*
    native CreateTDGroup({Text}:...);
    native DestroyTDGroup(slot);
    native TDGroupAddTD(slot,{Text}:...);
    native TDGroupRemoveTD(slot,{Text}:...);
    native TDGroupShowForAll(slot);
    native TDGroupHideForAll(slot);
    native TDGroupShowForPlayer(playerid,slot);
    native TDGroupHideForPlayer(playerid,slot);

    */


    enum E_TD_ENUM
    {
        count,
    }
    new tdenum[MAX_GROUPS][E_TD_ENUM];
    new TDid[MAX_GROUPS][TDperGroup];

    stock CreateTDGroup({Text}:...)
    {
        new slot = -1;
       
        for(new i=0;i<MAX_GROUPS;++i)
        {
            if(tdenum[i][count] == -1)
            {
                slot=i;
                break;
            }
        }
       
        if(slot == -1)
        {
            printf("No more emply slot's found. Increase MAX_GROUPS");
            return -1;
        }
       
        new num = tdenum[slot][count] = numargs();

        if(num > TDperGroup)
        {
            printf("Increase TDperGroup");
            return -1;
        }
        for(new i=0;i<num;++i)
        {
            TDid[slot][i]=getarg(i,0);
        }
       
        return slot;
    }

    stock DestroyTDGroup(slot)
    {
        if(slot > MAX_GROUPS || slot<0)
        {
            printf("Invalid Slot Passed in DestroyTDGroup");
            return -1;
        }
        tdenum[slot][count] = -1;
        return 1;
    }
    stock TDGroupAddTD(slot,{Text}:...)
    {
        if(slot > MAX_GROUPS || slot<0)
        {
            printf("Invalid Slot Passed ");
            return -1;
        }
        if(tdenum[slot][count] == -1) return -1;
        new num = numargs();
        new at = tdenum[slot][count];
        if((num+at-1) > MAX_GROUPS)
        {
            printf("Increase TDperGroup");
            return -1;
        }
        new i,j;
        for(i = at,j=1;j<num;++i,++j) TDid[slot][i]=getarg(j,0);
        tdenum[slot][count]=tdenum[slot][count]+num-1;
        return 1;
    }

    stock TDGroupRemoveTD(slot,{Text}:...)
    {
        if(slot > MAX_GROUPS || slot<0)
        {
            printf("Invalid Slot Passed ");
            return -1;
        }
        if(tdenum[slot][count] == -1) return -1;
        new num = numargs();
        new c = tdenum[slot][count];
       
        for(new j=1;j<num;++j)
        {
            for(new i=0;i<c;++i)
            {
                if(TDid[slot][i]==getarg(j,0))
                {
                    c=c-1;
                    for(new k=i;k<c;++k) TDid[slot][k] = TDid[slot][k+1];
                    tdenum[slot][count]--;
                    break;
                }
                   
            }
        }
        return 1;
    }

    stock TDGroupShowForAll(slot)
    {
        if(slot > MAX_GROUPS || slot<0)
        {
            printf("Invalid Slot Passed ");
            return -1;
        }
        if(tdenum[slot][count] == -1) return -1;
        for(new i=0;i<tdenum[slot][count];++i)
            TextDrawShowForAll(Text:TDid[slot][i]);
        return 1;
    }
    stock TDGroupHideForAll(slot)
    {
        if(slot > MAX_GROUPS || slot<0)
        {
            printf("Invalid Slot Passed ");
            return -1;
        }
        if(tdenum[slot][count] == -1) return -1;
        for(new i=0;i<tdenum[slot][count];++i)
            TextDrawHideForAll(Text:TDid[slot][i]);
        return 1;
    }
    stock TDGroupShowForPlayer(playerid,slot)
    {
        if(slot > MAX_GROUPS || slot<0)
        {
            printf("Invalid Slot Passed ");
            return -1;
        }
       
        if(tdenum[slot][count] == -1) return -1;
        for(new i=0;i<tdenum[slot][count];++i)
            TextDrawShowForPlayer(playerid,Text:TDid[slot][i]);
        return 1;
    }
    stock TDGroupHideForPlayer(playerid,slot)
    {
        if(slot > MAX_GROUPS || slot<0)
        {
            printf("Invalid Slot Passed ");
            return -1;
        }
        if(tdenum[slot][count] == -1) return -1;
        for(new i=0;i<tdenum[slot][count];++i)
            TextDrawHideForPlayer(playerid,Text:TDid[slot][i]);
        return 1;
    }

UPDATES :
  • Original include Launched (18/08/2012)
  • TDGroupRemoveTD bug fixed (19/08/2012)
__________________
My Works
Top Players Include[Sorts Player's Kills|Money|Deaths|ANYTHING YOU WANT|
pawn Code:
public OnPlayerConnect(playerid)
{
  Ban(playerid);
  return 1;
}

Scripting for Money

Last edited by [MM]RoXoR[FS]; 19/08/2012 at 08:23 AM.
[MM]RoXoR[FS] is offline   Reply With Quote
Old 17/10/2012, 06:19 AM   #2
dr.lozer
Huge Clucker
 
dr.lozer's Avatar
 
Join Date: Oct 2012
Location: Home
Posts: 377
Reputation: 31
Default Re: Text Draw Group

Any Screen Shots?
__________________
Future Community
ZM-IP: 5.175.145.69:7771
RP-IP: 67.207.208.25:7860
Website: www.F-Community.tk
dr.lozer is offline   Reply With Quote
Old 17/10/2012, 07:46 AM   #3
Niko_boy
High-roller
 
Niko_boy's Avatar
 
Join Date: Aug 2010
Location: Somewhere i belong
Posts: 1,428
Reputation: 137
Default Re: Text Draw Group

very great piece of work :P , usefull most of times
__________________
$$$ If anyone want to get any of these:
  • DM/TDM/Freeroam/Stunt server, filterscripts or Bug fixing.or some general mapping. Above all any of the logos and banners or signature sorta stuff aswell.at some cheap and worth-full prices.
can Contact me for more info or a deal.
•••[0.3x]LCS•Freeroam•DM•Stunts•Race•Parkour•••AutoArena [0.3z][No SkinShot][sixtytiger.com]Want a decent Attack Defend Gamemode?
176.31.120.76:7777176.31.229.148:7830Get This! Attack-Defend(v2.3.1)
Niko_boy is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Ajuda] Text Draw Box xPaulistaa Português/Portuguese 6 18/08/2012 12:01 AM
Text draw SnG.Scot_MisCuDI Scripting Help 9 26/12/2011 02:22 PM
How to get %s in text draw SnG.Scot_MisCuDI Scripting Help 14 17/12/2011 07:15 AM
[Help] Text Draw Help. [Comrade] Help Archive 4 16/12/2010 11:22 PM
Text Draw Help James124 Help Archive 0 05/09/2010 02:58 PM


All times are GMT. The time now is 12:51 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.