Player ID Listed in TextDraw?
#1

Hello there! I am requesting help, as title says, about making a Textdraw enlisting player ids in it.

Код:
#include a-samp
#include foreach
#include sscanf2

#define TEAM_ZERO 0
#define TEAM_ONE 1

new Text:TextDraw[2],syncstring[512];

forward sync();

ModeInit()
{
SetTimer("sync",1000,true);
TeamTextDraw[0]=TextDrawCreate(coords,"_~n~");
TeamTextDraw[1]=TextDrawCreate(coords,"_~n~");
return 1;
}
public OnPlayerSpawn(....)
{
if(....)
{
SetPlayerTeam(playerid,TEAM_ZERO);
TextDrawShowForPlayer(playerid,TextDraw[0]);
}
else 
{
SetPlayerTeam(playerid,TEAM_ONE);
TextDrawShowForPlayer(playerid,TextDraw[1]);
}
return 1;
}
public sync()
{
foreach(Player,i)
{
if(GetPlayerTeam(i)==0)
{
format(syncstring,sizeof(syncstring),"TEAM ZERO IDS~n~%d~n~",i);
TextDrawSetString(TextDraw[0],syncstring);
}
else if(GetPlayerTeam(i)==1)
{
format(syncstring,sizeof(syncstring),"TEAM ONE IDS~n~%d~n~",i);
TextDrawSetString(TextDraw[1],syncstring);
}
return 1;
}
In the TextDraw will appear only ONE id and not everyones in that team!
Anyone please?

+REP
Reply
#2

I didn't tested, but you can do something like this:

PHP код:
public sync()
{
    new 
ids[64][2];
    foreach(
Player,i)
    {
        switch(
GetPlayerTeam(i))
        {
            case 
.. 1:
            {
                
format(ids[i], 64,"%d~n~%s"iids[i]);
            }
        }
    }
    
format(syncstring,sizeof(syncstring),"TEAM ZERO IDS~n~%s~n~",ids[0]);
    
TextDrawSetString(TextDraw[0],syncstring);
    
format(syncstring,sizeof(syncstring),"TEAM ONE IDS~n~%s~n~",ids[1]);
    
TextDrawSetString(TextDraw[1],syncstring);
    return 
1;

Reply
#3

Код:
public sync() 
{ 
    new ids[64][2]; 
    foreach(Player,i) 
    { 
        switch(GetPlayerTeam(i)) 
        { 
            case 0 .. 1: 
            { 
                format(ids[i], 64,"%d~n~%s", i, ids[i]); 
            } 
        } 
    } 
    format(syncstring,sizeof(syncstring),"TEAM ZERO IDS~n~%s~n~",ids[0]); 
    TextDrawSetString(TextDraw[0],syncstring); 
    format(syncstring,sizeof(syncstring),"TEAM ONE IDS~n~%s~n~",ids[1]); 
    TextDrawSetString(TextDraw[1],syncstring); 
}
return 1; 
}
I had to modify this to:

Код:
public sync() 
    { 
    new ids[64][2]; 
    switch(GetPlayerTeam(i)) 
    { 
    case 0 :
    format(ids[0], 64,"%d~n~%s", i, ids[0]); 
    } 
    case 1:
    {
    format(ids[1], 64,"%d~n~%s", i, ids[1]);
    }
    } 
    } 
    format(syncstring,sizeof(syncstring),"TEAM ZERO IDS~n~%s~n~",ids[0]); 
    TextDrawSetString(TextDraw[0],syncstring); 
    format(syncstring,sizeof(syncstring),"TEAM ONE IDS~n~%s~n~",ids[1]); 
    TextDrawSetString(TextDraw[1],syncstring); 
}
return 1; 
}
But seems not to work, only 1 id is visible
Reply
#4

That's because you removed the loop
Reply
#5

Okay I will try.. but how to make team 0 ids visible only for them?
Reply
#6

Quote:
Originally Posted by kanerandyfirst
Посмотреть сообщение
Okay I will try.. but how to make team 0 ids visible only for them?
Do you want to let only players with team 0 to see Team 0 players ids?
Reply
#7

Yes, like a list of their team ids
Reply
#8

Quote:
Originally Posted by kanerandyfirst
Посмотреть сообщение
Yes, like a list of their team ids
But you already made two different textdraws: the first one is for Team 0 and the second one is for Team 1. One of these two textdraws is shown when the player spawns, if the player is Team 0 he will see the first textdraw and if he is Team 1 he will see the second one.

I don't know exactly which are the conditions under OnPlayerSpawn; in the way you do everytime he spawns we will be setted again in once of the two teams and he will see again the textdraw.
Reply
#9

Yes there are two "if"
Код:
if(GetPlayerTeam(playerid))==0)TextDrawHideForPlayer(playerid,TeamText[1]);
if(GetPlayerTeam(playerid))==1)TextDrawHideForPlayer(playerid,TeamText[0]);
in another function, but I am trying to make a list with all ids a team has in.
When a player spawns,
Код:
ShowPlayerDialog(playerid,DIALOG_TEAM_SWITCH,DIALOG_STLYE_LIST,"Please pick up your team","Team Zero\nTeam One","Select","");
I thought, maybe strcat could be of some use?
Reply
#10

Quote:
Originally Posted by kanerandyfirst
Посмотреть сообщение
Yes there are two "if"
Код:
if(GetPlayerTeam(playerid))==0)TextDrawHideForPlayer(playerid,TeamText[1]);
if(GetPlayerTeam(playerid))==1)TextDrawHideForPlayer(playerid,TeamText[0]);
in another function, but I am trying to make a list with all ids a team has in.
When a player spawns,
Код:
ShowPlayerDialog(playerid,DIALOG_TEAM_SWITCH,DIALOG_STLYE_LIST,"Please pick up your team","Team Zero\nTeam One","Select","");
I thought, maybe strcat could be of some use?
And you want this list on the textdraw, right? What about the function I've said the first time?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)