Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] i have a error

 
  • 0 Vote(s) - 0 Average
Pawn i have a error
Nicolas_Belic
Offline

Burgershot Member
Posts: 10
Threads: 5
Joined: Feb 2021
Reputation: 0
Location: Argentina
#1
2021-02-20, 01:27 PM
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
LinesinRows
Offline

Burgershot Member
Posts: 13
Threads: 4
Joined: Feb 2020
Reputation: 0
Location: Turkey
#2
2021-02-20, 05:34 PM
Change Gl_Privados[playerid] to [font=Monaco, Consolas, Courier, monospace]Gl_Privados[i] in foreach.[/font]
Nicolas_Belic
Offline

Burgershot Member
Posts: 10
Threads: 5
Joined: Feb 2021
Reputation: 0
Location: Argentina
#3
2021-02-20, 07:37 PM
Nope, this not works
destiezk
Offline

Burgershot Member
Posts: 41
Threads: 1
Joined: Feb 2021
Reputation: 3
Location: Hungary
#4
2021-02-20, 08:53 PM (This post was last modified: 2021-02-20, 08:53 PM by destiezk.)
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.
LinesinRows
Offline

Burgershot Member
Posts: 13
Threads: 4
Joined: Feb 2020
Reputation: 0
Location: Turkey
#5
2021-02-20, 08:55 PM (This post was last modified: 2021-02-20, 09:01 PM by LinesinRows.)
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?
daddy.
Offline

Burgershot Member
Posts: 58
Threads: 7
Joined: Nov 2019
Reputation: 3
Location: Bosnia and Herzegovina / Zenica
#6
2021-02-20, 08:59 PM
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
https://github.com/daddyDOT

♥
[Image: image.png]
Nicolas_Belic
Offline

Burgershot Member
Posts: 10
Threads: 5
Joined: Feb 2021
Reputation: 0
Location: Argentina
#7
2021-02-20, 09:19 PM (This post was last modified: 2021-02-20, 09:20 PM by Nicolas_Belic.)
(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)
daddy.
Offline

Burgershot Member
Posts: 58
Threads: 7
Joined: Nov 2019
Reputation: 3
Location: Bosnia and Herzegovina / Zenica
#8
2021-02-20, 09:23 PM (This post was last modified: 2021-02-20, 09:23 PM by daddy..)
Hmm, have you tried that command I sent you, it's possible that I made some mistakes?
daddy. / daddyDOT
https://github.com/daddyDOT

♥
[Image: image.png]
Nicolas_Belic
Offline

Burgershot Member
Posts: 10
Threads: 5
Joined: Feb 2021
Reputation: 0
Location: Argentina
#9
2021-02-20, 09:32 PM (This post was last modified: 2021-02-20, 09:33 PM by Nicolas_Belic.)
(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
daddy.
Offline

Burgershot Member
Posts: 58
Threads: 7
Joined: Nov 2019
Reputation: 3
Location: Bosnia and Herzegovina / Zenica
#10
2021-02-20, 10:21 PM
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
https://github.com/daddyDOT

♥
[Image: image.png]
arber
Offline

Burgershot Member
Posts: 11
Threads: 0
Joined: Aug 2020
Reputation: 1
Location: Kosovo
#11
2021-02-20, 11:29 PM
what are you trying to make first
Nicolas_Belic
Offline

Burgershot Member
Posts: 10
Threads: 5
Joined: Feb 2021
Reputation: 0
Location: Argentina
#12
2021-02-21, 01:38 AM
(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
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode