SA-MP Forums Archive
help with this textdraw - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: help with this textdraw (/showthread.php?tid=88040)



help with this textdraw - Mishima - 23.07.2009

Код:
//top of the script
forward HideKillDraw(playerid);
new Text:KillTextDraw[MAX_PLAYERS];
new KillTextTimer[MAX_PLAYERS];

public OnPlayerDeath(playerid, killerid, reason)
{
	new ptname[256];
	GetPlayerName(killerid,ptname,256);
    format(string,sizeof(string),"%s Owned",ptname);
	KillTextDraw[killerid] = TextDrawCreate(320.0, 360.0,string);
	TextDrawFont(KillTextDraw[killerid], 2);
	TextDrawSetShadow(KillTextDraw[killerid], 0);
	TextDrawSetOutline(KillTextDraw[killerid], 1);
	TextDrawAlignment(KillTextDraw[killerid], 2);
	TextDrawColor(KillTextDraw[killerid], COLOR_SRED);
	TextDrawShowForPlayer(killerid, KillTextDraw[killerid]);
	KillTextTimer[killerid] = SetTimerEx("HideKillDraw", 3000, false, "d", killerid);
    return 1;
}

public HideKillDraw(playerid)
{
    TextDrawHideForPlayer(playerid, KillTextDraw[playerid]);
	return 1;
}

public OnPlayerDisconnect(playerid,reason)
{
	TextDrawDestroy(KillTextDraw[playerid]);
    return 1;
}
well the i don't know what's wrong with the code, but when i enter the server and i kill someone it says that i got owned, and it's supposed to say that the other player got owned...
any help here please?


Re: help with this textdraw - MadeMan - 23.07.2009

Change

pawn Код:
new ptname[256];
GetPlayerName(killerid,ptname,256);
to

pawn Код:
new ptname[MAX_PLAYER_NAME];
GetPlayerName(playerid,ptname,MAX_PLAYER_NAME);
And you also create another textdraw every time player kills someone. You should do TextDrawCreate OnPlayerConnect and when player kills someone then use TextDrawSetString and TextDrawShowForPlayer.


Re: help with this textdraw - Mishima - 23.07.2009

Quote:
Originally Posted by MadeMan
Change

pawn Код:
new ptname[256];
GetPlayerName(killerid,ptname,256);
to

pawn Код:
new ptname[MAX_PLAYER_NAME];
GetPlayerName(playerid,ptname,MAX_PLAYER_NAME);
And you also create another textdraw every time player kills someone. You should do TextDrawCreate OnPlayerConnect and when player kills someone then use TextDrawSetString and TextDrawShowForPlayer.
i don't understand well about TextDrawSetString even by reading the wiki... can u help?


Re: help with this textdraw - Joe Staff - 23.07.2009

It's just like TextDrawCreate but instead of putting in text for a new textdraw, you're just changing a pre-made one.

TextDrawSetString(YourTextDraw,"WordZ");


Re: help with this textdraw - Mishima - 23.07.2009

well now i have
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	new ptname[MAX_PLAYER_NAME];
	GetPlayerName(killerid,ptname,MAX_PLAYER_NAME);
    format(string,sizeof(string),"%s Owned",ptname);
    TextDrawSetString(KillTextDraw[killerid],string);
  	TextDrawShowForPlayer(killerid, KillTextDraw[killerid]);
	KillTextTimer[killerid] = SetTimerEx("HideKillDraw", 3000, false, "d", killerid);
    return 1;
}

public OnPlayerConnect()
{
	KillTextDraw[playerid] = TextDrawCreate(320.0, 360.0," ");
	TextDrawFont(KillTextDraw[playerid], 2);
	TextDrawSetShadow(KillTextDraw[playerid], 0);
	TextDrawSetOutline(KillTextDraw[playerid], 1);
	TextDrawAlignment(KillTextDraw[playerid], 2);
	TextDrawColor(KillTextDraw[playerid], COLOR_SRED);
    return 1;
}
and this is still not working...


Re: help with this textdraw - MadeMan - 23.07.2009

pawn Код:
GetPlayerName(playerid,ptname,MAX_PLAYER_NAME);
Do you have it like this?


Re: help with this textdraw - Mishima - 23.07.2009

well i think problem is solved for now, but i wonder if 2 players die at the same time the textdraw stays on the screen and don't disappears, i'll test it, if the problem happens i'll post it here, thanks for the help guys