SA-MP Forums Archive
Script doesnt give me a weapon but complies just fine - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Script doesnt give me a weapon but complies just fine (/showthread.php?tid=79723)



Script doesnt give me a weapon but complies just fine - HydraX - 30.05.2009

pawn Код:
forward Minigame();
new gSlots;

pawn Код:
public Minigame()
{
    new string[64];
    switch(random(5))
    {
        case 0:
        {
          GameTextForAll("~r~~h~~h~MINIGUN ~n~~y~~h~FIGHT", 3000, 3);
          for(new i = 0; i < gSlots; i++)
          {
            if(!IsPlayerConnected(i))
              continue;
            GivePlayerWeapon(i, 38, 20);
          }
        }
        case 1:
        {
          GameTextForAll("~r~~h~~h~ROCKET ~n~~y~~h~FIGHT", 3000, 3);
          for(new i = 0; i < gSlots; i++)
          {
            if(!IsPlayerConnected(i))
              continue;
            GivePlayerWeapon(i, 35, 4);
          }
        }
        case 2:
        {
          GameTextForAll("~r~~h~~h~CHAINSAW ~n~~y~~h~FIGHT", 3000, 3);
          for(new i = 0; i < gSlots; i++)
          {
            if(!IsPlayerConnected(i))
              continue;
            GivePlayerWeapon(i, 9, 1);
          }
        }
        case 3:
        {
          GameTextForAll("~r~~h~~h~GRENADE ~n~~y~~h~FIGHT", 3000, 3);
          for(new i = 0; i < gSlots; i++)
          {
            if(!IsPlayerConnected(i))
              continue;
            GivePlayerWeapon(i, 16, 10);
          }
        }
        case 4:
        {
          GameTextForAll("~r~~h~~h~FLAMETHROWER ~n~~y~~h~FIGHT", 3000, 3);
          for(new i = 0; i < gSlots; i++)
          {
            if(!IsPlayerConnected(i))
              continue;
            GivePlayerWeapon(i, 37, 500);
          }
        }
    }
}



Re: Script doesnt give me a weapon but complies just fine - Cezar - 30.05.2009

Well erm...probably I'm mistaken but why do you continue if(!IsPlayerConnected(i))? Doesn't that mean your giving the weapon only if the player is not connected?


Re: Script doesnt give me a weapon but complies just fine - HydraX - 30.05.2009

it gives the player a weapon if the player is connect to the server


Re: Script doesnt give me a weapon but complies just fine - Gamer007 - 30.05.2009

No it doesn't

Код:
if(!IsPlayerConnected(i))
if(! <<<< // it means FALSE that means if he's not connected. Learn to code


Re: Script doesnt give me a weapon but complies just fine - yezizhu - 30.05.2009

edited
for(new i = 0; i < gSlots; i++)
to
for(new i;i<MAX_PLAYERS;i++)


Re: Script doesnt give me a weapon but complies just fine - yezizhu - 30.05.2009

Quote:
Originally Posted by Gamer007
No it doesn't

Код:
if(!IsPlayerConnected(i))
if(! <<<< // it means FALSE that means if he's not connected. Learn to code
He's right..
He is doing !IsPlayerConnected(i) continue;


Re: Script doesnt give me a weapon but complies just fine - HydraX - 30.05.2009

well i deleted the ! but it still doesnt work


Re: Script doesnt give me a weapon but complies just fine - Gamer007 - 30.05.2009

Quote:
Originally Posted by yezizhu
edited
for(new i = 0; i < gSlots; i++)
to
for(new i;i<MAX_PLAYERS;i++)
Did you make this HydraX?


Re: Script doesnt give me a weapon but complies just fine - member - 30.05.2009

Here is what they all mean HydraX.

pawn Код:
public Minigame()
{
    new string[64];
    switch(random(5))
    {
        case 0:
        {
          GameTextForAll("~r~~h~~h~MINIGUN ~n~~y~~h~FIGHT", 3000, 3);
          for(new i;i<MAX_PLAYERS;i++)
          {
            if(IsPlayerConnected(i))
            GivePlayerWeapon(i, 38, 20);
          }
        }
        case 1:
        {
          GameTextForAll("~r~~h~~h~ROCKET ~n~~y~~h~FIGHT", 3000, 3);
          for(new i;i<MAX_PLAYERS;i++)
          {
            if(IsPlayerConnected(i))
              continue;
            GivePlayerWeapon(i, 35, 4);
          }
        }
        case 2:
        {
          GameTextForAll("~r~~h~~h~CHAINSAW ~n~~y~~h~FIGHT", 3000, 3);
          for(new i;i<MAX_PLAYERS;i++)
          {
            if(IsPlayerConnected(i))
            GivePlayerWeapon(i, 9, 1);
          }
        }
        case 3:
        {
          GameTextForAll("~r~~h~~h~GRENADE ~n~~y~~h~FIGHT", 3000, 3);
          for(new i;i<MAX_PLAYERS;i++)
          {
            if(IsPlayerConnected(i))
            GivePlayerWeapon(i, 16, 10);
          }
        }
        case 4:
        {
          GameTextForAll("~r~~h~~h~FLAMETHROWER ~n~~y~~h~FIGHT", 3000, 3);
          for(new i;i<MAX_PLAYERS;i++)
          {
            if(IsPlayerConnected(i))
            GivePlayerWeapon(i, 37, 500);
          }
        }
    }
}



Re: Script doesnt give me a weapon but complies just fine - Gamer007 - 30.05.2009

i think its not correct

Код:
for(new i;i<MAX_PLAYERS;i++)
          {
i think this code won't work it's gotta be like this:

Код:
for(new i=0;i<MAX_PLAYERS;i++)
          {