info -
StR_MaRy - 26.10.2016
hey guys i want to activate a cmd something like /push and i want that command to check if all 12 generators are activated that's 1 and not 0 how can i make that ? something like
new Generator1 = 0;
CMD:repair(playerid)
{
Generator1 = 1;
}
then another one again...
until 12 then he go somewhere to use /push and that command need to check if all generators have 1 and not 0
Re: info -
ThatFag - 26.10.2016
Код:
new Generator[12];
CMD:repair(playerid)
{
if(Generator[1] == 1 || Generator[2] == 1 // and so on till 12)
{
making an generator be 1 or 0
Generator[1] = 1;
Generator[2] = 1; etc
Re: info -
RockyGamer - 26.10.2016
Quote:
Originally Posted by ThatFag
Код:
new Generator[12];
CMD:repair(playerid)
{
if(Generator[1] == 1 || Generator[2] == 1 // and so on till 12)
{
making an generator be 1 or 0
Generator[1] = 1;
Generator[2] = 1; etc
|
As I understood he wants to check if all of the generators are working so use && (and) instead of || (or) in your if.
btw is /repair supposed to fix all generators or just one by one?
Re: info -
StR_MaRy - 26.10.2016
one by one and then after you use /push that command should check if all generators are 1 that's repaired 100 hp how you can say
Re: info -
ThatFag - 26.10.2016
Код:
new Generator[13];
COMMAND:repair(playerid, params[])
{
if(Generator[1] == 1)
{
Generator[2] = 1;
}
else if(Generator[2] == 1)
{
Generator[3] = 1;
}
else if(Generator[3] == 1)
{
Generator[4] = 1;
}
else if(Generator[4] == 1)
{
Generator[5] = 1;
}
else if(Generator[5] == 1)
{
Generator[6] = 1;
}
else if(Generator[8] == 1)
{
Generator[9] = 1;
}
else if(Generator[9] == 1)
{
Generator[10] = 1;
}
else if(Generator[10] == 1)
{
Generator[11] = 1;
}
else if(Generator[11] == 1)
{
Generator[12] = 1;
}
return 1;
}
COMMAND:push(playerid , params[])
{
if(Generator[1] == 1 && Generator[2] == 1 && Generator[3] == 1 && Generator[4] == 1 && Generator[5] == 1 && Generator[6] == 1 && Generator[7] == 1 && Generator[8] == 1 && Generator[9] == 1 && Generator[10] == 1 && Generator[11] == 1 && Generator[12] == 1)return SendClientMessage(playerid, -1,"Generators arent all 1");
{
RepairVehicle(playerid);
return 1;
}
}
Re: info -
StR_MaRy - 26.10.2016
and i have a question dear "ThatFag" if i want to be next to a generator like a coord or something like generator 6 you need to be at that coord and generator 3 another coords it will still work fine ?
EDIT: and if i want to do something like SendClientMessage to give a message to all Survivors i did something like
new Survivors = 0; cause i wanted to make a textdraw to see how many survivors are alive

so if i do something like new Survivors = Survivors[playerid]; and then SendClientMesssage(Survivros[playerid], etc... will send a message to all survivors ? who are alive
Re: info -
RockyGamer - 26.10.2016
It's easier to use for
PHP код:
new generators[12];
CMD:push(playerid, params[])
{
new ready=1;
for (new i=0; i<12; i++)
{
if(generators[i]==0) ready=0;
}
if(ready)
{
//do something here
}
return 1;
}
CMD:repair(playerid, params[])
{
for(new i=0; i<12; i++)
{
if(generators[i]==0) { generators[i]=1; break; }
}
return 1;
}
Re: info -
ThatFag - 26.10.2016
Well i think yes, as long as you can use IsPlayerInRangeOfPoint for any generator so yeah.
about survivors do
Код:
New Survivors[MAX_PLAYERS];
then where you define if a player is survivor or he died do
Код:
Survivors[playerid] = 1;
if hes dead
Survivors[playerid] = 0;
its better i think .
Re: info -
StR_MaRy - 26.10.2016
yea rocky but i want to use /repair just for one generator then another one use /repair not using /repair and repair all 12 generators

and as i know if i use /repair it need's to set ready=1; for that generator so when you use /push to read all 12 generators are ready
Re: info -
RockyGamer - 26.10.2016
Quote:
Originally Posted by StR_MaRy
yea rocky but i want to use /repair just for one generator then another one use /repair not using /repair and repair all 12 generators  and as i know if i use /repair it need's to set ready=1; for that generator so when you use /push to read all 12 generators are ready
|
When i was writing that i didn't know that you had to be in a certain position to repair a generator and you probably haven't noticed that i've put
after repairing a generator so it repairs only one generator.
In this case it's best to use IsPlayerInRangeOfPoint and check for every generator as ThatFag already mentioned before.
EDIT: also with variable ready i check if all of the generators are ready so you have no reason to set that to 1 in cmd repair