PDA

View Full Version : Do this to all the players, not only me.


gamersx
17/02/2017, 03:08 AM
Hello, im having this trouble and i need a little help.

I made this command to "activate" another.

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.

Wolfe
17/02/2017, 03:18 AM
Make a loop that loops through every player then set the variable to one.

http://wiki.sa-mp.com/wiki/Loops

gamersx
17/02/2017, 03:24 AM
Hi, thanks for helping, by looking i found this.

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 :(

Eloy
17/02/2017, 03:25 AM
More fast using Foreach

Edit:

Foreach no loop if IsPlayerConnected, replace to variable bool logged

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

Wolfe
17/02/2017, 03:28 AM
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.

gamersx
17/02/2017, 03:48 AM
Hi, i made this:

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 :(

Sew_Sumi
17/02/2017, 04:11 AM
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.

gamersx
17/02/2017, 04:14 AM
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

Sew_Sumi
17/02/2017, 04:52 AM
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.

if(LoggedIn(playerid))
{
SendClientMessage(playerid, -1, "Player is logged in");
}

gamersx
17/02/2017, 04:53 AM
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;
}

Sew_Sumi
17/02/2017, 05:25 AM
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;
}

You may want to look at how you are using camarografo, as that's likely to be only for the person who used the command, not everyone else.

gamersx
17/02/2017, 05:33 AM
Let me explain this maybe it will help, i have a "tv system" so /enabletv will be like "activate the other command " so the players can use /watchtv, and when /tvoff, now the players when use /watchtv they'll be not able to use it.

The problem is when i write /enabletv, it is working only for me i can use /watchtv, but for example my friend can/t.

And i put what you said and this are the errors.

(30887) : error 010: invalid function or declaration // FIRST LINE
(30887 -- 30892) : error 010: invalid function or declaration
(30887 -- 30896) : error 010: invalid function or declaration
(30887 -- 30896) : fatal error 107: too many error messages on one line // LAST LINE OF WHAT YOU SAID.

and i have it defined like this
new camarografo[MAX_PLAYERS];

Thanks for helping me

Sew_Sumi
17/02/2017, 07:41 AM
Show both the commands, and highlight which ones are the lines that are erroring. When you use /enabletv, it shouldn't need to loop and set everyone elses variables.