Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Seregamil
Created June 2, 2014 06:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Seregamil/3535dbe34f96eb5b84ae to your computer and use it in GitHub Desktop.
Save Seregamil/3535dbe34f96eb5b84ae to your computer and use it in GitHub Desktop.
Skill system
//by Seregamil
#include a_samp
main(){
}
#define SKILL_WEAPONS 10
new Float: weapon_shots[ MAX_PLAYERS ][ SKILL_WEAPONS ];
new Float: weapon_damaged[ MAX_PLAYERS ][ SKILL_WEAPONS ];
/*
22 - WEAPON_COLT45
23 - WEAPON_SILENCED
24 - WEAPON_DEAGLE
25 - WEAPON_SHOTGUN
26 - WEAPON_SAWEDOFF
27 - WEAPON_SHOTGSPA
28 - WEAPON_UZI
29 - WEAPON_MP5
30 - WEAPON_AK47
31 - WEAPON_M4
*/
public OnGameModeInit(){
return true;
}
public OnPlayerConnect(playerid){
for( new j = 0; j != SKILL_WEAPONS; j++ ){
weapon_shots[ playerid ][ j ] = 0.0;
weapon_damaged[ playerid ][ j ] = 0.0;
}
return true;
}
public OnPlayerCommandText(playerid, cmdtext[]){
if(!strcmp(cmdtext, "/skill", true)){
new j = -1, str[ 256 ], weapon_name[ 32 ];
format( str, 256, "{ffffff}Навыки владения оружиями:\n" );
while( ++j != SKILL_WEAPONS ){
GetWeaponName( ( j + 22 ), weapon_name, sizeof weapon_name );
if( weapon_shots[ playerid ][ j ] == 0.0 || weapon_damaged[ playerid ][ j ] == 0.0 )
format( str, 256, "%s%s: 0.0%s\n", str, weapon_name, "%" );
else
format( str, 256, "%s%s: %.2f%s\n", str, weapon_name, ( weapon_damaged[ playerid ][ j ] / weapon_shots[ playerid ][ j ] ) * 100.0, "%" );
}
return ShowPlayerDialog( playerid, 0, DIALOG_STYLE_MSGBOX, " ", str, "Ok", "" );
}
return SendClientMessage(playerid, -1, "Command is not exist");
}
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart){
if( 22 <= weaponid <= 31 )
weapon_damaged[ playerid ][ weaponid - 22 ] += 1.0;
return true;
}
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ){
if( 22 <= weaponid <= 31 ){
weapon_shots[ playerid ][ weaponid - 22 ] += 1.0;
SetPlayerSkillLevel( playerid, weaponid - 22, floatround( ( ( weapon_damaged[ playerid ][ weaponid - 22 ] / weapon_shots[ playerid ][ weaponid - 22 ] ) * 100.0 ) * 9.99 ) );
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment