Do this to all the players, not only me. -
gamersx - 17.02.2017
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.
Re: Do this to all the players, not only me. -
Wolfe - 17.02.2017
Make a loop that loops through every player then set the variable to one.
https://sampwiki.blast.hk/wiki/Loops
Re: Do this to all the players, not only me. -
gamersx - 17.02.2017
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
Respuesta: Do this to all the players, not only me. -
Eloy - 17.02.2017
More fast using Foreach
Edit:
Foreach no loop if IsPlayerConnected, replace to variable bool logged
PHP код:
foreach(new i : Players)
{
if(Player[i][Logged] == True && pAdmin[i] > 0)
{
// They're admin, send message
}
}
Re: Do this to all the players, not only me. -
Wolfe - 17.02.2017
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.
Re: Do this to all the players, not only me. -
gamersx - 17.02.2017
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
Re: Do this to all the players, not only me. -
Sew_Sumi - 17.02.2017
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.
Re: Do this to all the players, not only me. -
gamersx - 17.02.2017
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
Re: Do this to all the players, not only me. -
Sew_Sumi - 17.02.2017
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");
}
Re: Do this to all the players, not only me. -
gamersx - 17.02.2017
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;
}