Raised This Month: $51 Target: $400
 12% 

Solved [HELP] Remember weapons


Post New Thread Reply   
 
Thread Tools Display Modes
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-18-2018 , 13:47   Re: [HELP] Remember weapons
Reply With Quote #11

maybe in Ham_Killed pre, everything else is called after the user is already dead.
__________________
stuff

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

Quote:
Originally Posted by CrAzY MaN View Post
Okay, will mixup that.
But isn't there a way of doing this with DeathMsg or client_death?
Yes maybe DeathMsg since client_death is only used to count stats in csx module.
__________________
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:54   Re: [HELP] Remember weapons
Reply With Quote #13

I would go with Ham_Killed registered as pre. Btw, hamsandwich is a very useful module, trying to avoid it is like shooting yourself in the foot and trying to walk.
__________________

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

Code:
#include <amxmodx> #include <cstrike> #include <fun> #include <hamsandwich> #include <fakemeta> #include <engine> #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; new iWeapons public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         RegisterHam(Ham_Killed, "player", "Ham_Killed_Pre", 0)     //RegisterHam(Ham_Killed, "player", "Ham_Killed_Post", 1) } public Ham_Killed_Pre(id) {     g_weaponname = ArrayCreate(32);     get_weapons(id) } //public Ham_Killed_Post(id) // or 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.") } public get_weapons(id) {     new weapons[32], 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) {     strip_user_weapons(id)     new weapon_name[32];         for(new i=0; i < iWeapons; i++ )     {         ArrayGetString(g_weaponname, i, weapon_name, charsmax(weapon_name))                 give_item(id, weapon_name)         //ExecuteHam(Ham_AddPlayerItem, weapon_name[i], id)                 client_print( id, print_chat, "New Weapons : %s", weapon_name )     }    } //----------------------------------------------------------------// /*-------------------------RESPAWN PLAYER-------------------------*/ //----------------------------------------------------------------// public respawn_player(id) {     if (!is_user_alive(id) && (CS_TEAM_T <= cs_get_user_team(id) <= CS_TEAM_CT))     {         ExecuteHamB(Ham_CS_RoundRespawn, id)     }         give_weapons(id)                     ArrayClear(g_weaponname); }

What am i doing wrong here?
__________________
CrAzY MaN is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-19-2018 , 16:33   Re: [HELP] Remember weapons
Reply With Quote #15

Nvm i was on the phone. What part is not working ?
__________________
stuff

Last edited by maqi; 06-19-2018 at 16:40.
maqi is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 06-19-2018 , 16:50   Re: [HELP] Remember weapons
Reply With Quote #16

Why do you use client_death and Ham_Killed together? Go with Ham_Killed and respawn player?
And what kind of code is it ? Why do you use this?

Code:
(CS_TEAM_T <= cs_get_user_team(id) <= CS_TEAM_CT)

Last edited by PurposeLessx; 06-19-2018 at 16:53.
PurposeLessx is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-19-2018 , 16:53   Re: [HELP] Remember weapons
Reply With Quote #17

What?
__________________
stuff
maqi is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-19-2018 , 17:26   Re: [HELP] Remember weapons
Reply With Quote #18

Quote:
Make sure that num has an initial value of 0 or the native will not
work correctly.
__________________
stuff
maqi is offline
shauli
Member
Join Date: Jun 2018
Old 06-19-2018 , 17:58   Re: [HELP] Remember weapons
Reply With Quote #19

Quote:
Originally Posted by CrAzY MaN View Post
What am i doing wrong here?
You've created g_weaponname in Ham_Killed_Pre but never destroyed it, so you're basically recreating it over and over again.

Actually I don't see the point in using dyanmic arrays here, just use a regular one. Also it's better to just save the weapon index and use get_weaponname in respawn_player() instead of saving the strings.

BTW, is the current code working? If not, try to tell us when or where you think there's a problem, and show us the results from the client_print().
shauli is offline
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 06-20-2018 , 00:00   Re: [HELP] Remember weapons
Reply With Quote #20

Ham_Killed as post works same as client_death.
So there's no difference.

I'm clearing the array(IDK maybe you haven't seen) by "ArrayClear(g_weaponname).
Should I use ArrayDestroy?

Actually, it works perfectly.
Getting perfect "wepon names" on client print.

It just shows error of "ArrayGetString".
Will attach full error soon.
__________________

Last edited by CrAzY MaN; 06-20-2018 at 00:03.
CrAzY MaN is offline
Reply



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 13:36.


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