19.07.2017, 21:47
I coded an entirely more efficient command for you. It could be even more efficient as to how it grabs the weapon choice typed and deals with it, but, I figured I'd keep it simple so you can understand it.
This also makes it super simple to add more weapons in the future if need be.
If you have any questions, just let me know. I can explain any part of the command I did.
This also makes it super simple to add more weapons in the future if need be.
If you have any questions, just let me know. I can explain any part of the command I did.
Код:
CMD:sethitman( playerid, params[] ) { new targetID, targetName[MAX_PLAYER_NAME], adminName[MAX_PLAYER_NAME], weaponChoice[16], adminMessage[128], playerMessage[128], weaponSkillsGiven = 0 ; //Checks if ( PlayerInfo[playerid][pAdmin] <= 1339 && PlayerInfo[playerid][pShopTech] == 0 ) return Error( playerid, "You are not authorized to use this command." ); if ( sscanf( params, "is[16]", targetID, weaponChoice ) ) { SendClientMessage( playerid, COLOR_GRAD1, "USAGE: /sethitman [playerid] [weapon]" ); SendClientMessage( playerid, COLOR_GRAD2, "Available Weapons: 9mm, sawnoff, uzi" ); return 1; } //Weapon Choices if ( strcmp( weaponChoice, "9mm", true ) == 0 ) { PlayerInfo[targetID][p9mmSkill] = 0; SetPlayerSkillLevel( targetID, WEAPONSKILL_PISTOL, 400 ); } else { PlayerInfo[playerid][p9mmSkill] = 1; SetPlayerSkillLevel( targetID, WEAPONSKILL_PISTOL, 999 ); weaponSkillsGiven = 1; } if ( strcmp( weaponChoice, "sawnoff", true ) == 0 ) { PlayerInfo[targetID][pSawnoffSkill] = 0; SetPlayerSkillLevel( targetID, WEAPONSKILL_SAWNOFF_SHOTGUN, 400 ); } else { PlayerInfo[playerid][pSawnoffSkill] = 1; SetPlayerSkillLevel( targetID, WEAPONSKILL_SAWNOFF_SHOTGUN, 999 ); weaponSkillsGiven = 1; } if ( strcmp( weaponChoice, "uzi", true ) == 0 ) { PlayerInfo[targetID][pUziSkill] = 0; SetPlayerSkillLevel( targetID, WEAPONSKILL_MICRO_UZI, 400 ); } else { PlayerInfo[playerid][pUziSkill] = 1; SetPlayerSkillLevel( targetID, WEAPONSKILL_MICRO_UZI, 999 ); weaponSkillsGiven = 1; } //Messages if ( weaponSkillsGiven == 0 ) { format( adminMessage, sizeof( adminMessage ), "AdmCmd: %s has taken %s's hitman skill on the %s.", adminName, targetName, weaponChoice ); format( playerMessage, sizeof( playerMessage ), "Admin %s has taken your hitman skill on the %s.", adminName, weaponChoice ); } else { format( adminMessage, sizeof( adminMessage ), "AdmCmd: %s gave %s hitman skill on the %s.", adminName, targetName, weaponChoice ); format( playerMessage, sizeof( playerMessage ), "Admin %s has given you hitman skill on the %s.", adminName, weaponChoice ); } //Messages being Sent & Logged Log( "logs/csr.log", adminMessage ); SendAdminMessage( COLOR_LIGHTRED, adminMessage ); SendClientMessage( targetID, COLOR_WHITE, playerMessage ); OnPlayerStatsUpdate( targetID ); return 1; }