[HELP] OnPlayerDeath - PlayerName|PlayerID|KilledBy?
#1

I need help =/ (I have searched at forum and wiki) How to make an script who finds the Player name and Player ID and Death reason.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SendDeathMessage(killerid, playerid, reason);
    SendClientMessage(playerid,0x00FF00FF,"%d has been killed by (Person who killed him), (Weapon he used to kill him with)");
    return 1;
}
Reply
#2

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
     new pName[24], KillerName[24], string[60];
     GetPlayerName(playerid, pName, sizeof(pName);
     GetPlayerName(killerid, KillerName, sizeof(KillerName);
     SendDeathMessage(killerid, playerid, reason);
     format(string, sizeof(string), "%s has been killed by %s, %d", pName, KillerName, reason);
     SendClientMessageToAll(playerid, 0x00FF00FF, string);
}
Reply
#3

pawn Код:
public OnPlayerDeath( playerid, killerid, reason )
{
   new gun[ 32 ], name[ MAX_PLAYER_NAME ], killer[ MAX_PLAYER_NAME ], string[ 80 ];
   GetPlayerName( playerid, name, MAX_PLAYER_NAME );
   GetPlayerName( killerid, killer, MAX_PLAYER_NAME );
   GetWeaponName( reason, gun, 32 );
   format( string, 80, "%s killed %s with a %s", killer, name, gun );
   SendClientMessageToAll( 0x00FF00FF, string );
   return 1;
}
The only bad thing with this, is that it will return NULL for weapon IDs 18, 44 and 45. You can alternatively use the aWeaponNames array found in fsdebug.pwn in the filterscripts folder, and use that to check the weapon names.
Reply
#4

Thanks
Reply
#5

For the distance, will that be easy to make?
Reply
#6

Quote:
Originally Posted by XVK
Посмотреть сообщение
For the distance, will that be easy to make?
Yes if you know whats the Pythagorean theorem is
Reply
#7

For the distance you can use this function (I took it from LA:RP script)
pawn Код:
public Float:GetDistanceBetweenPlayers(playerid1,playerid2)
{
    new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    if(!IsPlayerConnected(playerid1) || !IsPlayerConnected(playerid2))
    {
        return -1.00;
    }
    GetPlayerPos(playerid1,x1,y1,z1);
    GetPlayerPos(playerid2,x2,y2,z2);
    return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
That is, as Nero_3D said, the Pythagorean theorem.
Reply
#8

How could you make this all together?

pawn Код:
public Float:GetDistanceBetweenPlayers(playerid1,playerid2)
{
    new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    if(!IsPlayerConnected(playerid1) || !IsPlayerConnected(playerid2))
    {
        return -1.00;
    }
    GetPlayerPos(playerid1,x1,y1,z1);
    GetPlayerPos(playerid2,x2,y2,z2);
    return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
pawn Код:
public OnPlayerDeath( playerid, killerid, reason )
{
   new gun[ 32 ], name[ MAX_PLAYER_NAME ], killer[ MAX_PLAYER_NAME ], string[ 80 ];
   GetPlayerName( playerid, name, MAX_PLAYER_NAME );
   GetPlayerName( killerid, killer, MAX_PLAYER_NAME );
   GetWeaponName( reason, gun, 32 );
   format( string, 80, "%s killed %s with a %s", killer, name, gun );
   SendClientMessageToAll( 0x00FF00FF, string );
   return 1;
}
Reply
#9

pawn Код:
public OnPlayerDeath( playerid, killerid, reason )
{
   new
       gun    [ 32 ],
       name   [ MAX_PLAYER_NAME ],
       killer [ MAX_PLAYER_NAME ],
       string [ 65 + ( MAX_PLAYER_NAME * 2 ) ]
   ;

   GetPlayerName            ( playerid, name, MAX_PLAYER_NAME );
   GetPlayerName            ( killerid, killer, MAX_PLAYER_NAME );
   GetWeaponName            ( reason, gun, 32 );
   format                   ( string, sizeof ( string ), "%s ( %d ) has killed %s ( %d ) with a %s ( %d ) Distance : ( %f )", killer, killerid, name, playerid, gun, reason, GetDistanceBetweenPlayers ( playerid, killerid ) );
   SendClientMessageToAll   ( 0x00FF00FF, string );
   return 1;
}

forward Float:GetDistanceBetweenPlayers(p1,p2);
public Float:GetDistanceBetweenPlayers(p1,p2)
{
    new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
    {
        return -1.00;
    }
    GetPlayerPos(p1,x1,y1,z1);
    GetPlayerPos(p2,x2,y2,z2);
    return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
NOT TESTED
Reply
#10

It works!!!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)