Raised This Month: $ Target: $400
 0% 

Get user weapons on death


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 07-30-2014 , 16:53   Re: Get user weapons on death
Reply With Quote #1

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:
#include <amxmodx> 
#include <amxmisc> 
#include <hamsandwich> 
#include <fun> 
#include <cstrike> 

new iWeapons[33][32
new 
iWeaponBackPack[33][32]
new 
iDeadOrigin[33][3]

public 
plugin_init()  

    
RegisterHam(Ham_Killed"player""eventPlayerKilled"false


public 
eventPlayerKilled(id

    new 
iNum 
    get_user_weapons
(idiWeapons[id], iNum
    
    for(new 
0iNumi++)
    {
        if(
iWeapons[id][i]) 
        {
            if(
iWeapons[id][i] != CSW_KNIFE)
            {
                
iWeaponBackPack[id][i] = cs_get_user_bpammo(idiWeapons[id][i])  
            }
        }
        else
        {
            break
        }
    }
    
    
get_user_origin(idiDeadOrigin[id])
    
    new 
menu menu_create("Respawn ?""menuRespawnHandler")
    
    
menu_additem(menu"Yes")
    
menu_additem(menu"No")
    
    
menu_display(idmenu)


public 
menuRespawnHandler(idmenuitem

    if(!
is_user_connected(id) || is_user_alive(id))
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED    
    
}
    
    if(
item == 0)
    {
        
ExecuteHamB(Ham_CS_RoundRespawnid
        
set_user_origin(idiDeadOrigin[id])
        
        new 
szWeaponName[45
        
        for(new 
032i++) 
        { 
            if(
iWeapons[id][i]) 
            { 
                if(
iWeapons[id][i] == CSW_KNIFE)
                {
                    
give_item(id"weapon_knife"
                }
                else
                {
                    
get_weaponname(iWeapons[id][i], szWeaponNamecharsmax(szWeaponName)) 
                    
                    
give_item(idszWeaponName
                    
cs_set_user_bpammo(idiWeapons[id][i], iWeaponBackPack[id][i]) 
                }
            } 
            else
            {
                break
            }
        } 
    }
    
    
arrayset(iWeapons[id], 032
    
arrayset(iWeaponBackPack[id], 032
    
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED

Note: You could avoid useless loop cycles using break when iWeapons[id][i] == 0...

Edit3: Added the origin stuff and testet, should work o.k.

Last edited by mottzi; 07-30-2014 at 17:43.
mottzi is offline
Send a message via MSN to mottzi
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:02.


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