Do this to all the players, not only me.
#1

Hello, im having this trouble and i need a little help.

I made this command to "activate" another.

pawn Код:
zcmd(acamara, playerid, params[])
    {
        if(!Team_LSTV(playerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "No formas parte de LSTV.");
        {
            if(IsPlayerInRangeOfPoint(playerid, 2.0,2013.0183,-1282.8282,23.9762))
            {
            camarografo[playerid] = 1;
            SendClientMessageEx(playerid, COLOR_WHITE, "Agarraste la camara,ahora pueden verte en un televisor.!");
            }

        }
        return 1;
    }
The thing its this " camarografo[playerid] = 1; " its like an /adminduty. So, when i do this i can use my command that its "/watchtv", but only i can use it, how can i make that this line " camarografo[playerid] = 1; " goes for all the players on the server.

I mean that when i use /acamara, all the players have activated this " camarografo[playerid] = 1; " not only me. Thank you!

Thanks for reading.
Reply
#2

Make a loop that loops through every player then set the variable to one.

https://sampwiki.blast.hk/wiki/Loops
Reply
#3

Hi, thanks for helping, by looking i found this.

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    {
        if(pAdmin[playerid] > 0) // alter to actual variable 'pAdmin' is ambiguous at best.
        {
            // They're admin, send message
        }
    }
}
How can i do that? im confused
Reply
#4

More fast using Foreach

Edit:

Foreach no loop if IsPlayerConnected, replace to variable bool logged

PHP код:
foreach(new Players)
{
    if(
Player[i][Logged] == True && pAdmin[i] > 0)
    {
            
// They're admin, send message
    
}

Reply
#5

pawn Код:
new bool:CanWatchTV[MAX_PLAYERS];

CMD:enabletv(playerid, params[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        CanWatchTV[i] = true;
    }
    return 1;
}
Put your if statements iand what not at the top before the loop.
Reply
#6

Hi, i made this:

pawn Код:
zcmd:enabletv(playerid, params[])
if(!Team_LSTV(playerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "No formas parte de LSTV.");
if(IsPlayerInRangeOfPoint(playerid, 2.0,2013.0183,-1282.8282,23.9762))
SendClientMessageEx(playerid, COLOR_WHITE, "Agarraste la camara,ahora pueden verte en un televisor.!");
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        camarografo[i] = true;
    }
    return 1;
}
And obviously its wrong, errors,warnings. How can i do it? sorry for asking but i dont know
Reply
#7

Quote:
Originally Posted by gamersx
Посмотреть сообщение
And obviously its wrong, errors,warnings. How can i do it? sorry for asking but i dont know
Would be good for you to provide those errors so you can get helped faster.
Reply
#8

Yeah, i didnt because i just put it like that and i though obviously its wrong. But there you go :

warning 213: tag mismatch
error 010: invalid function or declaration
error 021: symbol already defined: "SendClientMessageEx"
error 010: invalid function or declaration
fatal error 107: too many error messages on one line
Reply
#9

Line number would help, as that's vital to see where the error actually is occurring.

If statements are generally encased in braces { } unless they are on one line.

PHP код:
if(LoggedIn(playerid))
{
    
SendClientMessage(playerid, -1"Player is logged in");

Reply
#10

I think the solution will be how to put more stuff in this:

{
for(new i = 0; i < MAX_PLAYERS; i++)
{
camarografo[i] = true;
}
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)