I need help with Text Draws.
#1

So i have my text draws

pawn Код:
Textdraw4 = TextDrawCreate(472.000000, 148.000000, "Rank:");
    TextDrawBackgroundColor(Textdraw0, 65535);
    TextDrawFont(Textdraw0, 1);
    TextDrawLetterSize(Textdraw0, 0.529999, 2.000000);
    TextDrawColor(Textdraw0, 16777215);
    TextDrawSetOutline(Textdraw0, 1);
    TextDrawSetProportional(Textdraw0, 1);

    Textdraw5 = TextDrawCreate(472.000000, 172.000000, "Kills:");
    TextDrawBackgroundColor(Textdraw1, 65535);
    TextDrawFont(Textdraw1, 1);
    TextDrawLetterSize(Textdraw1, 0.629998, 2.200000);
    TextDrawColor(Textdraw1, 16777215);
    TextDrawSetOutline(Textdraw1, 1);
    TextDrawSetProportional(Textdraw1, 1);

    Textdraw6 = TextDrawCreate(472.000000, 197.000000, "Deaths:");
    TextDrawBackgroundColor(Textdraw2, 65535);
    TextDrawFont(Textdraw2, 1);
    TextDrawLetterSize(Textdraw2, 0.479999, 2.299998);
    TextDrawColor(Textdraw2, 16777215);
    TextDrawSetOutline(Textdraw2, 1);
    TextDrawSetProportional(Textdraw2, 1);

    Textdraw7 = TextDrawCreate(472.000000, 224.000000, "Health:");
    TextDrawBackgroundColor(Textdraw3, 65535);
    TextDrawFont(Textdraw3, 1);
    TextDrawLetterSize(Textdraw3, 0.500000, 2.099999);
    TextDrawColor(Textdraw3, 16777215);
    TextDrawSetOutline(Textdraw3, 1);
    TextDrawSetProportional(Textdraw3, 1);
I want my health,kills,deaths to show here. I can do Rank by myself but can anyone help me with this?
Reply
#2

Example for health:

