Display Kills
#1

hi,
can someone help me pls?

pawn Код:
new Text:killtext;

//OnGameModeInit
killtext = TextDrawCreate(518.000000, 134.000000, "Kills: 0");
TextDrawBackgroundColor(killtext, 255);
TextDrawFont(killtext, 1);
TextDrawLetterSize(killtext, 0.500000, 1.000000);
TextDrawColor(killtext, -65281);
TextDrawSetOutline(killtext, 1);
TextDrawSetProportional(killtext, 1);

//dont know where to set it
     new newtext[41];
     format(newtext, sizeof(newtext), "Kills: %s", kills[killerid]);
     TextDrawSetString(killtext, newtext);

//OnPlayerDeath
     deaths[playerid]++;
     if(killerid!=INVALID_PLAYER_ID) {
     kills[killerid]++; }
i want that the kills a player has are displayed with this textdraw.
But the number doesnt change.
Reply
#2

pls someone
Reply
#3

forward update(); // TOP
// end
pawn Код:
public update()
{
   new newtext[41];
   format(newtext, sizeof(newtext), "Kills: %s", kills[killerid]);
   SetTextDrawString(killtext, string);
   SetTimerEx("update", 5000, true, "i");
   return 1;
}

Also, add on OnGameModeInit: SetTimerEx("update", 5000, true, "i");
Reply
#4

kills[MAX_PLAYERS]; // at top of your code

if(killerid!=INVALID_PLAYER_ID) kills[killerid]++; // OnPlayerDeath
new newtext[41]; // OnPlayerDeath
format(newtext, sizeof(newtext), "Kills: %d", kills[killerid]); // OnPlayerDeath
TextDrawSetString(killtext, newtext); // OnPlayerDeath

kills[playerid]=0; // on player disconnect, if player disconnects set kills to 0

timer isnt necessary, simply put everything under onplayerdeath
Reply
#5

Edited...


Whats wrong with the code?
nothing appears behind Kills:
This is all ive got (all that has sth in common with this textdraw)

pawn Код:
new Text:killtext;

//OnGameModeInit:

killtext = TextDrawCreate(518.000000, 134.000000, "Kills:");
TextDrawBackgroundColor(killtext, 255);
TextDrawFont(killtext, 1);
TextDrawLetterSize(killtext, 0.500000, 1.000000);
TextDrawColor(killtext, -65281);
TextDrawSetOutline(killtext, 1);
TextDrawSetProportional(killtext, 1);

//OnPlayerSpawn
TextDrawShowForPlayer(playerid, killtext);

//OnPlayerDeath:
     tode[playerid]++;
     if(killerid!=INVALID_PLAYER_ID) {
     kills[killerid]++; }

//the kills of the players shall not be resetet theyre saved and loaded from a file:
   
//load 
kills[playerid]=(playerid,dini_Int(accFormat,"Kills"));
deaths[playerid]=(playerid,dini_Int(accFormat,"Deaths"));
//save under OnPlayerDisconnect:
 
dini_IntSet(accFormat,"Kills",kills[playerid]);
dini_IntSet(accFormat,"Deaths",deaths[playerid]);
thx for ur help!!
Reply
#6

Quote:
Originally Posted by BlackWolf120
Посмотреть сообщение
pls guys, someone, take a qick look at my texdraw codes please.
I need this to understand also for my scoreboard i want to create.
What's wrong with the code..?

EDIT: Wait, I see the problem.

2 mins.
Reply
#7

pawn Код:
#include <a_samp>
new Text:killtext;


public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer(playerid, killtext);
    return 1;
}

public OnGameModeInit()
{
    killtext = TextDrawCreate(518.000000, 134.000000, "Kills: 0");
    TextDrawBackgroundColor(killtext, 255);
    TextDrawFont(killtext, 1);
    TextDrawLetterSize(killtext, 0.500000, 1.000000);
    TextDrawColor(killtext, -65281);
    TextDrawSetOutline(killtext, 1);
    TextDrawSetProportional(killtext, 1);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    new string[40];
    format(string,sizeof(string),"Kills: %i",kills[killerid]);
    tode[playerid]++;
    if(killerid!=INVALID_PLAYER_ID) {
    kills[killerid]++; }
    TextDrawShowForPlayer(playerid,killtext);
    TextDrawSetString(killtext,string);
    TextDrawShowForPlayer(killerid,killtext);
    return 1;
}
Reply
#8

thx , im gonna test it at once
Reply
#9

Quote:
Originally Posted by blackwave
Посмотреть сообщение
forward update(); // TOP
// end
pawn Код:
public update()
{
   new newtext[41];
   format(newtext, sizeof(newtext), "Kills: %s", kills[killerid]);
   SetTextDrawString(killtext, string);
   SetTimerEx("update", 5000, true, "i");
   return 1;
}

Also, add on OnGameModeInit: SetTimerEx("update", 5000, true, "i");
You don't need a timer you can just add in on OnPlayerDeath.
It it faster and uses less CPU.
Reply
#10

mhh,
i did it exactly like u said and it still doesnt work.
The number zero (0) stays 0 all the time. Kills: 0

whats the problem with this textdraw??
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)