• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] i have a error
#1
Code:
new Gl_Privados[MAX_PLAYERS];

CMD:toggl(playerid, params[]) {

? ? if (!Gl_Privados[playerid]) {

? ? ? ? Gl_Privados[playerid] = 1;

? ? ? ? SendClientMessage(playerid, 2, "GL Off");

? ? } else if (Gl_Privados[playerid]) {

? ? ? ? Gl_Privados[playerid] = 0;

? ? ? ? SendClientMessage(playerid, 2, "GL on");

? ? }

? ? return 1;

}





Code:
CMD:gl(playerid, params[])

{

? ? new Text[132], string[128], PlayerName[MAX_PLAYER_NAME];



? ? if(sscanf(params, "s[132]", Text))

? ? {

? ? ? ? SendClientMessage(playerid, -1, "{D41818}[COMANDO]{AFAFAF} /gl <texto>");

? ? }

? ? else

? ? {

? ? ? ? if (Gl_Privados[playerid] == 1) return SendClientMessage(playerid, -1, "{D41818}[ERROR]{AFAFAF} you have blocked the /gl");

? ? ? ? GetPlayerName(playerid, PlayerName, sizeof(PlayerName)); // storing player name first in the PlayerName variable

? ? ? ? foreach(new i : Player)

? ? ? ? {

? ? ? ? if (Gl_Privados[playerid] == 0)

? ? ? ? {

? ? ? ? SendClientMessage(i, 0xFFFFFF00, string);

? ? ? ? }

? ? ? ? if (Gl_Privados[playerid] == 1)

? ? ? ? {

? ? ? ? }

? ? ? ? }

? ? ? ? format(string, sizeof(string), "{D41818}[ID:%d - %s]:{AFAFAF} %s",playerid, PlayerName, Text);

? ? ? ? SendClientMessageToAll(0xFFFFFF00, string);

? ? }



? ? return 1;

}





i have a bug with this, when I disable /gl (send message to all players) I get messages from players anyway
  Reply
#2
Change?Gl_Privados[playerid] to?Gl_Privados[i] in foreach.
  Reply
#3
Nope, this not works
  Reply
#4
Code:
#define CheckLoop(%0) for(new %0; %0 <= Connects;%0) if(IsPlayerConnected(%0))

new bool:gGlPrivados[MAX_PLAYERS] = false; // Gl Privados is disabled defaultly.

EnableGlPrivados(playerid)
{
gGlPrivados[playerid] = true;
SendClientMessage(playerid, -1, "GL Enabled.");
}

DisableGlPrivados(playerid)
{
gGlPrivados[playerid] = false;
SendClientMessage(playerid, -1, "GL Disabled.");
}

CMD:togglegl(playerid, params[])
{
if (gGlPrivados[playerid] == true)
DisableGlPrivados(playerid);
else
EnableGlPrivados(playerid);
return 1;
}

public OnPlayerText(playerid, text[])
{
// rest of your code
CheckLoop(i)
{
if (gGlPrivados[i] == true)
{
new string[132];
format(string, sizeof(string), "PlayerID: %d | Text: %s", playerid, text[0]);
SendClientMessage(i, 0xFF0000FF, string);
}
}
return 0;
}
I didn't test this at all, and also I have no clue what you are trying to achieve, so keep this in mind.
  Reply
#5
You said, when u disabled gl, that's not work.
?In your code you can, if gl open text, else continue.



Code:
if (Gl_Privados[i] == 0)
{
? ?SendClientMessage(i, 0xFFFFFF00, string);
}

else if(Gl_Privados[i] == 1)? ? ? ??
{
? ? continue;
}


But at the end of your code,
Code:
/*
format(string, sizeof(string), "{D41818}[ID:%d - %s]:{AFAFAF} %s",playerid, PlayerName, Text);
SendClientMessageToAll(0xFFFFFF00, string);
*/

SendClientMessageToAll sending your "string" for everyone. Not looking for is user gl opened or closed.
You have already sending string message in foreach. Why again write it to all players?
  Reply
#6
Your code is all messed up, we barely know what do you want.

Try this:

Code:
CMD:gl(playerid, params[])

{

? ? static

? ? ? ? Text[132],

? ? ? ? string[128],

? ? ? ? PlayerName[MAX_PLAYER_NAME];



? ? if(!sscanf(params, "s[132]", Text)) return SendClientMessage(playerid, -1, "{D41818}[COMANDO]{AFAFAF} /gl <texto>");

? ? else

? ? {

? ? ? ? if (Gl_Privados[playerid] == 1) return SendClientMessage(playerid, -1, "{D41818}[ERROR]{AFAFAF} you have blocked the /gl");

? ? ? ? GetPlayerName(playerid, PlayerName, sizeof(PlayerName)); // storing player name first in the PlayerName variable

? ? ? ? foreach(new i : Player)

? ? ? ? {

? ? ? ? ? ? if (Gl_Privados[i] == 0)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? format(string, sizeof(string), "{D41818}[ID:%d - %s]:{AFAFAF} %s",playerid, PlayerName, Text);

? ? ? ? ? ? ? ? SendClientMessage(i, 0xFFFFFF00, string);

? ? ? ? ? ? }

? ? ? ? }

? ? }

? ? return 1;

}
daddy. /?daddyDOT





?

[Image: image.png]

  Reply
#7
(2021-02-20, 08:59 PM)daddy. Wrote:

