Re: [Help] give_item
1 Attachment(s)
Quote:
Originally Posted by ConnorMcLeod
(Post 1035083)
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 ). }
GiveNamedItem( id, pszName[] ) { new iEnt, iStr
iStr = MAKE_STRING(pszName)
iEnt = CREATE_NAMED_ENTITY(iStr) if( !pev_valid( iEnt ) ) { ALERT ( at_console, "NULL Ent in GiveNamedItem!\n" ) return }
new Float:fOrigin[3] pev(id, pev_origin, fOrigin) set_pev(iEnt, pev_origin, fOrigin) set_pev(iEnt, pev_spawnflags, pev(iEnt, pev_spawnflags) | SF_NORESPAWN)
_DispatchSpawn( iEnt , fOrigin ) DispatchTouch( iEnt, id ) }
_DispatchSpawn( iEnt , Float:fOrigin[3] ) { if( pev_valid( iEnt ) ) { if( !fOrigin[0] ) { pev(iEnt, pev_origin, fOrigin) }
fOrigin[0] -= 1 fOrigin[1] -= 1 fOrigin[2] -= 1 set_pev(iEnt, pev_absmin, fOrigin)
fOrigin[0] += 2 fOrigin[1] += 2 fOrigin[2] += 2 set_pev(iEnt, pev_absmax, fOrigin)
dllfunc(DLLFunc_Spawn, iEnt) } }
DispatchTouch( pEntity, pOther ) { if( pEntity && pOther && !( (pev(pEntity, pev_flags)|pev(pOther, pev_flags)) & FL_KILLME ) ) { dllfunc(DLLFunc_Touch, pEntity, pOther) } } //-------------------------------------------------------------------
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 i; i<sizeof( g_szWeapons ); i++) { if ( contain(giveweapons , g_szWeapons[i]) != -1) { GiveNamedItem( id, g_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<sizeof( g_szAmmoTypes ); i++) { new pos if ((pos = contain(giveammo, g_szAmmoTypes[i])) != -1) { pos += strlen(g_szAmmoTypes[i]) + 1 new pos2, amount 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_int( id, g_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_forward( FM_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_return( FMV_STRING, amx_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 :D )
|