[HELP] /policeduty
#1

Can someone help me? Im trying to make it where police can come on duty, and then when they type that again they come off duty. All I got so far is this:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(!strcmp(cmdtext, "/policeduty", true))
	{

	}
	return 1;
}
and no, im not a noob, i got more in my script, i jsut dont want people copying it of. So wat i dont understand is how to make it where on SendClientMessageToAll to say "%s is now on duty as a police officer." and then when he types /police duty again it says "%s is now off duty as a police officer." If you got any info, please let me know!
Reply
#2

you need GetPlayerName(playerid); for that you can find it on the wiki
Reply
#3

Ok I got that part, but how do I put where i type the command again and it says "%s is now off duty". I did this:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(!strcmp(cmdtext, "/policeduty", true))
	{
	new name[MAX_PLAYER_NAME], string[44];
  	GetPlayerName(playerid, name, sizeof(name));
  	format(string, sizeof(string), "%s is now on Police Duty!",name);
  	SendClientMessageToAll(0x0033CCAA, string);
  	return 1;
	}
  return 1;
}
so what do i put to make it where the 1st time you type the command, it says, "%s is now on duty", then when you type the command again it says "%s is now off duty".
Reply
#4

Try using a variable to do it.

Код:
new OnDuty[MAX_PLAYERS];

public OnPlayerCommandText(playerid, cmdtext[])
{
	if(!strcmp(cmdtext, "/policeduty", true))
	{
		if(OnDuty[playerid] == 0)
		{
			OnDuty[playerid] = 1;
			new name[MAX_PLAYER_NAME], string[44];
			GetPlayerName(playerid, name, sizeof(name));
			format(string, sizeof(string), "%s is now on Police Duty!",name);
			SendClientMessageToAll(0x0033CCAA, string);
		} else {
			OnDuty[playerid] = 0;
			new name[MAX_PLAYER_NAME], string[44];
			GetPlayerName(playerid, name, sizeof(name));
			format(string, sizeof(string), "%s is now off Police Duty!",name);
			SendClientMessageToAll(0x0033CCAA, string);
		}
		return 1;
	}
	return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)