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

give pistols if dead


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Cader
Senior Member
Join Date: Mar 2007
Old 03-06-2011 , 16:01   give pistols if dead
Reply With Quote #1

hi.

I have a surf server. I want to give pistols to players on spawn, if they don't have a primary/secondary weapon carried from previous round. or in other words, players only have died are going to get pistols (usp or glock)

here's what I have from my code snippet;

RegisterHam(Ham_Spawn, "player", "giveweap", 1)


public giveweap(id) {

if(is_user_alive(id) && !is_user_bot(id)) {
fm_strip_user_weapons(id)
fm_give_item(id, "weapon_knife")
if(cs_get_user_team(id) == CS_TEAM_CT) {
give_item(id, "weapon_usp")
give_item(id,"ammo_45acp")
give_item(id,"ammo_45acp")
give_item(id,"ammo_45acp")
give_item(id,"ammo_45acp")
give_item(id,"ammo_45acp")
give_item(id,"ammo_45acp")
give_item(id,"ammo_45acp")
give_item(id,"ammo_45acp")
give_item(id,"ammo_45acp")
}else{
give_item(id,"weapon_glock18")
give_item(id,"ammo_9mm")
give_item(id,"ammo_9mm")
give_item(id,"ammo_9mm")
give_item(id,"ammo_9mm")
give_item(id,"ammo_9mm")
give_item(id,"ammo_9mm")
give_item(id,"ammo_9mm")
}
}
}
Cader is offline
Shadows In Rain
Senior Member
Join Date: Apr 2010
Location: Russia::Siberia
Old 03-06-2011 , 17:20   Re: give pistols if dead
Reply With Quote #2

Code:
new bool:u_died[33] ... public plugin_init() {     ...     RegisterHam(Ham_Spawn, "player", "giveweap", 1)     ...     RegisterHam(Ham_Killed, "player", "fn_PlayerKilled_post", 1)     ... } ... public fn_PlayerKilled_post(victim, attacker, shouldgib) {     u_died[victim] = true } ... public giveweap(id) {     if(is_user_alive(id) && !is_user_bot(id) && u_died[id])     {         u_died[id] = false                 fm_strip_user_weapons(id)         fm_give_item(id, "weapon_knife")                 if(cs_get_user_team(id) == CS_TEAM_CT)         {             give_item(id, "weapon_usp")                         give_item(id,"ammo_45acp")             give_item(id,"ammo_45acp")             give_item(id,"ammo_45acp")             give_item(id,"ammo_45acp")             give_item(id,"ammo_45acp")             give_item(id,"ammo_45acp")             give_item(id,"ammo_45acp")             give_item(id,"ammo_45acp")             give_item(id,"ammo_45acp")         }         else         if(cs_get_user_team(id) == CS_TEAM_T) // what if spawned as spectator / unassigned?         {             give_item(id,"weapon_glock18")                         give_item(id,"ammo_9mm")             give_item(id,"ammo_9mm")             give_item(id,"ammo_9mm")             give_item(id,"ammo_9mm")             give_item(id,"ammo_9mm")             give_item(id,"ammo_9mm")             give_item(id,"ammo_9mm")         }     } }
__________________
I'm using Google translator, yarrr. |.◕‿‿◕.|
Shadows In Rain is offline
Send a message via ICQ to Shadows In Rain
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-06-2011 , 17:24   Re: give pistols if dead
Reply With Quote #3

Try this :

PHP Code:
/*    Formatright © 2010, ConnorMcLeod

    This plugin is free software;
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this plugin; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

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

#define VERSION "0.0.1"
#define PLUGIN ""

#define XO_PLAYER 5
#define m_bNotKilled 113
#define HasUserSurvivedLastRound(%0)    get_pdata_int(%0, m_bNotKilled, XO_PLAYER)

new g_bitConnecting
#define MarkUserConnecting(%0)    g_bitConnecting |= 1<<(%0&31)
#define ClearUserConnecting(%0)    g_bitConnecting &= ~(1<<(%0&31))
#define IsUserConnecting(%0)    ( g_bitConnecting & 1<<(%0&31) )

new HamHook:g_iHhPlayerSpawnPostHamHook:g_iHhAddPlayerItemPre

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")
    
RegisterHam(Ham_Spawn"player""CBasePlayer_Spawn_Pre")

    
DisableHamForwardg_iHhPlayerSpawnPost RegisterHam(Ham_Spawn"player""CBasePlayer_Spawn_Post"1) )
    
DisableHamForwardg_iHhAddPlayerItemPre RegisterHam(Ham_AddPlayerItem"player""CBasePlayer_AddPlayerItem_Pre") )
}

public 
client_connectid )
{
    
MarkUserConnectingid )
}

public 
client_putinserverid )
{
    
ClearUserConnectingid )
}

public 
CBasePlayer_Spawn_Preid )
{
    if( !
IsUserConnecting(id) && !HasUserSurvivedLastRound(id) )
    {
        
EnableHamForwardg_iHhPlayerSpawnPost )
        
EnableHamForwardg_iHhAddPlayerItemPre )
    }
}

public 
CBasePlayer_AddPlayerItem_Preid iWeapon )
{
    return 
HAM_SUPERCEDE
}

public 
CBasePlayer_Spawn_Postid )
{
    
DisableHamForwardg_iHhPlayerSpawnPost )
    
DisableHamForwardg_iHhAddPlayerItemPre )
    
strip_user_weapons(id)
    
give_item(id"weapon_knife")
    switch( 
cs_get_user_team(id) )
    {
        case 
CS_TEAM_T:
        {
            
give_item(id"weapon_glock18")
            
cs_set_user_bpammo(idCSW_GLOCK18120)
        }
        case 
CS_TEAM_CT:
        {
            
give_item(id"weapon_usp")
            
cs_set_user_bpammo(idCSW_USP100)
        }
    }

__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 05:16.


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