Raised This Month: $32 Target: $400
 8% 

Solved [HELP] Remember weapons


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 06-09-2018 , 03:54   [HELP] Remember weapons
Reply With Quote #1

How do i set weapons of killer and victim to previous weapons when they were respawned?

eg.
  • Current Weapon = ak47, glock18, knife
  • Died
  • On Respawn, change weapon to ak47, glock18, knife
__________________

Last edited by CrAzY MaN; 06-20-2018 at 10:05.
CrAzY MaN is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-09-2018 , 04:14   Re: [HELP] Remember weapons
Reply With Quote #2

Save the weapons list in an array when they die and give it back to them on spawn.
__________________
HamletEagle is offline
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 06-09-2018 , 06:30   Re: [HELP] Remember weapons
Reply With Quote #3

Can you show me example?
__________________
CrAzY MaN is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-09-2018 , 06:53   Re: [HELP] Remember weapons
Reply With Quote #4

https://forums.alliedmods.net/showthread.php?t=308093
Here is your example. Just make the array globals and index them by player index.
__________________
HamletEagle is offline
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 06-18-2018 , 06:36   Re: [HELP] Remember weapons
Reply With Quote #5

Okay, so i tried making this.
It works fine, but gives some log errors.
Any fix?

Code:
Code:
#include <amxmodx> #include <cstrike> #include <fun> #include <fakemeta> #if AMXX_VERSION_NUM < 183     #include <dhudmessage> #endif   #define PLUGIN "Test:Remember Weapons on Respawn" #define VERSION "1.0" #define AUTHOR "CrAzY MaN"   new Array:g_weaponname;   public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR) }   public client_death(killer, victim) {     set_task(3.0, "respawn_player", victim)             set_dhudmessage(0, 255, 0, -1.0, 0.77, 0, 6.0, 12.0)     show_dhudmessage(victim, "You will respawn in 3 seconds.")         g_weaponname = ArrayCreate(32);         get_weapons(victim)         ArrayClear(g_weaponname) }   public get_weapons(id) {     new weapons[32], iWeapons, weapon_name[32];     get_user_weapons(id, weapons, iWeapons)       for (new i=0; i<=iWeapons; i++)     {              get_weaponname(weapons[i], weapon_name, charsmax(weapon_name))             ArrayPushString(g_weaponname, weapon_name)                 client_print(id, print_chat, "Old Weapons : %s", weapon_name)     } }   public give_weapons(id) {     new weapon_name[32];     strip_user_weapons(id)     for(new i=0; i < ArraySize(g_weaponname); i++ )     {         ArrayGetString(g_weaponname, i, weapon_name, charsmax(weapon_name))             give_item(id, weapon_name)                 client_print( id, print_chat, "New Weapons : %s", weapon_name )     } }   //----------------------------------------------------------------// /*-------------------------RESPAWN PLAYER-------------------------*/ //----------------------------------------------------------------//   public respawn_player(id) {     if (!is_user_connected(id) || is_user_alive(id) || cs_get_user_team(id) == CS_TEAM_SPECTATOR)         return;         set_pev(id, pev_deadflag, DEAD_RESPAWNABLE)     dllfunc(DLLFunc_Think, id)         if (is_user_bot(id) && pev(id, pev_deadflag) == DEAD_RESPAWNABLE)     {         dllfunc(DLLFunc_Spawn, id)     }         give_weapons(id) }

Error :
PHP Code:
L 06/18/2018 15:51:25Invalid weapon id 0
L 06
/18/2018 15:51:25: [AMXXDisplaying debug trace (plugin "Untitled.amxx"version "1.0")
L 06/18/2018 15:51:25: [AMXXRun time error 10native error (native "get_weaponname")
L 06/18/2018 15:51:25: [AMXX]    [0Untitled.sma::get_weapons (line 42)
L 06/18/2018 15:51:25: [AMXX]    [1Untitled.sma::client_death (line 29
__________________

Last edited by CrAzY MaN; 06-18-2018 at 06:37.
CrAzY MaN is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 06-18-2018 , 12:11   Re: [HELP] Remember weapons
Reply With Quote #6

You need to pick weapons to array at Ham_AddPlayerItem i guess, is better than store on death.
Also if possible spawn a player using Ham_CS_RoundRespawn
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 06-18-2018 , 12:58   Re: [HELP] Remember weapons
Reply With Quote #7

I used Fakemeta everywhere in my plugin, don't wanna add another include for just this thing.
What am i doing wrong here?
__________________
CrAzY MaN is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 06-18-2018 , 13:19   Re: [HELP] Remember weapons
Reply With Quote #8

Quote:
Originally Posted by CrAzY MaN View Post
I used Fakemeta everywhere in my plugin, don't wanna add another include for just this thing.
What am i doing wrong here?
so forgot it, client_death is called after player dead soo get_user_weapons will not work
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-18-2018 , 13:21   Re: [HELP] Remember weapons
Reply With Quote #9

Quote:
Originally Posted by CrAzY MaN View Post
I used Fakemeta everywhere in my plugin, don't wanna add another include for just this thing.
What am i doing wrong here?
Not this bullshit again, not again..
Add as many includes as you need. By trying to use only one module you are doing way more harm than good.
__________________

Last edited by HamletEagle; 06-18-2018 at 13:23.
HamletEagle is offline
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 06-18-2018 , 13:36   Re: [HELP] Remember weapons
Reply With Quote #10

Okay, will mixup that.
But isn't there a way of doing this with DeathMsg or client_death?
__________________

Last edited by CrAzY MaN; 06-18-2018 at 13:38.
CrAzY MaN is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:13.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode