[HELP] /policeduty - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] /policeduty (
/showthread.php?tid=153199)
[HELP] /policeduty -
Emanuel_Rodriguez - 07.06.2010
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!
Re: [HELP] /policeduty -
boelie - 07.06.2010
you need GetPlayerName(playerid); for that you can find it on the wiki
Re: [HELP] /policeduty -
Emanuel_Rodriguez - 07.06.2010
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".
Re: [HELP] /policeduty -
AK47KILLA - 07.06.2010
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;
}