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.
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.
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").
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.
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
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.