06.04.2012, 15:43
Well, I'm trying to create a function that gets their favorite weapon and tbh, i'm stuck;
My player variables are like so:
How said variables are set:
What I've got so far is:
Could someone assist me further?
My player variables are like so:
pawn Code:
enum E_accVars {
Passcode, Cash, RegisteredIP[ 16 ],
Kills, Deaths, Status,
Model, KillsWithWeapon [ 42 ], DeathsByWeapon [ 42 ] //KillsWithWeapon & DeathsByWeapon are the variables used in this.
}
pawn Code:
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;
}
pawn Code:
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;
}