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

Function on player spawn, how to set index?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GoldNux
Senior Member
Join Date: Mar 2018
Old 03-18-2018 , 19:24   Function on player spawn, how to set index?
Reply With Quote #1

This plugin is meant to give you a weapon when you respawn, but it gives you a new weapon any time someone respawns. How do I make it so it only does it for the person spawning?

Thanks!

Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <hamsandwich> #include <fun> #define PLUGIN "gn_impulser" #define VERSION "0.1" #define AUTHOR "GoldNux" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1)     register_cvar("gn_impulse", "0") } public fwHamPlayerSpawnPost(id) {     if (is_user_alive(id))     {         if (!get_cvar_num("gn_impulse"))         {             return PLUGIN_CONTINUE         }         new players[32]         new playercount         get_players(players, playercount)         new i         for (i=0; i<playercount; i++)         {             giveWeapons(players[i])         }     }     return PLUGIN_CONTINUE } public giveWeapons(id) {     if (cs_get_user_team(id) == CS_TEAM_T)     {            cs_set_user_armor(id, 100, CS_ARMOR_VESTHELM)         give_item(id, "weapon_ak47")         cs_set_user_bpammo(id, CSW_SCOUT, 90)         give_item(id, "weapon_hegrenade")         client_cmd(id, "lastinv")     }     if (cs_get_user_team(id) == CS_TEAM_CT)     {         cs_set_user_armor(id, 100, CS_ARMOR_VESTHELM)         give_item(id, "weapon_m4a1")         cs_set_user_bpammo(id, CSW_AUG, 90)         cs_set_user_defuse(id, 1)         give_item(id, "weapon_hegrenade")         client_cmd(id, "lastinv")     } }
__________________
Try my version of de_dust2, I think it's great and you should check it out!
https://gamebanana.com/mods/83731
GoldNux is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 03-18-2018 , 19:43   Re: Function on player spawn, how to set index?
Reply With Quote #2

change :

PHP Code:
public fwHamPlayerSpawnPost(id)
{
    if (
is_user_alive(id))
    {
        if (!
get_cvar_num("gn_impulse"))
        {
            return 
PLUGIN_CONTINUE
        
}

        new 
players[32]
        new 
playercount
        get_players
(playersplayercount)

        new 
i
        
for (i=0i<playercounti++)
        {
            
giveWeapons(players[i])
        }
    }

    return 
PLUGIN_CONTINUE

to:

PHP Code:
public fwHamPlayerSpawnPost(id)
{
    if (
is_user_alive(id))
    {
        if (!
get_cvar_num("gn_impulse"))
        {
            return 
PLUGIN_CONTINUE
        
}

        
giveWeapons(id)
    }

    return 
PLUGIN_CONTINUE

__________________
JusTGo is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-18-2018 , 20:30   Re: Function on player spawn, how to set index?
Reply With Quote #3

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

#define PLUGIN "gn_impulser"
#define VERSION "0.1"
#define AUTHOR "GoldNux"

new g_pImpulse;

public 
plugin_init()
{
    
register_pluginPLUGIN VERSION AUTHOR );
    
RegisterHamHam_Spawn "player""fwHamPlayerSpawnPost" );
    
g_pImpulse register_cvar"gn_impulse" "0" );
}

public 
fwHamPlayerSpawnPostid )
{
    if ( 
is_user_aliveid ) && get_pcvar_numg_pImpulse ) )
    {
        
giveWeaponsid );
    }


public 
giveWeaponsid )
{
    new 
CsTeams:ctTeam cs_get_user_teamid );
    
    
give_itemid , ( ctTeam == CS_TEAM_T ) ? "weapon_ak47" "weapon_m4a1" );
    
cs_set_user_bpammoid , ( ctTeam == CS_TEAM_T ) ? CSW_SCOUT CSW_AUG 90 );
    
give_itemid "weapon_hegrenade" );
    
cs_set_user_armorid 100 CS_ARMOR_VESTHELM );
    
client_cmdid "lastinv" );

__________________

Last edited by Bugsy; 03-18-2018 at 20:57.
Bugsy is offline
Reply


Thread Tools
Display Modes

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 02:10.


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