Raised This Month: $ Target: $400
 0% 

Permanent Superjump?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 03-18-2009 , 21:09   Permanent Superjump?
Reply With Quote #1

Using TSFUN:
Code:
#include <amxmodx> #include <hamsandwich> #include <tsfun> new g_iSuperJump[32] public plugin_init() {     register_plugin("Permanent Superjump", "1.0", "Spunky")     RegisterHam(Ham_Spawn, "player", "fnSpawn", 0) } public fnSpawn(id) {     new const iIndex = id - 1     g_iSuperJump[iIndex] = ts_createpwup(TSPWUP_SUPERJUMP)     ts_givepwup(id, g_iSuperJump[iIndex])     return HAM_HANDLED }

With this, whenever someone joins, before they even get in the game, I get a runtime error and my server crashes. The error says that the player isn't in game yet.
Spunky is offline
Send a message via AIM to Spunky
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-18-2009 , 21:45   Re: Permanent Superjump?
Reply With Quote #2

Code:
    RegisterHam(Ham_Spawn, "player", "fnSpawn", 0)

Code:
    RegisterHam(Ham_Spawn, "player", "fnSpawn", 1)

Also, check is_user_alive().
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 03-18-2009 , 22:27   Re: Permanent Superjump?
Reply With Quote #3

I changed:
Code:
RegisterHam(Ham_Spawn, "player", "fnSpawn", 0)

to:
Code:
RegisterHam(Ham_Spawn, "player", "fnSpawn", 1)

And still got the error. The error stopped when I added the is_user_alive() check, but no powerup was given after spawning. For some reason it's still calling it before the player is even in the server. I tried killing myself a few times to see if it would invoke it correctly, but no luck.
Spunky is offline
Send a message via AIM to Spunky
dogandcat
BANNED
Join Date: Jan 2009
Old 03-19-2009 , 13:41   Re: Permanent Superjump?
Reply With Quote #4

check user alive....
dogandcat is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-19-2009 , 13:51   Re: Permanent Superjump?
Reply With Quote #5

Try this :

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <tsfun>

#define MAX_PLAYERS 32

new g_bFirstSpawn[MAX_PLAYERS+1]

public 
plugin_init()
{
    
RegisterHam(Ham_Spawn"player""Player_Spawn_Pre")
    
register_forward(FM_ClientPutInServer"ClientPutInServer")
}

public 
ClientPutInServer(id)
{
    
g_bFirstSpawn[id] = true
}

public 
Event_TextMsg_Restart()
{
    
g_bRestarting true
}

public 
Player_Spawn_Preid )
{
    if( 
g_bFirstSpawn[id] )
    {
        
g_bFirstSpawn[id] = false
        
return
    }

    
ts_givepwup(idts_createpwup(TSPWUP_SUPERJUMP))

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 03-19-2009 at 13:54.
ConnorMcLeod is offline
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 03-19-2009 , 13:57   Re: Permanent Superjump?
Reply With Quote #6

wont work, ts_givepwup doesn't work. You have to createpwup then set its origin UNDER the person then they move into it. that function has never worked sadily,
Code:
static cell AMX_NATIVE_CALL give_pwup(AMX *amx, cell *params)
{ // index,pwupentindex
	edict_t* pent = INDEXENT(params[2]);
	if ( FNullEnt( pent ) || strcmp("ts_powerup",STRING(pent->v.classname))!=0 ){
		return 0;
	}
	
	int id = params[1];
	if (id<1 || id>gpGlobals->maxClients)
	{ 
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", id);
		return 0;
	}
	CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
	if (!pPlayer->ingame || !pPlayer->IsAlive())
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Player %d is not ingame.", id);
		return 0;
	}

	pent->v.origin = pPlayer->pEdict->v.origin;

	MDLL_Touch(pent, pPlayer->pEdict);

	REMOVE_ENTITY(pent);

	return 1;
}

Last edited by Styles; 03-19-2009 at 14:01.
Styles is offline
Send a message via AIM to Styles
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-19-2009 , 14:17   Re: Permanent Superjump?
Reply With Quote #7

Then you can try this :

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_alive(id) )
    {
        
GiveUserSuperJumpid )
    }
}

GiveUserSuperJumpid )
{
    new 
iEnt engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"ts_powerup"))
    if( !
pev_validiEnt ) )
    {
        return
    }

    
SetKeyValue(iEnt"pwuptype""256""ts_powerup")
    
SetKeyValue(iEnt"duration""60""ts_powerup")

    new 
Float:fOrigin[3]
    
pev(idpev_originfOrigin)
    
set_pev(iEntpev_originfOrigin)

    
dllfunc(DLLFunc_SpawniEnt)
    
dllfunc(DLLFunc_TouchiEntid)
}

SetKeyValue(iEnt, const szKey[], const szValue[], const szClassName[])
{
    
set_kvd(0KV_ClassNameszClassName)
    
set_kvd(0KV_KeyNameszKey)
    
set_kvd(0KV_ValueszValue)
    
set_kvd(0KV_fHandled0)
    
dllfunc(DLLFunc_KeyValueiEnt0)

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 03-19-2009 , 17:29   Re: Permanent Superjump?
Reply With Quote #8

Thanks Connor, that works perfectly.
Spunky is offline
Send a message via AIM to Spunky
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 08:58.


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