[Scripting Help] Hitman Skills
#10

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.

Код:
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;

}
Reply


Messages In This Thread
[Scripting Help] Hitman Skills - by Toss - 18.07.2017, 17:23
Re: [Scripting Help] Hitman Skills - by Paulice - 18.07.2017, 17:32
Re: [Scripting Help] Hitman Skills - by FailerZ - 18.07.2017, 17:33
Re: [Scripting Help] Hitman Skills - by Toss - 18.07.2017, 17:35
Re: [Scripting Help] Hitman Skills - by IceBilizard - 18.07.2017, 17:54
Re: [Scripting Help] Hitman Skills - by FailerZ - 18.07.2017, 18:02
Re: [Scripting Help] Hitman Skills - by IceBilizard - 18.07.2017, 18:17
Re: [Scripting Help] Hitman Skills - by Toss - 18.07.2017, 19:06
Re: [Scripting Help] Hitman Skills - by IceBilizard - 19.07.2017, 14:22
Re: [Scripting Help] Hitman Skills - by Daymen - 19.07.2017, 21:47

Forum Jump:


Users browsing this thread: 3 Guest(s)