PDA

View Full Version : SWAT and FBI Commands


newarvuti
24/04/2010, 06:53 AM
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(37 0) : warning 217: loose indentation
C:\Documents and Settings\Janar\Desktop\SAMP\gamemodes\minu2.pwn(38 7) : warning 217: loose indentation

Both are the SetPlayerHealth lines in FBI and SWAT.

Assyria
24/04/2010, 08:30 AM
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;
}
}

Dark_Kostas
24/04/2010, 08:30 AM
loose indentation is this.

if(something)
{
something else
}
else
{
something else
}

to fix it, you need to fix your lines

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.

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.

Eliran Pesahov
24/04/2010, 08:41 AM
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.

newarvuti
24/04/2010, 11:27 AM
Thanks for help, I appreciate this!

Viper_swipe
13/10/2012, 07:55 AM
I want like this another script anyone knows