Код:
new string[64];
format(string,sizeof(string),"Health: %i",GetPlayerHealth(playerid));
TextDrawSetString(Textdraw7,string);
Do the same for kills and death. All you have to do is to change it so it inputs the amount of kills or death into the %i (means the script has to read it from the userfile where you save the player's deaths and kills).
Also don't forget the timer to check the player's health regularily
Reply
#3

You would need a health timer for the health but I'm sure you already have a timer that you can just add to. Here is how you would do kills and deaths.
pawn Код:
new Text:Textdraw5[MAX_PLAYERS];
new Text:Textdraw6[MAX_PLAYERS];
new deaths[MAX_PLAYERS];
new kills[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
    Textdraw5[playerid] = TextDrawCreate(472.000000, 172.000000, "Kills:");
    TextDrawBackgroundColor(Textdraw5[playerid], 65535);
    TextDrawFont(Textdraw5[playerid], 1);
    TextDrawLetterSize(Textdraw5[playerid], 0.629998, 2.200000);
    TextDrawColor(Textdraw5[playerid], 16777215);
    TextDrawSetOutline(Textdraw5[playerid], 1);
    TextDrawSetProportional(Textdraw5[playerid], 1);
    Textdraw6[playerid] = TextDrawCreate(472.000000, 197.000000, "Deaths:");
    TextDrawBackgroundColor(Textdraw6[playerid], 65535);
    TextDrawFont(Textdraw6[playerid], 1);
    TextDrawLetterSize(Textdraw6[playerid], 0.479999, 2.299998);
    TextDrawColor(Textdraw6[playerid], 16777215);
    TextDrawSetOutline(Textdraw6[playerid], 1);
    TextDrawSetProportional(Textdraw6[playerid], 1);
    TextDrawShowForPlayer(playerid, Textdraw5[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw6[playerid]);
    return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID) kills[killerid]++;
    deaths[playerid] ++;
    new str[40];
    format(str, sizeof(str), "Kills: %d", kills[killerid]);
    TextDrawSetString(Textdraw5[killerid], str);
    format(str, sizeof(str), "Deaths: %d", deaths[playerid]);
    TextDrawSetString(Textdraw6[playerid], str);
    return 1;
}
EDIT:


Quote:
Originally Posted by Drebin
Посмотреть сообщение
Example for health:

Код:
new string[64];
format(string,sizeof(string),"Health: %i",GetPlayerHealth(playerid));
TextDrawSetString(Textdraw7,string);
Do the same for kills and death. All you have to do is to change it so it inputs the amount of kills or death into the %i (means the script has to read it from the userfile where you save the player's deaths and kills).
There is a few errors in your code there
1. GetPlayerHealth is a float %f not a integer.
2. GetPlayerHealth has mutliple params
pawn Код:
new Float:Health;
GetPlayerHealth(playerid, Health);
3. You need a textdraw for each player.
Reply
#4

You'd have to run a timer to update the players health textdraw, every second or so.

EDIT: Aw, crap.
Reply
#5

Quote:
Originally Posted by [HiC]TheKiller
Посмотреть сообщение
You would need a health timer for the health but I'm sure you already have a timer that you can just add to. Here is how you would do kills and deaths.
pawn Код:
new Text:Textdraw5[MAX_PLAYERS];
new Text:Textdraw6[MAX_PLAYERS];
new deaths[MAX_PLAYERS];
new kills[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
    Textdraw5[playerid] = TextDrawCreate(472.000000, 172.000000, "Kills:");
    TextDrawBackgroundColor(Textdraw5[playerid], 65535);
    TextDrawFont(Textdraw5[playerid], 1);
    TextDrawLetterSize(Textdraw5[playerid], 0.629998, 2.200000);
    TextDrawColor(Textdraw5[playerid], 16777215);
    TextDrawSetOutline(Textdraw5[playerid], 1);
    TextDrawSetProportional(Textdraw5[playerid], 1);
    Textdraw6[playerid] = TextDrawCreate(472.000000, 197.000000, "Deaths:");
    TextDrawBackgroundColor(Textdraw6[playerid], 65535);
    TextDrawFont(Textdraw6[playerid], 1);
    TextDrawLetterSize(Textdraw6[playerid], 0.479999, 2.299998);
    TextDrawColor(Textdraw6[playerid], 16777215);
    TextDrawSetOutline(Textdraw6[playerid], 1);
    TextDrawSetProportional(Textdraw6[playerid], 1);
    TextDrawShowForPlayer(playerid, Textdraw5[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw6[playerid]);
    return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID) kills[killerid]++;
    deaths[playerid] ++;
    new str[40];
    format(str, sizeof(str), "Kills: %d", kills[killerid]);
    TextDrawSetString(Textdraw5[killerid], str);
    format(str, sizeof(str), "Deaths: %d", deaths[playerid]);
    TextDrawSetString(Textdraw6[playerid], str);
    return 1;
}
EDIT:




There is a few errors in your code there
1. GetPlayerHealth is a float %f not a integer.
2. GetPlayerHealth has mutliple params
pawn Код:
new Float:Health;
GetPlayerHealth(playerid, Health);
3. You need a textdraw for each player.
I get the errors:

pawn Код:
C:\Documents and Settings\Chris\Desktop\Desktop\SAMP Server\gamemodes\WorldWar.pwn(500) : error 028: invalid subscript (not an array or too many subscripts): "Textdraw5"
C:\Documents and Settings\Chris\Desktop\Desktop\SAMP Server\gamemodes\WorldWar.pwn(500) : warning 215: expression has no effect
C:\Documents and Settings\Chris\Desktop\Desktop\SAMP Server\gamemodes\WorldWar.pwn(500) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\Chris\Desktop\Desktop\SAMP Server\gamemodes\WorldWar.pwn(500) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Chris\Desktop\Desktop\SAMP Server\gamemodes\WorldWar.pwn(500) : fatal error 107: too many error messages on one line

pawn Код:
Textdraw5[playerid] = TextDrawCreate(472.000000, 172.000000, "Kills:");//Line 500
    TextDrawBackgroundColor(Textdraw5[playerid], 65535);
    TextDrawFont(Textdraw5[playerid], 1);
    TextDrawLetterSize(Textdraw5[playerid], 0.629998, 2.200000);
    TextDrawColor(Textdraw5[playerid], 16777215);
    TextDrawSetOutline(Textdraw5[playerid], 1);
    TextDrawSetProportional(Textdraw5[playerid], 1);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)