Get user weapons on death
Hey, guys! I'm currently trying to save somehow player's weapons when he dies. The purpose is to respawn him with the same weapons as he died (if it's even possible). So, what I tried:
- Hooking CurWeapon and looping trough get_user_weapons. - Geting user weapons on death (probably didn't work because he is already dead...) The problem is that I don't know how to save those weapon indexes and later give them on spawn. Any help is appereciated. P.S.: Took a look here, some of the information may be useful: https://forums.alliedmods.net/showthread.php?t=182970 |
Re: Get user weapons on death
You'd do something like:
PHP Code:
|
Re: Get user weapons on death
Well, that works, but only sometimes... :D
I mean, it seems like it's not the best way to do the job, since sometimes it doesn't give anything, sometimes it gives only primaries, etc. Here is my code for now, with the mentioned bugs: PHP Code:
Thanks! |
Re: Get user weapons on death
Just edited a few things :bee:
PHP Code:
|
Re: Get user weapons on death
The result is the same... Sometimes gives nothing, sometimes gives only primary, even once I was freezed?! No errors in the log for now. Well, I gues I will search for an alternative.
The question is currently staying. Thanks! |
Re: Get user weapons on death
Did you debug the array holding the weapon ids in the kill-event and in the respawn function?
Your for loop is wrong ( for(new i = 1; i <= g_iMaxPlayers; i++) ), have another look at my example. Stripping the players weapon is enough, you dont need to give him a knife, as tat would give him the knife twice (because it's already included in the weapons-array), then, you are not destroying the menus in the handler sometimes. Edit: Btw, you are saving the killers weapons and not the victims... Edit2: Both of you guys do the bpammo thing wrong; take this as a base and add your origin stuff: PHP Code:
Edit3: Added the origin stuff and testet, should work o.k. |
Re: Get user weapons on death
Lol, mottzi, thanks for the note. Really dumb - getting killer's weapons. Now it's all okay, thank you all guys!
|
Re: Get user weapons on death
hook curWeapon event, and save the weapons into global var.
after, use csx to hook the death and check the global var... :) |
Re: Get user weapons on death
I think it's not needed to hook that event, since I can get the weapons once on user's death and store them into the variable. The great example by mottzi is working (made little changes for the code). I think the case is closed! Thanks to all!
|
Re: Get user weapons on death
Quote:
|
| All times are GMT -4. The time now is 13:02. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.