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

Solved [HELP] Remember weapons


Post New Thread Reply   
 
Thread Tools Display Modes
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-20-2018 , 07:04   Re: [HELP] Remember weapons
Reply With Quote #31

Quote:
Originally Posted by maqi View Post
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.
Well we are talking about saving the old weapons which seems the best method saving them as bitsum value
__________________
@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
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 06-20-2018 , 07:10   Re: [HELP] Remember weapons
Reply With Quote #32

Quote:
Originally Posted by Natsheh View Post
Well we are talking about saving the old weapons which seems the best method saving them as bitsum value
Any example?
I didn't played much with bitsums.
__________________
CrAzY MaN is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-20-2018 , 07:23   Re: [HELP] Remember weapons
Reply With Quote #33

Theres no reason to argue about that anymore Everyone has their own opinion and i respect yours
__________________
stuff
maqi is offline
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 06-20-2018 , 10:03   Re: [HELP] Remember weapons
Reply With Quote #34

Quote:
Originally Posted by maqi View Post
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;

Thankie @maqi for the help in finding what i did wrong!
It works like a charm.

Thanks to all others who replied to this thread!
__________________

Last edited by CrAzY MaN; 06-20-2018 at 10:04.
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 03:30.


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