you killed textdraw
#1

I'm pretty new to textdraws,

Could anyone tell me with proper explanations how I set this textdraw to killerid, and playerid (you killed %s, killed by %s)

I tried to surf around maybe see some tutorials but I couldn't find any

Код:
	killed = TextDrawCreate(247.000000, 351.000000, "killed by");
	TextDrawBackgroundColor(killed, 255);
	TextDrawFont(killed, 3);
	TextDrawLetterSize(killed, 0.459998, 2.000000);
	TextDrawColor(killed, 227526655);
	TextDrawSetOutline(killed, 0);
	TextDrawSetProportional(killed, 1);
	TextDrawSetShadow(killed, 1);
	
	killedby = TextDrawCreate(247.000000, 351.000000, "you killed");
	TextDrawBackgroundColor(killedby, 255);
	TextDrawFont(killedby, 3);
	TextDrawLetterSize(killedby, 0.459998, 2.000000);
	TextDrawColor(killedby, 227526655);
	TextDrawSetOutline(killedby, 0);
	TextDrawSetProportional(killedby, 1);
	TextDrawSetShadow(killedby, 1);
Reply
#2

Use this PlayerTextDrawSetString and not TextDrawSetString
Reply
#3

PHP код:

new Text:killed;
new 
Text:killedby;
public 
OnGameModeInit()
{
//All things above this.
    
killed TextDrawCreate(247.000000351.000000"_____");
    
TextDrawBackgroundColor(killed255);
    
TextDrawFont(killed3);
    
TextDrawLetterSize(killed0.4599982.000000);
    
TextDrawColor(killed227526655);
    
TextDrawSetOutline(killed0);
    
TextDrawSetProportional(killed1);
    
TextDrawSetShadow(killed1);
    
killedby TextDrawCreate(247.000000351.000000"_____");
    
TextDrawBackgroundColor(killedby255);
    
TextDrawFont(killedby3);
    
TextDrawLetterSize(killedby0.4599982.000000);
    
TextDrawColor(killedby227526655);
    
TextDrawSetOutline(killedby0);
    
TextDrawSetProportional(killedby1);
    
TextDrawSetShadow(killedby1);
    return 
1;
}
public 
OnGameModeExit()
{
    
TextDrawHideForPlayer(playeridkilled);
    
TextDrawDestroy(killed);
    
TextDrawHideForPlayer(playeridkilledby);
    
TextDrawDestroy(killedby);
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    
TextDrawHideForPlayer(playeridkilled);
    
TextDrawDestroy(killed);
    
TextDrawHideForPlayer(playeridkilledby);
    
TextDrawDestroy(killedby);
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
    
TextDrawHideForPlayer(playeridkilled);
    
TextDrawHideForPlayer(playeridkilledby);
    return 
1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    new 
killinfo[210];
    new 
playername[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,playername,sizeof(playername));
    
format(killinfosizeof(killinfo), "You killed %s(%d)."playernameplayerid);
    
TextDrawSetString(killedkillinfo);
    
TextDrawShowForPlayer(playeridkilled);
    
SetTimerEx("HideTextdraw"5000false"i"killerid); // 1000 = 1 Second, therefore 5000 = 5 Second
    
    
new deathinfo[210];
    new 
killername[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,killername,sizeof(killername));
    
format(deathinfosizeof(deathinfo), "%s(%d) has killed you."killernamekillerid);
    
TextDrawSetString(killedbydeathinfo);
    
TextDrawShowForPlayer(playeridkilledby); // No need of timers here as I've hidden the textdraw for player when he spawn.
    
return 1;
}
forward HideTextdraw(playerid);
public 
HideTextdraw(playerid)
{
    
TextDrawHideForPlayer(playeridkilled);

Reply
#4

example:
Код:
new timer_death[MAX_PLAYERS],
       timer_death2[MAX_PLAYERS];
PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
 new 
str[60], str2[60], pName1[MAX_PLAYER_NAME], pName2[MAX_PLAYER_NAME];
 
GetPlayerName(playeridpName1MAX_PLAYER_NAME);
 
GetPlayerName(killeridpName2MAX_PLAYER_NAME);
 
TextDrawShowForPlayer(playeridkilled);
 
format(strsizeof(str), "You death by: %s"pName2(killerid));
 
TextDrawSetString(killedstr);
 
timer_death[playerid] = SetTimerEx("hidetd_player"4000false"d"playerid);

 
TextDrawShowForPlayer(killeridkilledby);
 
format(str2sizeof(str2), "You killed by: %s"pName(playerid);
 
TextDrawSetString(killedbystr);
 
timer_death2[killerid] = SetTimerEx("hidetd_killer"4000false"d"killerid);
 return 
1;
}

forward hidetd_player(playerid);
public 
hidetd_player(playerid){
TextDrawHideForPlayer(playeridkilled);
KillTimer(timer_death[playerid]);
return 
1;
}

forward hidetd_killer(killerid);
public 
hidetd_killer(killerid){
TextDrawHideForPlayer(killeridkilledby);
KillTimer(timer_death2[killerid]);
return 
1;

Reply
#5

Quote:
Originally Posted by dani18
Посмотреть сообщение
example:
Код:
new timer_death[MAX_PLAYERS],
       timer_death2[MAX_PLAYERS];
PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
 new 
str[60], str2[60], pName1[MAX_PLAYER_NAME], pName2[MAX_PLAYER_NAME];
 
GetPlayerName(playeridpName1MAX_PLAYER_NAME);
 
GetPlayerName(killeridpName2MAX_PLAYER_NAME);
 
TextDrawShowForPlayer(playeridkilled);
 
format(strsizeof(str), "You death by: %s"pName2(killerid));
 
TextDrawSetString(killedstr);
 
timer_death[playerid] = SetTimerEx("hidetd_player"4000false"d"playerid);
 
TextDrawShowForPlayer(killeridkilledby);
 
format(str2sizeof(str2), "You killed by: %s"pName(playerid);
 
TextDrawSetString(killedbystr);
 
timer_death2[killerid] = SetTimerEx("hidetd_killer"4000false"d"killerid);
 return 
1;
}
forward hidetd_player(playerid);
public 
hidetd_player(playerid){
TextDrawHideForPlayer(playeridkilled);
KillTimer(timer_death[playerid]);
return 
1;
}
forward hidetd_killer(killerid);
public 
hidetd_killer(killerid){
TextDrawHideForPlayer(killeridkilledby);
KillTimer(timer_death2[killerid]);
return 
1;

You're using 2 timers for same reason. Why don't you combine those in one? Or you can have a look at my code(above) and see how I've made it
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)