UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

custom_loadout

broken avatar :(
Created 11 years ago
by daedra descent
0 Members and 1 Guest are viewing this topic.
2,317 views
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
Signature
Let's keep this thread on topic from here on in. -DBZ

+1 to off-topic reply -DBZ

lmao. Too funny.

Goliath Script Placer: http://ugx-mods.com/forum/index.php/topic,11234.msg125257/topicseen.html#new

"...Christ, people. Learn C, instead of just stringing random characters
together until it compiles (with warnings)..."

-Linus Torvalds
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
I've been trying to get this to work forever, but nothing happens in-game. I've tried using client dvars add_weapon("name") and nothing works. I was wondering if anyone can shine a little bit of light as to why it isn't working.

Code Snippet
Plaintext
#include maps\_utility; 
#include common_scripts\utility;
#include maps\_zombiemode_utility;
#include maps\_zombiemode;
#include maps\_zombiemode_weapons;
#include maps\_loadout;


custom_loadout()
{
players = getplayers();

if(players == "0" )
{
add_Weapon("zombie_colt");
self setclientdvar("give dp28");
}
else if(players == "1" )
{
add_Weapon("tokarev");
}
else if(players == "2" )
{
add_Weapon("nambu");
}
else if(players == "3" )
{
add_Weapon("walther");
}
else if(players == "" )
{
}
}
broken avatar :(
×
broken avatar :(
[UGX] Founder
Location: usBay Area, California
Date Registered: 24 June 2011
Last active: 8 months ago
Posts
5,551
Respect
6,691Add +1
Forum Rank
Immortal
Primary Group
UGX Administrator
My Groups
More
My Contact & Social Links
More
Signature
If Java had true garbage collection, most programs would delete themselves upon execution.
×
treminaor's Groups
UGX Administrator
UGX Team Member
UGX Site Moderator Has the ability to issue warnings to users, edit and remove posts from the forum and to move topics to other boards. Upholds the rules of the forum. Moderates Chat Rooms.
The "give" console input is not a dvar, its a command. You can't execute commands from GSC or CSC - only the console and menu files can.

To give a player a weapon, use

Code Snippet
Plaintext
player maps\_zombiemode_weapons::weapon_give(<weapon>)

You could of course write giveWeapon(weapon) blah blah yourself but this function already checks inventory size and checks for many other possible mistakes.

Your code also does not make sense - you get the players with getPlayers() but then call everything on self - self is the level unless you called the function on something. And there's no need to include all of those files, it does nothing for your script. You aren't using any of the functions in those files except for add_weapon, and you aren't using that correctly. getPlayers() is a utility function, but it could easily be replaced with the engine function get_players() - it's just a shorthand for the real thing.

Code Snippet
Plaintext
#include maps\_utility; 
#include common_scripts\utility;
#include maps\_zombiemode_utility;

custom_loadout()
{
    players = getplayers();
weapon = "";
for(i=0;i<players.size;i++)
{
players[i] TakeWeapon(players[i] getCurrentWeapon()); //take their original loadout weapon. Remove this line if you don't need it.
if(i == 0) weapon = "dp28";
else if(i == 1) weapon = "tokarev";
ekse if(i == 2) weapon = "nambu";
else weapon = "walther";
players[i] maps\zombiemode_weapons::weapon_give(weapon);
    }
}
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
The "give" console input is not a dvar, its a command. You can't execute commands from GSC or CSC - only the console and menu files can.

To give a player a weapon, use

Code Snippet
Plaintext
player maps\_zombiemode_weapons::weapon_give(<weapon>)

You could of course write giveWeapon(weapon) blah blah yourself but this function already checks inventory size and checks for many other possible mistakes.

Your code also does not make sense - you get the players with getPlayers() but then call everything on self - self is the level unless you called the function on something. And there's no need to include all of those files, it does nothing for your script. You aren't using any of the functions in those files except for add_weapon, and you aren't using that correctly. getPlayers() is a utility function, but it could easily be replaced with the engine function get_players() - it's just a shorthand for the real thing.

I didn't think it was that messed up as I used both the UGX wiki tutorial and from _zombiemode scripts. I never originally had self add_weapon or the client dvar, I pretty much took what you posted and  made it a bit larger to make it easier to add things too like switch_too("weapon_name").

Code Snippet
Plaintext
players = getPlayers();
players[0] giveWeapon("weapon1");
players[1] giveWeapon("weapon2");
players[2] giveWeapon)"weapon3");
players[3] giveWeapon("weapon4");
blah blah
Last Edit: October 10, 2013, 03:17:57 am by daedra descent
broken avatar :(
×
broken avatar :(
[UGX] Founder
Location: usBay Area, California
Date Registered: 24 June 2011
Last active: 8 months ago
Posts
5,551
Respect
6,691Add +1
Forum Rank
Immortal
Primary Group
UGX Administrator
My Groups
More
My Contact & Social Links
More
×
treminaor's Groups
UGX Administrator
UGX Team Member
UGX Site Moderator Has the ability to issue warnings to users, edit and remove posts from the forum and to move topics to other boards. Upholds the rules of the forum. Moderates Chat Rooms.
The code you're quoting from me would work fine too, but that's not what you used in your example. Notice I was calling giveWeapon on each index of the player array - you were calling your stuff on self, and not using the giveWeapon function.

Again in the example I just gave you, I was calling on a player index - but this example is more advanced as it uses a for() loop to traverse through the player array and checks the player index each time. If the player index matches the index you wanted for each of those weapons, it picks the right one accordingly and gives it using the weapon_give function I described above.

weapon_give() ultimately is just the same as giveWeapon(), but if you read its contents in _zombiemode_weapons you will see that it has inventory size checks and other stuff which is very useful. giveWeapon() is an engine function which executes the command you were trying to use.
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
The code you're quoting from me would work fine too, but that's not what you used in your example. Notice I was calling giveWeapon on each index of the player array - you were calling your stuff on self, and not using the giveWeapon function.

Again in the example I just gave you, I was calling on a player index - but this example is more advanced as it uses a for() loop to traverse through the player array and checks the player index each time. If the player index matches the index you wanted for each of those weapons, it picks the right one accordingly and gives it using the weapon_give function I described above.

weapon_give() ultimately is just the same as giveWeapon(), but if you read its contents in _zombiemode_weapons you will see that it has inventory size checks and other stuff which is very useful. giveWeapon() is an engine function which executes the command you were trying to use.

I should probably ask, if for whatever reason that I wanted to add a second weapon alongside the pistols, would I just need to add something along the lines of

Code Snippet
Plaintext
 if(i == 0) weapon = "zombie_colt"; // same player
if(i == 0) weapon = "zombie_m1garand"; // same player

also, how would I go about determining which weapon is switched first (the first weapon they see first.), I tried doing
Code Snippet
Plaintext
set_switch_weapon( weapon );
, but it results in me getting full ammo for the pistols
Last Edit: October 10, 2013, 03:49:35 am by daedra descent
broken avatar :(
×
broken avatar :(
[UGX] Founder
Location: usBay Area, California
Date Registered: 24 June 2011
Last active: 8 months ago
Posts
5,551
Respect
6,691Add +1
Forum Rank
Immortal
Primary Group
UGX Administrator
My Groups
More
My Contact & Social Links
More
×
treminaor's Groups
UGX Administrator
UGX Team Member
UGX Site Moderator Has the ability to issue warnings to users, edit and remove posts from the forum and to move topics to other boards. Upholds the rules of the forum. Moderates Chat Rooms.
Code Snippet
Plaintext
#include maps\_utility; 
#include common_scripts\utility;
#include maps\_zombiemode_utility;

custom_loadout()
{
    players = getplayers();
    for(i=0;i<players.size;i++)
    {
        if(i == 0)
{
primary = "dp28";
sidearm = "m1911";
}
        else if(i == 1)
{
primary = "ppsh";
sidearm = "tokarev";
}
        else if(i == 2)
{
primary = "type100_smg";
sidearm = "nambu";
}
        else
{
primary = "mp40";
sidearm = "walther";
}

        players[i] TakeWeapon(players[i] getWeaponsListPrimaries()[0]);
        players[i] TakeWeapon(players[i] getWeaponsListPrimaries()[1]);
players[i] giveWeapon(primary);
players[i] giveWeapon(sidearm);
    }
}

 
Loading ...