enum E_accVars {
Passcode, Cash, RegisteredIP[ 16 ],
Kills, Deaths, Status,
Model, KillsWithWeapon [ 42 ], DeathsByWeapon [ 42 ] //KillsWithWeapon & DeathsByWeapon are the variables used in this.
}
public OnPlayerDeath(playerid, killerid, reason)
{
GivePlayerMoney( playerid, 10 ), GivePlayerMoney( killerid, -100 );
//Give them $100 if they succeed in killing someone, and take $10 if they die. This should help create an economy.
if( reason >= 0 && reason < 43 ) {
accInfo [ killerid ] [ KillsWithWeapon ] [ reason ] += 1;
accInfo [ playerid ] [ DeathsByWeapon ] [ reason ] += 1;
}
player_Spawned [ playerid ] = false;
return 1;
}
stock GetFavoriteWeapon( playerid )
{
new
favWepID = 0;
for( new w; w < 42; w ++ )
{
if( accInfo [ playerid ] [ KillsWithWeapon ] [ w ] != 0 )
{
//This is a viable candidate for their favorite weapon - they've used it before.
if( accInfo [ playerid ] [ KillsWithWeapon ] [ w ] > favWepID )
{
favWepID = w;
}
}
}
return favWepID;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if( killerid != INVALID_PLAYER_ID )
{
if( reason < 43 )
{
accInfo [ killerid ] [ KillsWithWeapon ] [ reason ] += 1;
}
GivePlayerMoney( killerid, 100 );
}
player_Spawned [ playerid ] = false;
if( reason < 43 )
{
accInfo [ playerid ] [ DeathsByWeapon ] [ reason ] += 1;
}
GivePlayerMoney( playerid, -10 );
return 1;
}
stock GetFavoriteWeapon( playerid )
{
new
weapon,
favWeapon,
kills = accInfo [ playerid ] [ KillsWithWeapon ] [ 0 ]
;
while( ++weapon < 43 )
{
if( kills < accInfo [ playerid ] [ KillsWithWeapon ] [ weapon ] )
{
kills = accInfo [ playerid ] [ KillsWithWeapon ] [ ( favWeapon = weapon ) ];
}
}
return favWeapon;
}
In OnPlayerDeath you should check if the killerid is valid
pawn Code:
pawn Code:
|