SA-MP Forums Archive
Give all players - 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: Give all players (/showthread.php?tid=176379)



Give all players - SampStunta - 12.09.2010

I've been wondering... What is the script line to give ALL players a weapon?
Sorry I knew this before but I forgot and searched everywhere!

Thanks
-SampStunta


Re: Give all players - willsuckformoney - 12.09.2010

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++) {
            if(IsPlayerConnected(i)) {
                PlayerPlaySound(i,1057,0.0,0.0,0.0);
                GivePlayerWeapon(i,weap,ammo); //Change weap && ammo to what your weapon and ammo should be.
            }
        }



Re: Give all players - Calgon - 13.09.2010

With foreach, I've made this function for you:

pawn Код:
stock giveWeaponToAllPlayers(weaponid, ammo) {
    foreach(Player, x) {
        GivePlayerWeapon(x, weaponid, ammo);
    }
   
    return 1;
}
Quote:
Originally Posted by Monty_Burns
Посмотреть сообщение
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++) {
            if(IsPlayerConnected(i)) {
                PlayerPlaySound(i,1057,0.0,0.0,0.0);
                GivePlayerWeapon(i,weap,ammo); //Change weap && ammo to what your weapon and ammo should be.
            }
has willsuckformoney sayed
You just copied his code completely...


Re: Give all players - SampStunta - 13.09.2010

Thanks so much guys! Will use Calgon's though


Re: Give all players - SampStunta - 13.09.2010

Well, I was actually un-successful... This:

Код:
#include <a_samp>
public OnPlayerCommandText(playerid, cmdtext[])
    if (strcmp("/startevent", cmdtext, true, 10) == 0)
    {
        for(new i = 0; i < MAX_PLAYERS; i++) {
            if(IsPlayerConnected(i)) {
                PlayerPlaySound(i,1057,0.0,0.0,0.0);
                GivePlayerWeapon(i,31,350); 
                GivePlayerWeapon(i,24,350);
                GivePlayerWeapon(i,26,350); 
                GivePlayerWeapon(i,27,350); 
            }
        return 1;
    }
    return 0;
}
That shouldn't give ALL the players weapons? Right? I want it to be ALL players get weapons...


Re: Give all players - iggy1 - 13.09.2010

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp("/startevent", cmdtext, true))
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                PlayerPlaySound(i,1057,0.0,0.0,0.0);
                GivePlayerWeapon(i,31,350);
                GivePlayerWeapon(i,24,350);
                GivePlayerWeapon(i,26,350);
                GivePlayerWeapon(i,27,350);
            }
        }
        return 1;
    }
    return 0;
}
I think "return 1" was in the wrong place ending the loop prematurely.