Raised This Month: $ Target: $400
 0% 

Get user weapons on death


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 07-30-2014 , 15:13   Re: Get user weapons on death
Reply With Quote #4

Well, that works, but only sometimes...
I mean, it seems like it's not the best way to do the job, since sometimes it doesn't give anything, sometimes it gives only primaries, etc.
Here is my code for now, with the mentioned bugs:
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <cstrike>
#include <fun>

const PH PLUGIN_HANDLED
const PC PLUGIN_CONTINUE

const TimeToRespawnAfterChoose 5

new player_lives[33]
new 
player_weapons[33][32]
new 
player_bpammo[33][32]
new 
g_flDeadOrigin[33][3]
new 
g_iMaxPlayers

public plugin_init() {
    
RegisterHam(Ham_Killed"player""onPlayerKilled")
    
    
g_iMaxPlayers get_maxplayers()
}

public 
onPlayerKilled(victimkillershouldgib)
{
    
    
pev(victimpev_origing_flDeadOrigin[victim])
    
set_task(1.0"taskAskForRespawn"victim)
    
    new 
num
    get_user_weapons
(killerplayer_weapons[killer], num)
        
    for(new 
inumi++)
        
cs_get_user_bpammo(killerplayer_bpammo[killer][player_weapons[killer][i]])    
}

public 
taskAskForRespawn(id)
{
    if(
is_user_alive(id))
        return 
PH
    
    
new szTitle[64]
    
formatex(szTitlecharsmax(szTitle), "You have\r %i\y extra lives^nDo you want to use one?"player_lives[id])
    
    new 
menu menu_create(szTitle"handleRespawnMenu")
    
    
menu_additem(menu"Yes"""0)
    
menu_additem(menu"No"""0)
    
    
menu_display(idmenu0)
    
    return 
PC
}

public 
handleRespawnMenu(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PH
    
}
    
    if(
is_user_alive(id))
    {
        
client_print(idprint_chat"You are already alive!")
        return 
PH
    
}
    
    switch(
item)
    {
        case 
0:
        {
            
client_print(idprint_chat"You will be respawned in %d seconds!"TimeToRespawnAfterChoose)
            
set_task(float(TimeToRespawnAfterChoose), "respawnPlayer"id)
        }
        default: return 
PH
    
}    
    
    return 
PH
}

public 
respawnPlayer(id)
{
    if(
is_user_alive(id))
        return 
PH
    
    ExecuteHamB
(Ham_CS_RoundRespawnid)
    
    
set_pev(idpev_origing_flDeadOrigin[id])
    
    new 
szWeaponName[32]
    for(new 
1<= g_iMaxPlayersi++)
    {
        if(
is_user_connected(id) && player_weapons[id][i])
        {
            
get_weaponname(player_weapons[id][i], szWeaponNamecharsmax(szWeaponName))
            
            
strip_user_weapons(id)
            
give_item(id"weapon_knife")
            
            
give_item(idszWeaponName)
            
cs_set_user_bpammo(idplayer_weapons[id][i], player_bpammo[id][i])
        }
    }
    
    return 
PC

I guess this is not the right way to set the BPAmmo, too, but it's the same with or without it. I'm currently waiting for better and improved suggestions.
Thanks!
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
 



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