TextDrawHideForPlayer after 2 seconds -
Captain_Mani - 14.12.2012
So I am making a TDM script. In it when we shoot someone, the damaged amount is listed below the screen as a textdraw. After I shoot someone, the textdraw comes, but it won't go back again. So I want to hide the textdraw back after two or three seconds after I shoot someone and the damaged textdraw appears. Please tell me how to do it. How do I set the timer for it? And my code is under OnPlayerGiveDamage.
Help me please!
Re: TextDrawHideForPlayer after 2 seconds -
Captain_Mani - 14.12.2012
Quote:
Originally Posted by ******
Timers.
|
I know that. But I want to know how to set it according to this.
Re: TextDrawHideForPlayer after 2 seconds -
Threshold - 14.12.2012
Try something along these lines:
pawn Код:
//At the top of your script
new TextDrawShowing[MAX_PLAYERS]; //You can make this a bool if you want, to make it easier to understand.
public OnPlayerConnect(playerid)
{
TextDrawShowing[playerid] = 0; //Or 'False' if you're using a boolean value.
return 1;
}
public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid)
{
//ShowTextDraw to player etc.
if(TextDrawShowing[damagedid] == 1) //if the textdraw is already showing
{
KillTimer(TextTimer[damagedid]); //Kill timer so the textdraw still displays 2 seconds after being hit
}
TextDrawShowing[damagedid] = 1;
SetTimerEx("RemoveTDBar", 2000, false,"i",damagedid);
return 1;
}
forward RemoveTDBar(playerid);
public RemoveTDBar(playerid)
{
//Hide textdraw from player
TextDrawShowing[playerid] = 0; //The textdraw is no longer showing
return 1;
}
Re: TextDrawHideForPlayer after 2 seconds -
Threshold - 14.12.2012
Quote:
Originally Posted by ******
I would use a more generic function of "forward HideTD(playerid, Text:td);" so that you can use the same one for every TD you have.
|
Good point. :S
Re: TextDrawHideForPlayer after 2 seconds -
maramizo - 14.12.2012
Give us the code of your textdraw, and I can give you an accurate code.
Re: TextDrawHideForPlayer after 2 seconds -
Captain_Mani - 14.12.2012
Quote:
Originally Posted by maramizo
Give us the code of your textdraw, and I can give you an accurate code.
|
Код:
Textdraw0 = TextDrawCreate(329.000000,408.000000,"Damage: %.Of");
TextDrawUseBox(Textdraw0,1);
TextDrawBoxColor(Textdraw0,0x00000066);
TextDrawTextSize(Textdraw0,-60.000000,94.000000);
TextDrawAlignment(Textdraw0,2);
TextDrawBackgroundColor(Textdraw0,0x000000ff);
TextDrawFont(Textdraw0,3);
TextDrawLetterSize(Textdraw0,0.399999,1.200000);
TextDrawColor(Textdraw0,0xffffffff);
TextDrawSetOutline(Textdraw0,1);
TextDrawSetProportional(Textdraw0,1);
@Benzo, didn't work for me. :\ Or I didn't get how to do it.
Please help me someone! Would be appreciated!
Re: TextDrawHideForPlayer after 2 seconds -
maramizo - 14.12.2012
Where do you create your textdraw?
edit:
Here's how the code should be:
pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid)
{
new str[40];
format(str, 40, "%.0f", amount);
TextDrawSetString(Textdraw0, str);
TextDrawShowForPlayer(playerid, Textdraw0);
SetTimerEx("hideplayertd", 2000, 0, "i", playerid)
return 1;
}
forward hideplayertd(p);
public hideplayertd(p)
{
TextDrawHideForPlayer(p, Textdraw0);
return 1;
}
Re: TextDrawHideForPlayer after 2 seconds -
Captain_Mani - 15.12.2012
Quote:
Originally Posted by maramizo
Where do you create your textdraw?
edit:
Here's how the code should be:
pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid) { new str[40]; format(str, 40, "%.0f", amount); TextDrawSetString(Textdraw0, str); TextDrawShowForPlayer(playerid, Textdraw0); SetTimerEx("hideplayertd", 2000, 0, "i", playerid) return 1; }
forward hideplayertd(p); public hideplayertd(p) { TextDrawHideForPlayer(p, Textdraw0); return 1; }
|
Thanks bro. It worked. Now can you tell me that, when I give damage, the damaged number is shown below, but when I hit again, it shows the damaged number again. Instead I want all that damaged number to be added and inserted that had been hit within 2 seconds. How to do that?
Re: TextDrawHideForPlayer after 2 seconds -
maramizo - 15.12.2012
No problemo!
pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid)
{
new str[40];
format(str, 40, "%i", strval(GetPVarString(playerid, "dmg")) + damagedid);
SetPVarString(playerid, "dmg", str);
TextDrawSetString(Textdraw0, str);
TextDrawShowForPlayer(playerid, Textdraw0);
SetTimerEx("hideplayertd", 2000, 0, "i", playerid)
return 1;
}
forward hideplayertd(p);
public hideplayertd(p)
{
TextDrawHideForPlayer(p, Textdraw0);
return 1;
}
Re: TextDrawHideForPlayer after 2 seconds -
Captain_Mani - 16.12.2012
Quote:
Originally Posted by maramizo
No problemo!
pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid) { new str[40]; format(str, 40, "%i", strval(GetPVarString(playerid, "dmg")) + damagedid); SetPVarString(playerid, "dmg", str); TextDrawSetString(Textdraw0, str); TextDrawShowForPlayer(playerid, Textdraw0); SetTimerEx("hideplayertd", 2000, 0, "i", playerid) return 1; }
forward hideplayertd(p); public hideplayertd(p) { TextDrawHideForPlayer(p, Textdraw0); return 1; }
|
I get two warnings and a error.
Код:
warning 202: number of arguments does not match definition
warning 202: number of arguments does not match definition
error 035: argument type mismatch (argument 1)
Why is it? :\