Raised This Month: $ Target: $400
 0% 

[Help] give_item


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ujjl
Senior Member
Join Date: Jul 2009
Location: Hungary
Old 12-29-2009 , 07:28   [Help] give_item
Reply With Quote #1

Hi! ( Long time no see )

When I use this command
PHP Code:
give_item(iPlayer,"item_longjump"
On player respawn, and the respawn place is not close to the ground. (Its high in the air). Then the player will not get his longjump module.

Any idea how to fix this?
__________________
- blupi blupi
ujjl is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-29-2009 , 07:34   Re: [Help] give_item
Reply With Quote #2

Do you use orpheu module ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
ujjl
Senior Member
Join Date: Jul 2009
Location: Hungary
Old 12-29-2009 , 07:37   Re: [Help] give_item
Reply With Quote #3

Quote:
Originally Posted by ConnorMcLeod View Post
Do you use orpheu module ?
Just this:

PHP Code:
#include <amxmodx>
#include <fun>
#include <fakemeta>
#include <hamsandwich> 
__________________
- blupi blupi
ujjl is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-29-2009 , 07:42   Re: [Help] give_item
Reply With Quote #4

I mean on the server.

Anyway, try ti use this instead to see if it works :

GiveNamedItem( id, "item_longjump" )

Then if it works we can find a workaround (the code above it not optimized at all)

PHP Code:
#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 )
    
    
DispatchTouchEntid )
}

_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)
    }

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 12-29-2009 at 07:45.
ConnorMcLeod is offline
ujjl
Senior Member
Join Date: Jul 2009
Location: Hungary
Old 12-29-2009 , 08:13   Re: [Help] give_item
Reply With Quote #5

No i dont have orpheu module on server.
The plugin works on normal respawn places. But when im high in the air, server crashes.

I use this btw:

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;"
*/

#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)
        {
            if ( 
equal(g_szWeapons[i],"item_longjump") )
            {
                
GiveNamedItemid"item_longjump" )
            }
            else 
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

__________________
- blupi blupi
ujjl is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 12-29-2009 , 08:18   Re: [Help] give_item
Reply With Quote #6

Connor i think he is using half-life not CS, so he doesnt need orpheu
__________________
xPaw is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-29-2009 , 08:25   Re: [Help] give_item
Reply With Quote #7

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).
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-29-2009 , 08:27   Re: [Help] give_item
Reply With Quote #8

Yes he has a HL server. ;)
__________________
Arkshine is offline
Old 12-29-2009, 08:27
ujjl
This message has been deleted by ujjl. Reason: Not accurate
ujjl
Senior Member
Join Date: Jul 2009
Location: Hungary
Old 12-29-2009 , 08:32   Re: [Help] give_item
Reply With Quote #9

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
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-29-2009 , 11:09   Re: [Help] give_item
Reply With Quote #10

Try to set physic keyvalue instead of giving the item.
Also you would have to find the "has longjump" offset.
__________________
- tired and retired -

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


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