how to ? - 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: how to ? (
/showthread.php?tid=133591)
how to ? -
Lajko1 - 13.03.2010
How i can make a command that have 2 things to do
if i type /chatoff it will give chat off i mean nobody can't write in chat... and if i type /chatoff it will put the chat ON again...
i know i can make 2 commands /chatoff and /chaton or something like this but i just need informations how to this what i ask for =)
ty for any help
Re: how to ? -
Jakku - 13.03.2010
pawn Код:
//Above Ongamemodeinit:
new ChatDisabled;
public OnGameModeInit()
{
ChatDisabled = 0; //Chat enabled
return 1;
}
else if(strcmp(cmd, "/chat", true) == 0) {
if (ChatDisabled == 0) {
ChatDisabled = 1; //Chat off
return 1;
}
if (ChatDisabled == 1) {
ChatDisabled = 0; //Chat on
return 1;
}
return 1;
}
public OnPlayerText(playerid, text[])
{
if(ChatDisabled == 1)
{
SendClientMessage(playerid, COLOR_YOURCOLOR, "The chat is currently disabled by an admin.");
return 0;
}
return 1;
}
Try this
Re: how to ? -
iron_war_lord - 13.03.2010
Quote:
Originally Posted by Jakku
pawn Код:
//Above Ongamemodeinit: new ChatDisabled;
public OnGameModeInit() { ChatDisabled = 0; //Chat enabled return 1; }
else if(strcmp(cmd, "/chat", true) == 0) { if (ChatDisabled == 0) { ChatDisabled = 1; //Chat off return 1; } if (ChatDisabled == 1) { ChatDisabled = 0; //Chat on return 1; } return 1; }
public OnPlayerText(playerid, text[]) { if(ChatDisabled == 1) { SendClientMessage(playerid, COLOR_YOURCOLOR, "The chat is currently disabled by an admin."); return 0; } return 1; }
Try this
|
You forgot a few things there
Here's my take:
You will need a placeholder for a boolean assignment for each player, in an array:
Now when the player types say for example: /tchat
Under public OnPlayerCommandText(playerid, cmdtext[])
Код:
if(strcmp(cmdtext, /tchat, true) == 0)
{
if(ChatToggle == false)
{
ChatToggle = true;
{
if(ChatToggle == true)
{
ChatToggle = false;
{
}
Under OnPlayerText(playerid, text[])
Код:
{
if(ChatToggle == true)
{
return 0;
}
if(ChatToggle == false)
{
return 1;
}
}
Don't forget to remove the return 1; under OnPlayerText first, or this won't work
Re: how to ? -
Lajko1 - 13.03.2010
ok i will try
Re: how to ? -
Jakku - 13.03.2010
Quote:
Originally Posted by Zinglish
Quote:
Originally Posted by Jakku
pawn Код:
//Above Ongamemodeinit: new ChatDisabled;
public OnGameModeInit() { ChatDisabled = 0; //Chat enabled return 1; }
else if(strcmp(cmd, "/chat", true) == 0) { if (ChatDisabled == 0) { ChatDisabled = 1; //Chat off return 1; } if (ChatDisabled == 1) { ChatDisabled = 0; //Chat on return 1; } return 1; }
public OnPlayerText(playerid, text[]) { if(ChatDisabled == 1) { SendClientMessage(playerid, COLOR_YOURCOLOR, "The chat is currently disabled by an admin."); return 0; } return 1; }
Try this
|
You forgot a few things there
Here's my take:
You will need a placeholder for a boolean assignment for each player, in an array:
Now when the player types say for example: /tchat
Under public OnPlayerCommandText(playerid, cmdtext[])
Код:
if(strcmp(cmdtext, /tchat, true) == 0)
{
if(ChatToggle == false)
{
ChatToggle = true;
{
if(ChatToggle == true)
{
ChatToggle = false;
{
}
Under OnPlayerText(playerid, text[])
Код:
{
if(ChatToggle == true)
{
return 0;
}
if(ChatToggle == false)
{
return 1;
}
}
Don't forget to remove the return 1; under OnPlayerText first, or this won't work
|
You won't need. My version works perfectly