Posts
2,790
Respect
351Add +1
Forum Rank
King of the Zombies
Primary Group
Community Daedra
Login Issues
Forgot password?Activate Issues
Account activation email not received? Wrong account activation email used?Other Problems?
Contact Support - Help Center Get help on the UGX Discord. Join it now!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
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.
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.
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. |