Global variable i think
#1

Hello, how to change global variable for all players if i use command?
I have this
pawn Код:
new spikes[MAX_PLAYERS];
and after command i need it to bee like
pawn Код:
spikes[playerid] = 0;
but the thing is i cant figure out how to make it for all players not just for one who used the command. And yea, i hope its the right word for it Thanks
Reply
#2

alright. can be done using a loop:
pawn Код:
// zcmd:
CMD:spikesoffall(playerid) {
    for(new i = 0; i < MAX_PLAYERS; i++) spikes[i] = 0;
    return 1;
}
Reply
#3

Thanks, i will try that.
Reply
#4

Sorry for double post, didnt work. It was the same, removed all spikes but that thing staid. Maybe i have to better explain. If someone uses spike command it makes this to go to 1
pawn Код:
spikes[playerid] = 1;
if someone already placed spikes then this happens -
pawn Код:
if (spikes[playerid] == 1) return SendClientMessage(playerid, 0xE01B4CFF, "{ff0000}** {C8D1CC}You already placed spikes!");
So if admin uses command to remove all players spikes on server, then how to get that spikes[playerid] = 1; goes to spikes[playerid] = 0; for everyone?
Reply
#5

Quote:
Originally Posted by bleedis
Посмотреть сообщение
Sorry for double post, didnt work. It was the same, removed all spikes but that thing staid. Maybe i have to better explain. If someone uses spike command it makes this to go to 1
pawn Код:
spikes[playerid] = 1;
if someone already placed spikes then this happens -
pawn Код:
if (spikes[playerid] == 1) return SendClientMessage(playerid, 0xE01B4CFF, "{ff0000}** {C8D1CC}You already placed spikes!");
So if admin uses command to remove all players spikes on server, then how to get that spikes[playerid] = 1; goes to spikes[playerid] = 0; for everyone?
Well instead of setting spikes[playerid] = 0 you would need to do what the guy above said.

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
So when you use the command to set the spikes to 0 for all players. Instead of doing spikes[playerid] = 0 you would need to do spikes[i] = 0 . Then instead of just setting that variable to 0 for the player who used the command [playerid], it would go threw all the online players [i] and set that variable to 0 for them.

So when the player uses the command to set the spikes, you would do spikes[playerid] = 1 and the admin command to remove ALL spikes would have spikes[i] = 0 in the command with the for (new.. code before you use the [i].

Did that make any sense?
Reply
#6

Yup. Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)