Textdraw help.
#1

pawn Код:
dcmd_stats(playerid,params[])
{
    #pragma unused params
    new pName[MAX_PLAYERS],string[128];
    new Float:health,Float:armour;
    GetPlayerHealth(playerid,health);
    GetPlayerArmour(playerid,armour);
    GetPlayerName(playerid,pName,32);
    SendClientMessage(playerid,COLOR_WHITE,"--------------------------------------STATS--------------------------------------");
    format(string,sizeof string,"Adminlevel: %i",PlayerInfo[playerid][level]);
    SendClientMessage(playerid,COLOR_RED,string);
    format(string,sizeof string,"Money: %i",GetPlayerMoney(playerid));
    SendClientMessage(playerid,COLOR_BLUE,string);
    format(string,sizeof string,"Ping: %i",GetPlayerPing(playerid));
    SendClientMessage(playerid,COLOR_ORANGE,string);
    format(string,sizeof string,"Health: %i || Armour: %i",health,armour);
    SendClientMessage(playerid,COLOR_GRAY,string);
    return 1;
}
How could I get that, to be used in a textdraw what shows on your screen in the centre, when you do the command /statson, then hide when you do the command /statsoff? Thank you for your help.
Reply
#2

pawn Код:
dcmd_stats(playerid,params[])
{
    #pragma unused params
    new pName[MAX_PLAYERS],string[128];
    new Float:health,Float:armour;
    GetPlayerHealth(playerid,health);
    GetPlayerArmour(playerid,armour);
    GetPlayerName(playerid,pName,32);
    //SendClientMessage(playerid,COLOR_WHITE,"--------------------------------------STATS--------------------------------------");
    format(string,sizeof string,"Adminlevel: %s",PlayerInfo[playerid][level]);
    TextDrawSetString(TextDrawName, string);
    format(string,sizeof string,"Money: %s",GetPlayerMoney(playerid));
    TextDrawSetString(TextDrawName, string);
    format(string,sizeof string,"Ping: %s",GetPlayerPing(playerid));
    TextDrawSetString(TextDrawName, string);
    format(string,sizeof string,"Health: %s || Armour: %s",health,armour);
    TextDrawSetString(TextDrawName, string);
    return 1;
}
if u want it to work you will need to creat the textdraw first

WIKI
Reply
#3

Okay, I have this...

pawn Код:
Stats = TextDrawCreate(232, 245, "stats");
    TextDrawFont(Stats , 2);
    TextDrawLetterSize(Stats , 0.5, 3.5);
    TextDrawColor(Stats , 0xFF0000FF);
    TextDrawSetOutline(Stats , 1);
    TextDrawSetProportional(Stats , 1);
    TextDrawSetShadow(Stats , 1);
    TextDrawUseBox(Stats,0);
What do I do? I tried to set the things that say... TextDrawName, to Stats, but when I am in game, it just shows a box?
Reply
#4

you do have
TextDrawShowForPlayer(playerid,Stats ); ??
EDIT
u would need
TextDrawTextSize
Reply
#5

Under the dcmd_stats thing? if so, then yes I do.
Reply
#6

just use a Text Draw In Game Editor it will make your job easier
i would suggest THIS
Reply
#7

Wait, could you gimmie a little bit of help please?, I have BSN textdraw Editor :3, and that's where I got the screen positions, and things.. but could you help me more? PM me on here, if you wanna, or add me to MSN, calpol21@hotmail.co.uk
Reply
#8

Create a global array variable like:
pawn Код:
new Text:Stats[MAX_PLAYERS];
After that you have to add the TextDrawCreate into OnPlayerConnect:
pawn Код:
public OnPlayerConnect(playerid)
{
    Stats[playerid] = TextDrawCreate(232.0, 245.0, " ");
    TextDrawFont(Stats[playerid], 2);
    TextDrawLetterSize(Stats[playerid], 0.5, 3.5);
    TextDrawColor(Stats[playerid], 0xFF0000FF);
    TextDrawSetOutline(Stats[playerid], 1);
    TextDrawSetProportional(Stats[playerid], 1);
    TextDrawSetShadow(Stats[playerid], 1);
    TextDrawUseBox(Stats[playerid], 0);
    return 1;
}
Now we will try to make the command:
pawn Код:
dcmd_statson(playerid, params[])
{
    new string[512], Float:health, Float:armour;
    GetPlayerHealth(playerid, health);
    GetPlayerArmour(playerid, armour);
    format(string, sizeof(string),"------STATS------~n~Adminlevel: %d~n~Money: %d~n~Ping: %d~n~Health: %d%% || Armour: %d%%", PlayerInfo[playerid][level], GetPlayerMoney(playerid), GetPlayerPing(playerid), floatround(health), floatround(armour));
    TextDrawSetString(Stats[playerid], string);
    TextDrawShowForPlayer(playerid, Stats[playerid]);
    return 1;
}
pawn Код:
dcmd_statsoff(playerid, params[])
{
    TextDrawHideForPlayer(playerid, Stats[playerid]);
    return 1;
}
And ofc lets don't forget to destroy the textdraw if the player disconnects:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    TextDrawDestroy(Stats[playerid]);
    return 1;
}
If you think the text might to look bad on your screen so you can change the values.
Hope this little tutorial helped you abit.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)