PDA

View Full Version : Hiding badge for LSPD & FBI


SerbanRobert
13/07/2017, 04:12 PM
Hi SAMP community users, can someone make me a zcmd command that allowes only FBI and LSPD to hide their badges ? I mean, it will be useful for undercover operations. And, if possible, when a LSPD detective / FBI Agent type /hidebadge to show a message only for them "You concealed your badge" and make their names white and when they type again to show a message "You took out your badge" and make their names blue. Can someone help me with that ? Because I'm a noob scripter and I don't know how to script that.

Abagail
13/07/2017, 04:16 PM
SA:MP doesn't provide native functions for a faction system or badges, you'll have to give examples of your code that's relevant to faction badges (setting them, hiding them, detecting them).

SerbanRobert
13/07/2017, 04:33 PM
I mean, when an FBI or LSPD types /hidebadge to get a message with "You concealed your badge" and simply make their names white from blue and when they type again to get a message with "You took out your badge" and make their names blue from white.
For LSPD I have "IsACop"
And for FBI I have "IsFBI"
PS: A command that makes only feds and officers name white from their duty color, blue and vice versa.

SerbanRobert
13/07/2017, 04:45 PM
So, can anyone help me ?

kubak01
13/07/2017, 04:59 PM
Aye.

new badgeActive[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
badgeActive[playerid] = true;
}

COMMAND:showbadge(playerid) return cmd_hidebadge(playerid);
COMMAND:hidebadge(playerid)
{
badgeActive[playerid] = !badgeActive[playerid];
new string[24];
format(string, sizeof string, "Badge status: %s", ( badgeActive[playerid] ) ? ("visible") : ("hidden") )
return 1;
}


And just use this variable somewhere in your /badge command.

ElMaestro123
13/07/2017, 05:09 PM
Aye.

new badgeActive[playerid];

public OnPlayerConnect(playerid)
{
badgeActive[playerid] = true;
}

COMMAND:showbadge(playerid) return cmd_hidebadge(playerid);
COMMAND:hidebadge(playerid)
{
badgeActive[playerid] = !badgeActive[playerid];
new string[128];
format(string, sizeof string, "Badge status: %s", ( badgeActive[playerid] ) ? ("visible") : ("hidden") )
return 1;
}


And just use this variable somewhere in your /badge command.
this won't work, you can't declare player variable by adding [ playerid ], only by adding [ MAX_PLAYERS ].
also this string length looks like shit, 128? ok.

kubak01
13/07/2017, 05:21 PM
this won't work, you can't declare player variable by adding [ playerid ], only by adding [ MAX_PLAYERS ].
also this string length looks like shit, 128? ok.

Aye i wrote this on the forums and didn't even realise this mistake with declaring somehow, thanks for correcting me.

Sew_Sumi
13/07/2017, 05:33 PM
Aye i wrote this on the forums and didn't even realise this mistake with declaring somehow, thanks for correcting me.

This is Scripting Help, not script for you... By simply pasting up bad code, it encourages those who aren't actually following the rules, to continue doing so because they will just get what they want.

They need to provide code themselves, otherwise there should be no help.

Omirrow
13/07/2017, 09:53 PM
Took me less than a minute to write that, you can edit and expand on this one, if you want to-
Here you go;

bool:BadgeStatus[MAX_PLAYERS char],

public OnPlayerConnect(playerid)
{
BadgeStatus{playerid} = false;
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/mycommand", cmdtext, true, 10) == 0)
{
if(BadgeStatus{playerid})
{
SendClientMessage(playerid, -1, "You've hidden your badge.");
SetPlayerColor(playerid, COLORWHENBADGEISHIDDEN);
BadgeStatus{playerid} = false;
}
else
{
SendClientMessage(playerid, -1, "You've brought your badge back!");
SetPlayerColor(playerid, COLORWHENBADGEISON);
BadgeStatus{playerid} = true;
}
return 1;
}
return 0;
}