AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Permanent Superjump? (https://forums.alliedmods.net/showthread.php?t=87979)

Spunky 03-18-2009 21:09

Permanent Superjump?
 
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. :(

Exolent[jNr] 03-18-2009 21:45

Re: Permanent Superjump?
 
Code:
    RegisterHam(Ham_Spawn, "player", "fnSpawn", 0)
:arrow:
Code:
    RegisterHam(Ham_Spawn, "player", "fnSpawn", 1)

Also, check is_user_alive().

Spunky 03-18-2009 22:27

Re: Permanent Superjump?
 
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. :(

dogandcat 03-19-2009 13:41

Re: Permanent Superjump?
 
check user alive....

ConnorMcLeod 03-19-2009 13:51

Re: Permanent Superjump?
 
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))



Styles 03-19-2009 13:57

Re: Permanent Superjump?
 
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;
}


ConnorMcLeod 03-19-2009 14:17

Re: Permanent Superjump?
 
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)



Spunky 03-19-2009 17:29

Re: Permanent Superjump?
 
Thanks Connor, that works perfectly.


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

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