Scripting command(s) -
Wrench - 01.01.2017
Hello, everyone! I want to make a command. /onduty and /offduty for cops. I want like:
I did /offduty
I got the message: You're now an off-duty cop.
Everyone got: Wrench(ID.) is now an off-duty cop.
etc.
I did this:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/offduty", cmdtext, true, 5) == 0)
{
SendClientMessage(playerid,0xFFFFFF,"You're now an off-duty cop.");
format(fstr, sizeof(fstr), "%s [%d] is now an off-duty cop.", GetName(playerid), playerid, GetName(targetid), targetid, reason);
}
return 0;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/onduty", cmdtext, true, 5) == 0)
{
SendClientMessage(playerid,0xFFFFFF,"You're now an on-duty cop.");
format(fstr, sizeof(fstr), "%s [%d] is now an on-duty cop.", GetName(playerid), playerid, GetName(targetid), targetid, reason);
}
return 0;
}
I am sure that it is wrong. How can I do this? Please help me guys.
Respuesta: Scripting command(s) -
Goncho28 - 01.01.2017
You only need to add SendClientMessageToAll under the both formats! And you don't need both callbacks (OnPlayerCommandText), only one.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/offduty", cmdtext, true, 5) == 0)
{
new string[128];
SendClientMessage(playerid,0xFFFFFF,"You're now an off-duty cop.");
format(string, sizeof(string), "%s [%d] is now an off-duty cop.", GetName(playerid), playerid, GetName(targetid), targetid, reason);
SendClientMessageToAll(-1, string);
}
if (strcmp("/onduty", cmdtext, true, 5) == 0)
{
new string[128];
SendClientMessage(playerid,0xFFFFFF,"You're now an on-duty cop.");
format(string, sizeof(string), "%s [%d] is now an on-duty cop.", GetName(playerid), playerid, GetName(targetid), targetid, reason);
SendClientMessageToAll(-1, string);
}
return 0;
}
You must not define a global string, you must make one for each format, regards!
Re: Scripting command(s) -
Loinal - 01.01.2017
PHP код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/offduty", cmdtext, true, 5) == 0)
{
SendClientMessage(playerid,0xFFFFFF,"You're now an off-duty cop.");
format(fstr, sizeof(fstr), "%s [%d] is now an off-duty cop.", GetName(playerid), playerid, GetName(targetid), targetid, reason);
SendClientMessageToAll(0xFF0000FF,fstr);
}
return 0;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/onduty", cmdtext, true, 5) == 0)
{
SendClientMessage(playerid,0xFFFFFF,"You're now an on-duty cop.");
format(fstr, sizeof(fstr), "%s [%d] is now an on-duty cop.", GetName(playerid), playerid, GetName(targetid), targetid, reason);
SendClientMessageToAll(0xFF0000FF,fstr);
}
return 0;
}
Re: Scripting command(s) -
Wrench - 01.01.2017
Thank ya very much, guys!
Re: Scripting command(s) -
saffierr - 01.01.2017
Why aren't you using ZCMD ? And for the cmd you could use a boolean.
Re: Scripting command(s) -
Codeah - 01.01.2017
I recommend you to use PawnCMD. It uses memory hacking to increase speed and is way easier to write down every single time.
https://sampforum.blast.hk/showthread.php?tid=608474