18.08.2012, 07:03
(
Последний раз редактировалось [MM]RoXoR[FS]; 19.08.2012 в 08:23.
)
Text Draw Group
Using this include, you can group multiple textdraw's into one group.- Defines
Код:#define MAX_GROUPS 100 #define TDperGroup 25
TDperGroup is maximum no of Textdraws a Group can have. Default is 25 - Natives
pawn Код: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 Код: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 Код:CMD:add(playerid,params[])
{
#pragma unused params
TDGroupAddTD(TD,Textdraw3,Textdraw2);
return 1;
} - TDGroupRemoveTD(slot,{Text}:...)
Remove's a textDraw from the group
pawn Код: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
- CreateTDGroup({Text}:...)
- Bugs
You will need to add
pawn Код:for(new i=0;i<MAX_GROUPS;++i) tdenum[i][count] = -1;
I tried hook and ALS method, they dont seem to be working. - Download
PASTEBIN
pawn Код:#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;
}
- Original include Launched (18/08/2012)
- TDGroupRemoveTD bug fixed (19/08/2012)