AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to give player a weapon on round start? (https://forums.alliedmods.net/showthread.php?t=87127)

6o}|{e 03-07-2009 08:25

How to give player a weapon on round start?
 
Hi there! ;)

How to give player a weapon or two or maybe more than one on round start?

hleV 03-07-2009 08:29

Re: How to give player a weapon on round start?
 
Code:
#include <amxmodx> #include <fakemeta_util>   new g_MaxPlayers;   public plugin_init()         register_event("HLTV", "NewRound", "a", "1=0", "2=0");   public plugin_cfg()         g_MaxPlayers = get_maxplayers();   public NewRound()         for (new Client = 1; Client <= g_MaxPlayers; Client++)         {                 if (!is_user_alive(Client))                         continue;                   fm_give_item(Client, "weapon_awp"); // The way to give weapon         }

6o}|{e 03-07-2009 08:43

Re: How to give player a weapon on round start?
 
Man you are quick. :) Thanks and + karma.

ConnorMcLeod 03-07-2009 08:58

Re: How to give player a weapon on round start?
 
hleV code won't compile unless you include fun instead of fakemeta_util, or unless you change give_item with fm_give_item.
Moreover, on new round, player who have died during the previous round are still dead.

It would be better to give weapons when players spawn.
Clic this link to see weapons and ammo names.

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

public plugin_init()
{
    
RegisterHam(Ham_Spawn"player""Player_Spawn_Post"1)
}

public 
Player_Spawn_Postid )
{
    if( 
is_user_aliveid ) )
    {
        
GiveNamedItemid "weapon_awp" )
        
GiveNamedItemid "ammo_338magnum" )
        
GiveNamedItemid "ammo_338magnum" )
        
GiveNamedItemid "ammo_338magnum" )
    }
}

GiveNamedItemid szName[] )
{
    new 
iEnt engfuncEngFunc_CreateNamedEntityengfunc(EngFunc_AllocStringszName) )
    if( 
pev_validiEnt ) )
    {
        new 
Float:fOrigin[3]
        
pev(idpev_originfOrigin)
        
set_pev(iEntpev_originfOrigin)
        
set_pev(iEntpev_spawnflagspev(iEntpev_spawnflags) | SF_NORESPAWN)
        
dllfunc(DLLFunc_SpawniEnt)
        
dllfunc(DLLFunc_TouchiEntid)
        if( 
szName[0] == 'w' && pev(iEntpev_effects) & EF_NODRAW )
        {
            return 
iEnt // returns only weapon ents
        
}
        else if( 
szName[0] == 'i' // only some items doesn't disappear
        
{
            
set_pev(iEntpev_flagsFL_KILLME)
        }
    }
    return 
0



Dr.G 03-07-2009 08:59

Re: How to give player a weapon on round start?
 
fm_give_item ??? :)

ConnorMcLeod 03-07-2009 09:05

Re: How to give player a weapon on round start?
 
Quote:

Originally Posted by Dr.G (Post 775712)
fm_give_item ??? :)

It's similar to the function GiveNamedItem i made, and it's included in fakemeta_util.inc.

Dr.G 03-07-2009 09:36

Re: How to give player a weapon on round start?
 
yea i know it was a comment to helV's code... didnt see your post came between ;)


All times are GMT -4. The time now is 08:50.

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