#1

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
Reply
#2

Код:
 
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
Reply
#3

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?
Reply
#4

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
Reply
#5

Код:
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;
 }
}
Reply
#6

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
Reply
#7

It's easier to use for

PHP код:
new generators[12];

CMD:push(playeridparams[])
{
    new 
ready=1;
    for (new 
i=0i<12i++)
    {
        if(
generators[i]==0ready=0
    }
    if(
ready)
    {
        
//do something here
    
}
    return 
1;
}

CMD:repair(playeridparams[])
{
    for(new 
i=0i<12i++)
    {
        if(
generators[i]==0) { generators[i]=1; break; }
    }
    return 
1;

Reply
#8

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 .
Reply
#9

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
Reply
#10

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
PHP код:
break; 
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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)