Give all players
#1

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

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.
            }
        }
Reply
#3

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

Thanks so much guys! Will use Calgon's though
Reply
#5

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)