SWAT and FBI Commands
#1

Hello all people in this community!

I am pretty new scripter, so I do not know much. I hope you won't disrespect me because of it. I am scripting 3rd day right now.

Anyway, I have made this script section:
Код:
  if(strcmp(cmdtext, "/swat", true) == 0)
  {
  		if(GetPlayerSkin(playerid) == 285)
			SendClientMessage(playerid, COLOR_RED, "You are SWAT already!");
		else
			SetPlayerArmour(playerid, 100);
			SetPlayerHealth(playerid, 100);
			SetPlayerSkin(playerid, 285);
			SetPlayerColor(playerid, COLOR_GREEN);
			GivePlayerWeapon(playerid, 8, 100);
			GivePlayerWeapon(playerid, 31, 500);
			GivePlayerWeapon(playerid, 29, 300);
			GivePlayerWeapon(playerid, 34, 50);
			GivePlayerWeapon(playerid, 24, 100);
			return 1;
	}
	if(strcmp(cmdtext, "/fbi", true) == 0)
	{
  	if(GetPlayerSkin(playerid) == 286)
	  	SendClientMessage(playerid, COLOR_RED, "You are FBI already!");
		else
			SetPlayerArmour(playerid, 100);
			SetPlayerHealth(playerid, 100);
			SetPlayerSkin(playerid, 286);
			SetPlayerColor(playerid, COLOR_GREEN);
			GivePlayerWeapon(playerid, 8, 300);
			GivePlayerWeapon(playerid, 31, 800);
			GivePlayerWeapon(playerid, 29, 800);
			GivePlayerWeapon(playerid, 34, 100);
			GivePlayerWeapon(playerid, 24, 300);
			return 1;
	}
When I use it first time, it gives all these. When I use it second time, it still does give these and returns the message also.

What have I done wrong?

Also, when I try to compile, it gives 2 errors:
Код:
C:\Documents and Settings\Janar\Desktop\SAMP\gamemodes\minu2.pwn(370) : warning 217: loose indentation
C:\Documents and Settings\Janar\Desktop\SAMP\gamemodes\minu2.pwn(387) : warning 217: loose indentation
Both are the SetPlayerHealth lines in FBI and SWAT.
Reply
#2

Its just saying that your code is loosing intendation
Код:
		if(strcmp(cmdtext, "/swat", true) == 0)
  {
  		if(GetPlayerSkin(playerid) == 285)
			SendClientMessage(playerid, COLOR_RED, "You are SWAT already!");
		else
		SetPlayerArmour(playerid, 100);
		SetPlayerHealth(playerid, 100);
		SetPlayerSkin(playerid, 285);
		SetPlayerColor(playerid, COLOR_GREEN);
		GivePlayerWeapon(playerid, 8, 100);
		GivePlayerWeapon(playerid, 31, 500);
		GivePlayerWeapon(playerid, 29, 300);
		GivePlayerWeapon(playerid, 34, 50);
		GivePlayerWeapon(playerid, 24, 100);
		return 1;
	}
	}
Reply
#3

loose indentation is this.
pawn Код:
if(something)
{
    something else
}
    else
{
    something else
}
to fix it, you need to fix your lines
pawn Код:
if(something)
{
    something else
}
else
{
    something else
}
Also use [ pawn] [/ pawn] tags for pawn code.
Lastly its better to use { } to your scripts. Try this.
pawn Код:
if(strcmp(cmdtext, "/swat", true) == 0)
{
    if(GetPlayerSkin(playerid) == 285) return SendClientMessage(playerid, COLOR_RED, "You are SWAT already!");
    SetPlayerArmour(playerid, 100);
    SetPlayerHealth(playerid, 100);
    SetPlayerSkin(playerid, 285);
    SetPlayerColor(playerid, COLOR_GREEN);
    GivePlayerWeapon(playerid, 8, 100);
    GivePlayerWeapon(playerid, 31, 500);
    GivePlayerWeapon(playerid, 29, 300);
    GivePlayerWeapon(playerid, 34, 50);
    GivePlayerWeapon(playerid, 24, 100);
    return 1;
}
if(strcmp(cmdtext, "/fbi", true) == 0)
{
    if(GetPlayerSkin(playerid) == 286) return SendClientMessage(playerid, COLOR_RED, "You are FBI already!");
    SetPlayerArmour(playerid, 100);
    SetPlayerHealth(playerid, 100);
    SetPlayerSkin(playerid, 286);
    SetPlayerColor(playerid, COLOR_GREEN);
    GivePlayerWeapon(playerid, 8, 300);
    GivePlayerWeapon(playerid, 31, 800);
    GivePlayerWeapon(playerid, 29, 800);
    GivePlayerWeapon(playerid, 34, 100);
    GivePlayerWeapon(playerid, 24, 300);
    return 1;
}
Also, if you use these commands, it will add you infinitive ammo each time they do /swat /fbi /swat /fbi. Use ResetPlayerWeapons(playerid) before SetPlayerArmour, to reset their weapons.
Reply
#4

I will tell you what's your problem... First you add this new line to your script.
Код:
new SWATOnDuty[MAX_PLAYERS];
Then... the command should looks like that.
Код:
if(strcmp(cmdtext, "/swat", true) == 0)
{
	if(IsPlayerConnected(playerid))
	{
		if(SWATOnDuty[playerid] == 0)
		{
			SetPlayerSkin(playerid,285);
			SetPlayerArmour(playerid,100);
			SetPlayerHealth(playerid,100);
			SetPlayerColor(playerid, COLOR_GREEN);
			GivePlayerWeapon(playerid,8,100);
			GivePlayerWeapon(playerid,31,500);
			GivePlayerWeapon(playerid,29,300);
			GivePlayerWeapon(playerid,34,50);
			GivePlayerWeapon(playerid,24,100);
			SWATOnDuty[playerid] = 1;
			SendClientMessage(playerid,COLOR_GRAD1,"You are now ON DUTY as SWAT.");
			return 1;
		}
		else if(SWATOnDuty[playerid] == 1)
		{
			SetPlayerSkin(playerid,101);//You can change to whatever you want, or change it back to the pModel of player's skin
			SetPlayerArmour(playerid,0);
			SetPlayerHealth(playerid,100);
			ResetPlayerWeapons(playerid);
			SWATOnDuty[playerid] = 0;
			SendClientMessage(playerid,COLOR_GRAD1,"You are now OFF DUTY as SWAT.");
			return 1;
		}
	}
	return 1;
}
I hope you see what has been changed, and You can do the same with /fbi... just need to make another "new".
Like "new FBIOnDuty[MAX_PLAYERS];", Enjoy.
Reply
#5

Thanks for help, I appreciate this!
Reply
#6

I want like this another script anyone knows
Reply


Forum Jump:


Users browsing this thread: