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-20-2018 , 01:20   Re: [HELP] Remember weapons
Reply With Quote #21

You can't store weapons info in global variables like that, if a another player dies before the first one respawned, everything is messed up, both would get the number of weapons of the second one but actually weapons of the first one ( while there is enough ).
Also that quote i sent earlier get_user_weapons expects the num variable to be set to 0 beforehand to work properly.

This is how I would do it, it works of course.

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fun>

#pragma semicolon 1

#define MAX_PLAYERS 32

enum WeaponsData
{
    
WEAPONS[32],
    
NUM
}

new 
g_eWeaponsMAX_PLAYERS ][WeaponsData];

public 
plugin_init( ) 
{
    
register_plugin"Save Weapons On Death""1.0a""maqi" );
    
    
RegisterHamHam_Killed"player""Event_HamKilledPre");
    
RegisterHamHam_Spawn"player""Event_PlayerSpawnPost");
}

public 
client_connectiIndex )
    
g_eWeapons[iIndex][NUM] = 0;

public 
Event_HamKilledPreiIndex )
{
    new 
iWeapons[32];
    
    
get_user_weaponsiIndexiWeaponsg_eWeapons[iIndex][NUM] );
    
    
g_eWeapons[iIndex][WEAPONS] = iWeapons;
    
    return 
HAM_IGNORED;
}

public 
Event_PlayerSpawnPostiIndex )
{
    new 
sWeapon[32];
    
    for( new 
0g_eWeapons[iIndex][NUM]; i++ )
    {
        
get_weaponnameg_eWeapons[iIndex][WEAPONS][i], sWeaponcharsmax(sWeapon) );
        
give_itemiIndexsWeapon );
    }
    
    
g_eWeapons[iIndex][NUM] = 0;

    return 
HAM_IGNORED;

__________________
stuff

Last edited by maqi; 06-20-2018 at 01:48.
maqi is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-20-2018 , 02:11   Re: [HELP] Remember weapons
Reply With Quote #22

You can simply store weapons in a bitsum variable, you dont need a dynamical array.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 06-20-2018 at 02:11.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-20-2018 , 02:37   Re: [HELP] Remember weapons
Reply With Quote #23

Why ?
__________________
stuff
maqi is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-20-2018 , 05:19   Re: [HELP] Remember weapons
Reply With Quote #24

Quote:
Originally Posted by maqi View Post
Why ?
Much better and efficient.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-20-2018 , 05:24   Re: [HELP] Remember weapons
Reply With Quote #25

Quote:
Originally Posted by Natsheh View Post
Much better and efficient.
I would not say it's "much better and efficient".Yes, it is more efficient but adds unneded complexity. Using a normal array should be enough. In most cases you will not notice the difference between bitsum and an array.
__________________
HamletEagle is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-20-2018 , 05:32   Re: [HELP] Remember weapons
Reply With Quote #26

Do you use bitsum instead of get_players ? Because its the exact same thing
__________________
stuff
maqi is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-20-2018 , 06:12   Re: [HELP] Remember weapons
Reply With Quote #27

Quote:
Originally Posted by maqi View Post
Do you use bitsum instead of get_players ? Because its the exact same thing
Nope its not the same, player id is required to execute functions upon him.

Anywho using the bitsum is more simple.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 06-20-2018 at 06:14.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-20-2018 , 06:14   Re: [HELP] Remember weapons
Reply With Quote #28

So is weapon id Its pretty much the same thing and get_user_weapons is a lot like get_players, just saying.
__________________
stuff
maqi is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-20-2018 , 06:19   Re: [HELP] Remember weapons
Reply With Quote #29

Quote:
Originally Posted by maqi View Post
So is weapon id Its pretty much the same thing and get_user_weapons is a lot like get_players, just saying.
I'm not sure whats the reference you are trying to get. The only thing is common between weapons id and players id that the ids starts from 1 and ends at 32.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 06-20-2018 at 06:19.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-20-2018 , 06:35   Re: [HELP] Remember weapons
Reply With Quote #30

Im just saying that both weapon id and player id are nothing but integers from 1 to 32 and theres no reason to keep them as a bitsum especially when there are nice functions like get_players and get_user_weapons.
__________________
stuff
maqi 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 10:38.


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