SA-MP Forums Archive
[HELP] OnPlayerDeath - PlayerName|PlayerID|KilledBy? - 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] OnPlayerDeath - PlayerName|PlayerID|KilledBy? (/showthread.php?tid=192001)



[HELP] OnPlayerDeath - PlayerName|PlayerID|KilledBy? - Larsey123IsMe - 21.11.2010

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;
}



Re: [HELP] OnPlayerDeath - PlayerName|PlayerID|KilledBy? - randomkid88 - 21.11.2010

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);
}



Re: [HELP] OnPlayerDeath - PlayerName|PlayerID|KilledBy? - Grim_ - 21.11.2010

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.


Re: [HELP] OnPlayerDeath - PlayerName|PlayerID|KilledBy? - Larsey123IsMe - 21.11.2010

Thanks


Re: [HELP] OnPlayerDeath - PlayerName|PlayerID|KilledBy? - XVK - 22.12.2010

For the distance, will that be easy to make?


Re: [HELP] OnPlayerDeath - PlayerName|PlayerID|KilledBy? - Nero_3D - 22.12.2010

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


Re: [HELP] OnPlayerDeath - PlayerName|PlayerID|KilledBy? - Zimon95 - 22.12.2010

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.


Re : [HELP] OnPlayerDeath - PlayerName|PlayerID|KilledBy? - XVK - 22.12.2010

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;
}



Re: [HELP] OnPlayerDeath - PlayerName|PlayerID|KilledBy? - Retardedwolf - 22.12.2010

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


Re : [HELP] OnPlayerDeath - PlayerName|PlayerID|KilledBy? - XVK - 22.12.2010

It works!!!!