Your code is all messed up, we barely know what do you want.

Try this:

Code:
[/font][/size][/color]

[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]CMD:gl(playerid, params[])[/font][/size][/color]

[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]{[/font][/size][/color]

[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]? ? static[/font][/size][/color]

[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]? ? ? ? Text[132],[/font][/size][/color]

[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]? ? ? ? string[128],[/font][/size][/color]

[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]? ? ? ? PlayerName[MAX_PLAYER_NAME];[/font][/size][/color]



[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]? ? if(!sscanf(params, "s[132]", Text)) return SendClientMessage(playerid, -1, "{D41818}[COMANDO]{AFAFAF} /gl <texto>");[/font][/size][/color]

[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]? ? else[/font][/size][/color]

[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]? ? {[/font][/size][/color]

[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]? ? ? ? if (Gl_Privados[playerid] == 1) return SendClientMessage(playerid, -1, "{D41818}[ERROR]{AFAFAF} you have blocked the /gl");[/font][/size][/color]

[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]? ? ? ? GetPlayerName(playerid, PlayerName, sizeof(PlayerName)); // storing player name first in the PlayerName variable[/font][/size][/color]

[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]? ? ? ? foreach(new i : Player)[/font][/size][/color]

[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]? ? ? ? {[/font][/size][/color]

[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]? ? ? ? ? ? if (Gl_Privados[i] == 0)[/font][/size][/color]

[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]? ? ? ? ? ? {[/font][/size][/color]

[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]? ? ? ? ? ? ? ? format(string, sizeof(string), "{D41818}[ID:%d - %s]:{AFAFAF} %s",playerid, PlayerName, Text);[/font][/size][/color]

[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]? ? ? ? ? ? ? ? SendClientMessage(i, 0xFFFFFF00, string);[/font][/size][/color]

[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]? ? ? ? ? ? }[/font][/size][/color]

[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]? ? ? ? }[/font][/size][/color]

[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]? ? }[/font][/size][/color]

[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]? ? return 1;[/font][/size][/color]

[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]}[/font][/size][/color]

[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]










daddy, the function it's works but,?can't send custom messages?



Like this:



/gl hi, this is a test etc (reply: the command is bad use?/gl <text>)



/gl (reply:?[ID:0?- player]:{AFAFAF} (random word)
  Reply
#8
Hmm, have you tried that command I sent you, it's possible that I made some mistakes?
daddy. /?daddyDOT





?

[Image: image.png]

  Reply
#9
(2021-02-20, 09:23 PM)daddy. Wrote: Hmm, have you tried that command I sent you, it's possible that I made some mistakes?

i tested the command but not works

[Image: GNuOQtB]

https://imgur.com/a/GNuOQtB
  Reply
#10
My bad, try this:

Code:
CMD:gl(playerid, params[])

{

? ? static

? ? ? ? Text[132],

? ? ? ? string[128],

? ? ? ? PlayerName[MAX_PLAYER_NAME];



? ? if(sscanf(params, "s[132]", Text)) return SendClientMessage(playerid, -1, "{D41818}[COMANDO]{AFAFAF} /gl <texto>");

? ? else

? ? {

? ? ? ? if (Gl_Privados[playerid] == 1) return SendClientMessage(playerid, -1, "{D41818}[ERROR]{AFAFAF} you have blocked the /gl");

? ? ? ? GetPlayerName(playerid, PlayerName, sizeof(PlayerName)); // storing player name first in the PlayerName variable

? ? ? ? foreach(new i : Player)

? ? ? ? {

? ? ? ? ? ? if (Gl_Privados[i] == 0)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? format(string, sizeof(string), "{D41818}[ID:%d - %s]:{AFAFAF} %s",playerid, PlayerName, Text);

? ? ? ? ? ? ? ? SendClientMessage(i, 0xFFFFFF00, string);

? ? ? ? ? ? }

? ? ? ? }

? ? }

? ? return 1;

}
daddy. /?daddyDOT





?

[Image: image.png]

  Reply
#11
what are you trying to make first
  Reply
#12
(2021-02-20, 10:21 PM)daddy. Wrote: My bad, try this:

Code:
CMD:gl(playerid, params[])

{

? ? static

? ? ? ? Text[132],

? ? ? ? string[128],

? ? ? ? PlayerName[MAX_PLAYER_NAME];



? ? if(sscanf(params, "s[132]", Text)) return SendClientMessage(playerid, -1, "{D41818}[COMANDO]{AFAFAF} /gl <texto>");

? ? else

? ? {

? ? ? ? if (Gl_Privados[playerid] == 1) return SendClientMessage(playerid, -1, "{D41818}[ERROR]{AFAFAF} you have blocked the /gl");

? ? ? ? GetPlayerName(playerid, PlayerName, sizeof(PlayerName)); // storing player name first in the PlayerName variable

? ? ? ? foreach(new i : Player)

? ? ? ? {

? ? ? ? ? ? if (Gl_Privados[i] == 0)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? format(string, sizeof(string), "{D41818}[ID:%d - %s]:{AFAFAF} %s",playerid, PlayerName, Text);

? ? ? ? ? ? ? ? SendClientMessage(i, 0xFFFFFF00, string);

? ? ? ? ? ? }

? ? ? ? }

? ? }

? ? return 1;

}



thank you so much, really
  Reply


Forum Jump: