Raised This Month: $ Target: $400
 0% 

[Help] give_item


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
ujjl
Senior Member
Join Date: Jul 2009
Location: Hungary
Old 12-29-2009 , 08:32   Re: [Help] give_item
Reply With Quote #8

Quote:
Originally Posted by ConnorMcLeod View Post
Wait, seeing your code...
Do you say that when you spawn in the air, give a longjump doesn't work, and give other items work ? (even with your old code idc).
Well i use your func instead of give_item for all weapon and item to give. Now its not crash server, but i dont get the longjump module (other weapons i get) when i spawn in the air. This wierd thing happens in severian mod or with give_item or with your givenameditem.

PHP Code:
/*
    Respawn Item Control
        by ujjl
    
    Description:
      This plugin gives you extra items when you respawn. Eg. Longjump, or Shotgun.
      
    CVARS:
      "mp_giveweapons"    "weapon_shotgun;weapon_357;weapon_crossbow;weapon_9mmhandgun;weapon_crowbar;weapon_9mmAR;item_longjump;"
      "mp_giveammo"    "357:8;9mm:150;bolts:12;uranium:60;buckshot:50;ARgrenades:1;tripmine:40;"

      //TODO give_item fuggvenyt lecserelni valami "halkabbra"
      //TODO itemeket cvar-bol olvassa be
*/

#include <amxmodx>
//#include <amxmisc>
#include <fun>
#include <fakemeta>
#include <hamsandwich>

    #define VERSION         "0.9.7"

    #define SHOTGUN_BPAMMO_OFFSET        310     
    #define GLOCK_MP5_9MM_BPAMMO_OFFSET        311 
    #define CHAINGUN_BPAMMO_OFFSET        312
    #define PYTHON_BPAMMO_OFFSET        313
    #define GAUSS_EGON_BPAMMO_OFFSET        314
    #define RPG_BPAMMO_OFFSET            315
    #define CROSSBOW_BPAMMO_OFFSET        316
    #define TRIPMINE_BPAMMO_OFFSET        317
    #define SATCHEL_BPAMMO_OFFSET        318
    #define GRENADE_BPAMMO_OFFSET        319
    #define SNARK_BPAMMO_OFFSET            320    
    #define HORNET_BPAMMO_OFFSET        321
    
   //-----------------------------------------------------------------
   #define MAKE_STRING(%1)            engfunc(EngFunc_AllocString, %1)
#define CREATE_NAMED_ENTITY(%1)    engfunc(EngFunc_CreateNamedEntity, %1)
#define ALERT(%1,%2)            engfunc(EngFunc_AlertMessage, %1, %2)

enum {
    
at_notice,
    
at_console,        // same as at_notice, but forces a ConPrintf, not a message box
    
at_aiconsole,    // same as at_console, but only shown if developer level is 2!
    
at_warning,
    
at_error,
    
at_logged        // Server print to console ( only in multiplayer games ).
}

GiveNamedItemidpszName[] )
{
    new 
iEntiStr

    iStr 
MAKE_STRING(pszName)

    
iEnt CREATE_NAMED_ENTITY(iStr)
    if( !
pev_validiEnt ) )
    {
        
ALERT at_console"NULL Ent in GiveNamedItem!\n" )
        return
    }

    new 
Float:fOrigin[3]
    
pev(idpev_originfOrigin)
    
set_pev(iEntpev_originfOrigin)
    
set_pev(iEntpev_spawnflagspev(iEntpev_spawnflags) | SF_NORESPAWN)

    
_DispatchSpawniEnt fOrigin )
    
    
DispatchTouchiEntid )
}

_DispatchSpawniEnt Float:fOrigin[3] )
{
    if( 
pev_validiEnt ) )
    {
        if( !
fOrigin[0] )
        {
            
pev(iEntpev_originfOrigin)
        }

        
fOrigin[0] -= 1
        fOrigin
[1] -= 1
        fOrigin
[2] -= 1
        set_pev
(iEntpev_absminfOrigin)

        
fOrigin[0] += 2
        fOrigin
[1] += 2
        fOrigin
[2] += 2
        set_pev
(iEntpev_absmaxfOrigin)

        
dllfunc(DLLFunc_SpawniEnt)
    }
}

DispatchTouchpEntitypOther )
{
    if(  
pEntity && pOther && !( (pev(pEntitypev_flags)|pev(pOtherpev_flags)) & FL_KILLME )  )
    {
        
dllfunc(DLLFunc_TouchpEntitypOther)
    }
}  
   
//-------------------------------------------------------------------

new const g_szAmmoTypes[][] = {"buckshot","9mm","ARgrenades","357","uranium","rockets","bolts",
                
"tripmine","satchel","handgrenade","snark"}

new const 
g_szAmmoOffsets[] = {310,311,312,313,314,415,316,317,318,319,320}

new const 
g_szWeapons[][] = {"item_longjump","weapon_crowbar","weapon_9mmhandgun","weapon_shotgun",
                
"weapon_357","weapon_python","weapon_mp5","weapon_crossbow",
                
"weapon_9mmAR","weapon_rpg","weapon_gauss","weapon_egon",
                
"weapon_hornetgun","weapon_tripmine","weapon_satchel",
                
"weapon_handgrenade","weapon_snark"}    

new const 
amx_gamename[] = "sev09"

/*public event_hud_reset(id) 
{
    set_task(0.01,"give_weps",id)
    //give_weps(id)
    return PLUGIN_HANDLED
}*/

public give_weps(id
{
    if(
is_user_alive(id)){
    
strip_user_weapons(id)    //UPDATE RemoveAllItems(id, true);
    
    //give weapons
    
new giveweapons[128]
    
get_cvar_string("mp_giveweapons",giveweapons,charsmax (giveweapons))
    
    for(new 
ii<sizeofg_szWeapons ); i++)
    {
        if ( 
contain(giveweapons g_szWeapons[i]) != -1)
        {
            
            
GiveNamedItemidg_szWeapons[i] )
            
//give_item(id,g_szWeapons[i])
        
}
            
    }
    
    
//give ammo
    
new giveammo[128]
    
get_cvar_string("mp_giveammo",giveammo,charsmax (giveammo))
    
    for(new 
i;i<sizeofg_szAmmoTypes ); i++)
    {
        new 
pos
        
if ((pos contain(giveammog_szAmmoTypes[i])) != -1) {
            
pos += strlen(g_szAmmoTypes[i]) + 1
            
            
new pos2amount
            
            
if ((pos2 contain(giveammo[pos], ";")) != -1) {
                
pos2 += pos
                
//client_print(id,print_chat,"[ujjl] %s",giveammo[pos2]);
                
giveammo[pos2] = '^0'
                
amount str_to_num(giveammo[pos])
                
giveammo[pos2] = ';'
            
}
            else
            
amount str_to_num(giveammo[pos])
            
set_pdata_intidg_szAmmoOffsets[i], amount )
        }
    }
    
    return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

public 
plugin_init() 
{
    
register_plugin("Respawn Items",VERSION,"ujjl")
    
    
register_cvar("mp_giveweapons","weapon_shotgun;weapon_357;weapon_crossbow;weapon_9mmhandgun;weapon_crowbar;weapon_9mmAR;item_longjump;")
    
register_cvar("mp_giveammo","357:8;9mm:150;bolts:12;uranium:60;buckshot:50;ARgrenades:1;")
    
register_cvar("sev09_version",VERSION)
    
register_forwardFM_GetGameDescription"GameDesc" )
    
//register_event("ResetHUD","event_hud_reset","b");
    
RegisterHam(Ham_Spawn"player",  "give_weps"1)

    return 
PLUGIN_HANDLED
}
 
public 
client_putinserver(id)
{
    
set_task(0.01,"give_weps",id)
}

public 
GameDesc( ) {
    
forward_returnFMV_STRINGamx_gamename )
    return 
FMRES_SUPERCEDE
}

    
//[TUT]
    //  RegisterHam(Ham_Spawn, "player", "PlayerPreSpawn", 0); // Pre, player is dead
    //  RegisterHam(Ham_Spawn, "player", "PlayerPostSpawn", 1); // Post, player is alive 
Is it possible maybe to use set_pdata or something like i set the ammo of the weapons, to give longjump?

Edit: I added a map to test, it got some place (especially at the helicopter landing spot) where you got respawn places in the air (and its a good map )
Attached Files
File Type: rar C2A5E.rar (617.8 KB, 114 views)
__________________
- blupi blupi

Last edited by ujjl; 12-29-2009 at 08:47.
ujjl is offline
 



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 04:14.


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