Nebulah

Veteran
Messages
13
Reaction score
1
Points
558
Does anyone know how to give the player a random weapon?

also how do you pull the score from the game? I want to make it so when the score goes up 1 the player teleports to a different spot
 

Deltabot

New Member
Messages
13
Reaction score
19
Points
3
thats not how to do weapons.
Code:
weap = "smg_standard";
self giveWeapon(getWeapon(weap));
self switchtoweapon(getWeapon(weap));
 

CabCon

Head Administrator
Staff member
Head Staff Team
Messages
4,696
Reaction score
2,807
Points
1,053
Does anyone know how to give the player a random weapon?

also how do you pull the score from the game? I want to make it so when the score goes up 1 the player teleports to a different spot
Are you looking for a MP or ZM function? :smile:
 

JayCoder

Veteran
Staff member
Messages
350
Reaction score
149
Points
678
i think this should help

PHP:
function giveCustomLoadout()
{
    self TakeAllWeapons();
    self clearPerks();
 
    self SetPerk( "specialty_fallheight" );

    self GiveWeapon( level.weaponBaseMeleeHeld );
    self setSpawnWeapon( level.weaponBaseMeleeHeld );
 
    return level.weaponBaseMeleeHeld;
}

found in fr.gsc
 

Nebulah

Veteran
Messages
13
Reaction score
1
Points
558
s
i think this should help

PHP:
function giveCustomLoadout()
{
    self TakeAllWeapons();
    self clearPerks();
 
    self SetPerk( "specialty_fallheight" );

    self GiveWeapon( level.weaponBaseMeleeHeld );
    self setSpawnWeapon( level.weaponBaseMeleeHeld );
 
    return level.weaponBaseMeleeHeld;
}

found in fr.gsc
so how would i choose the weapon to put in there and is it possible to choose camo
 

JayCoder

Veteran
Staff member
Messages
350
Reaction score
149
Points
678
s

so how would i choose the weapon to put in there and is it possible to choose camo

do


PHP:
function giveCustomLoadout()
{
    self TakeAllWeapons();
    self clearPerks();
 
    self SetPerk( "specialty_fallheight" );
  
    level.weaponname = "weaponname here";//example: smg_standard

    self GiveWeapon( level.weaponname );
    self setSpawnWeapon( level.weaponname );
 
    return level.weaponname;
}
 

Encryption

Co-Leader of SM|T
Messages
27
Reaction score
12
Points
3
do


PHP:
function giveCustomLoadout()
{
    self TakeAllWeapons();
    self clearPerks();
 
    self SetPerk( "specialty_fallheight" );
 
    level.weaponname = "weaponname here";//example: smg_standard

    self GiveWeapon( level.weaponname );
    self setSpawnWeapon( level.weaponname );
 
    return level.weaponname;
}
I already answered his question also you don't need to set a perk...
 

Nebulah

Veteran
Messages
13
Reaction score
1
Points
558
do


PHP:
function giveCustomLoadout()
{
    self TakeAllWeapons();
    self clearPerks();
 
    self SetPerk( "specialty_fallheight" );
 
    level.weaponname = "weaponname here";//example: smg_standard

    self GiveWeapon( level.weaponname );
    self setSpawnWeapon( level.weaponname );
 
    return level.weaponname;
}

it doesn't work. I put the weapon name as "sniper_double+fmj+extclip" and it gives me no weapon.
 

CabCon

Head Administrator
Staff member
Head Staff Team
Messages
4,696
Reaction score
2,807
Points
1,053
Here we go guys!
@Encryption @JayCoder @Nebulah

I hope that Is what you searched:

Put this into the #using list:
Code:
#using scripts\shared\weapons_shared;
#using scripts\shared\array_shared;

Add this function somewhere:
Code:
function func_giveRandomWeapon()
{
    weaponsList_array = strTok("pistol_standard pistol_burst pistol_fullauto shotgun_semiauto ar_standard sniper_fastbolt sniper_powerbolt ar_marksman lmg_heavy "," "); // fill this with random weapons from the game, I tried to search a array whichs stores all weapons from the game but I didn't find one!
    for(;;)
    {
        weaponPick = array::random(weaponsList_array);
        weaponPick = getWeapon(weaponPick);
        if( self hasWeapon( weaponPick ) )
            continue;
        else if ( weapons::is_primary_weapon( weaponPick ) )
            break;
        else if ( weapons::is_side_arm( weaponPick ) )
            break;
        else
            continue;
    }
    self iprintln(weaponPick.displayName);
    self iprintln(weaponPick.name);
    self TakeWeapon(self GetCurrentWeapon());
    self giveWeapon(weaponPick);
    self GiveMaxAmmo(weaponPick);
    self SwitchToWeapon(weaponPick);
}

You can call now ::func_giveRandomWeapon and you will get one weapon of the weaponsList_array array! :smile: It is tested and it is working! :smile:

Regards,
CabCon.
 
Top