Will this W0rK ?
#1

I created this textdraws, when player kill someone or get killed by someone, if there is some problem please fix it for me! and post it below!

pawn Код:
#include <a_samp>

forward HideKillDraw(playerid);
new Text:KillTextDraw[MAX_PLAYERS];
new KillTextTimer[MAX_PLAYERS];

public OnPlayerDeath(playerid, killerid, reason)
{
    new ptname[256];
    GetPlayerName(killerid,ptname,256);
    new string[256];
    format(string,sizeof(string),"You got killed by %s",ptname);
    KillTextDraw[killerid] = TextDrawCreate(320.0, 360.0,string);
    KillTextDraw[playerid] = CreatePlayerTextDraw(playerid, 253.600006, 106.026641, "You killed %s");
    PlayerTextDrawLetterSize(playerid, KillTextDraw[playerid], 0.449999, 1.600000);
    PlayerTextDrawAlignment(playerid, KillTextDraw[playerid], 1);
    PlayerTextDrawColor(playerid, KillTextDraw[playerid], 16777215);
    PlayerTextDrawSetShadow(playerid, KillTextDraw[playerid], 0);
    PlayerTextDrawSetOutline(playerid, KillTextDraw[playerid], 1);
    PlayerTextDrawBackgroundColor(playerid, KillTextDraw[playerid], 51);
    PlayerTextDrawFont(playerid, KillTextDraw[playerid], 1);
    PlayerTextDrawSetProportional(playerid, KillTextDraw[playerid], 1);
    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;
}
Reply
#2

Have you even tested it?
Reply
#3

Yes i did, but it sometime owrk and sometime dont, i modded script to this

pawn Код:
#include <a_samp>
#include <zcmd>

forward HideKillDraw(playerid);
new Text:KillTextDraw[MAX_PLAYERS];
new KillTextTimer[MAX_PLAYERS];

main()
{
    print("***************************************");
    print("*    Insulin - Kill/Death Textdraw    *");
    print("*         Made by: Insulin            *");
    print("*           Version: 1.1              *");
    print("***************************************");
    return 1;
}

public OnFilterScriptInit()
{
    print("**************Killed*******************");
    print("           Version: 1.1                ");
    return 1;
}

public OnPlayerConnect(playerid)
{
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    new ptname[256];
    GetPlayerName(killerid,ptname,256);
    new string[256];
    GetPlayerName(playerid,string,256);
    format(string,sizeof(string),"You got killed by %s",string);
    KillTextDraw[killerid] = TextDrawCreate(188.0, 89.0,ptname);
    KillTextDraw[playerid] = CreatePlayerTextDraw(playerid, 188.0, 89.0,string);
    PlayerTextDrawLetterSize(playerid, KillTextDraw[playerid], 0.449999, 1.600000);
    PlayerTextDrawAlignment(playerid, KillTextDraw[playerid], 1);
    PlayerTextDrawColor(playerid, KillTextDraw[playerid], 16777215);
    PlayerTextDrawSetShadow(playerid, KillTextDraw[playerid], 0);
    PlayerTextDrawSetOutline(playerid, KillTextDraw[playerid], 1);
    PlayerTextDrawBackgroundColor(playerid, KillTextDraw[playerid], 51);
    PlayerTextDrawFont(playerid, KillTextDraw[playerid], 1);
    PlayerTextDrawSetProportional(playerid, KillTextDraw[playerid], 1);
    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;
}
Reply
#4

I think you don't need main() at your filterscript.
Reply
#5

Replace
pawn Код:
TextDrawShowForPlayer(killerid, KillTextDraw[killerid]);
with

pawn Код:
PlayerTextDrawShow(killerid, KillTextDraw[killerid]);
Reply
#6

Quote:
Originally Posted by RedJohn
Посмотреть сообщение
I think you don't need main() at your filterscript.
No, you don't need it.

You created per-player textdraw but the tag was for glabal TDs. Anyways, I fixed few things, it should work.

pawn Код:
#include <a_samp>

#undef MAX_PLAYERS
#define MAX_PLAYERS 50 // Define it with the slots you want (no need 500.. waste)

new
    PlayerText: KillTextDraw[ MAX_PLAYERS ]
;

