View Full Version : Keeping weapons between rounds
Haigotron
06-04-2007, 01:15 PM
Hello,
I have integrated a round system in my multiplayer team mod. I've basically changed the hl2mp_gamerules to reset and cleanup the map and respawn the players until the maxround is reached, then it'll end the map.
It works fine and everything resets. I wanted to know how to program a way to preserve the weapons a player was carrying (similar to CS) w/o regiving the default equipment.
Thanks in advance! :D
StuD-tos
06-04-2007, 01:29 PM
you could do an if statement to check if a weapon is already in that slot.
Marine
06-04-2007, 01:34 PM
Store the weapons the player has in a networked var (In the player class / in yours), then when they die, in the Spawn function, where it gives the default items, check what they have stored in the variables and then give them the correct weapons. This is how i'm doing my class system (Where there are numerious weapons).
Haigotron
06-04-2007, 02:41 PM
thanks for the replies,
I assume either way would require modifying the hl2mp_player class, when the game is equipping the player.
Also, is there a built in method that checks slots?
Store the weapons the player has in a networked var (In the player class / in yours)
Only store this information in a networked var if you really need it to be accessed on the client side (say, if for some reason it's important for equipment selection), otherwise it's easier (and more efficient) to just keep it all on the server.
Marine
06-05-2007, 07:13 AM
Only store this information in a networked var if you really need it to be accessed on the client side (say, if for some reason it's important for equipment selection), otherwise it's easier (and more efficient) to just keep it all on the server.
Thats very true, but i didn't realise what i needed it for (Might need it on client side), so i did it that way :)
Haigotron
06-05-2007, 04:44 PM
thanks again for the replies, its slowly making sense for me (im a slow newb programmer), but indeed I think its only required server side, similar to CS, it only needs to remember who got what weapon, and then resupply them.
I am wondering if there is a function that already exists that checks to see if a player is carrying a certain weapon?
Wildfire788
06-05-2007, 08:56 PM
May I suggest adding a new variable to determine whether or not the player died at the end of the last round?
Then put an if statement in the spawn function. If player died, then GiveDefaultItems. Else, let him keep the ones he already has.
Not exactly sure if that's possible though, I'm a new programmer as well.
Wildfire788
06-06-2007, 10:40 AM
Someone suggested to me elsewhere using SetAbsOrigin on the living players to the same coordinates as a spawn entity, and then just having a spawn function called for the dead players. I assume you'd have to heal the players and regenerate stamina/other stats depending on your mod as well.
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.