public OnPlayerConnect(playerid)
{
    KillTextDraw[playerid] = CreatePlayerTextDraw(playerid, 188.0, 89.0, "You got killed by N/A");
    PlayerTextDrawLetterSize(playerid, KillTextDraw[playerid], 0.449999, 1.600000);
    PlayerTextDrawAlignment(playerid, KillTextDraw[playerid], 1);
    PlayerTextDrawColor(playerid, KillTextDraw[playerid], 16777215);
    PlayerTextDrawSetShadow(playerid, KillTextDraw[playerid], 0);
    PlayerTextDrawSetOutline(playerid, KillTextDraw[playerid], 1);
    PlayerTextDrawBackgroundColor(playerid, KillTextDraw[playerid], 51);
    PlayerTextDrawFont(playerid, KillTextDraw[playerid], 1);
    PlayerTextDrawSetProportional(playerid, KillTextDraw[playerid], 1);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    new
        ptname[ MAX_PLAYER_NAME ],
        string[ 43 ]
    ;
    GetPlayerName(killerid,ptname,MAX_PLAYER_NAME);
    format(string,sizeof(string),"You got killed by %s",ptname);

    PlayerTextDrawSetString(playerid, KillTextDraw[playerid], string);
    PlayerTextDrawShow(playerid, KillTextDraw[playerid]);
    SetTimerEx("HideKillDraw", 3000, false, "d", playerid);
    return 1;
}

forward HideKillDraw(playerid);
public HideKillDraw(playerid)
{
    PlayerTextDrawHide(playerid, KillTextDraw[playerid]);
}
PS: Per-player's textdraws get destroyed automatically when a player disconnects.
Reply
#7

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
No, you don't need it.

You created per-player textdraw but the tag was for glabal TDs. Anyways, I fixed few things, it should work.

pawn Код:
#include <a_samp>

#undef MAX_PLAYERS
#define MAX_PLAYERS 50 // Define it with the slots you want (no need 500.. waste)

new
    PlayerText: KillTextDraw[ MAX_PLAYERS ]
;

public OnPlayerConnect(playerid)
{
    KillTextDraw[playerid] = CreatePlayerTextDraw(playerid, 188.0, 89.0, "You got killed by N/A");
    PlayerTextDrawLetterSize(playerid, KillTextDraw[playerid], 0.449999, 1.600000);
    PlayerTextDrawAlignment(playerid, KillTextDraw[playerid], 1);
    PlayerTextDrawColor(playerid, KillTextDraw[playerid], 16777215);
    PlayerTextDrawSetShadow(playerid, KillTextDraw[playerid], 0);
    PlayerTextDrawSetOutline(playerid, KillTextDraw[playerid], 1);
    PlayerTextDrawBackgroundColor(playerid, KillTextDraw[playerid], 51);
    PlayerTextDrawFont(playerid, KillTextDraw[playerid], 1);
    PlayerTextDrawSetProportional(playerid, KillTextDraw[playerid], 1);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    new
        ptname[ MAX_PLAYER_NAME ],
        string[ 43 ]
    ;
    GetPlayerName(killerid,ptname,MAX_PLAYER_NAME);
    format(string,sizeof(string),"You got killed by %s",ptname);

    PlayerTextDrawSetString(playerid, KillTextDraw[playerid], string);
    PlayerTextDrawShow(playerid, KillTextDraw[playerid]);
    SetTimerEx("HideKillDraw", 3000, false, "d", playerid);
    return 1;
}

forward HideKillDraw(playerid);
public HideKillDraw(playerid)
{
    PlayerTextDrawHide(playerid, KillTextDraw[playerid]);
}
PS: Per-player's textdraws get destroyed automatically when a player disconnects.
ok thanks, so the TD will show up on both killer and killed players, and will be destroyed after 3 seconds right ?
Reply
#8

No, you had only one message and I made it to show the message to the killed player "You got killed by name" for 3 seconds.

That should show the message to the killer and hide it after 3 seconds.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new
        ptname[ MAX_PLAYER_NAME ],
        string[ 43 ]
    ;
    GetPlayerName(killerid,ptname,MAX_PLAYER_NAME);
    format(string,sizeof(string),"You got killed by %s",ptname);

    PlayerTextDrawSetString(playerid, KillTextDraw[playerid], string);
    PlayerTextDrawShow(playerid, KillTextDraw[playerid]);
   
    GetPlayerName(playerid,ptname,MAX_PLAYER_NAME);
    format(string,sizeof(string),"You killed %s",ptname);

    PlayerTextDrawSetString(killerid, KillTextDraw[killerid], string);
    PlayerTextDrawShow(killerid, KillTextDraw[killerid]);
   
    SetTimerEx("HideKillDraw", 3000, false, "dd", playerid, killerid);
    return 1;
}

forward HideKillDraw(playerid, killerid);
public HideKillDraw(playerid, killerid)
{
    PlayerTextDrawHide(playerid, KillTextDraw[playerid]);
    PlayerTextDrawHide(killerid, KillTextDraw[killerid]);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)