AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with ZP class pls! (https://forums.alliedmods.net/showthread.php?t=107911)

retribution 10-31-2009 19:57

Help with ZP class pls!
 
Good day! I was trying to rewrite Kamikaze superhero and make a ZP class from it. I saw several ZP Kamikaze classes already, but i need not to DMG ppl, i want infect them like infection bomb from ZP core plugin does. So all things works just fine, but infection fails. Here is ZP core plugin http://forums.alliedmods.net/showthread.php?t=72505

Can you tell me where is my problem?

PHP Code:

// Based on Kamikaze! - Credits AssKicR & Scarzzurs/The_Unbound & {HOJ} Batman, rewritten for ZP by Lethal

/* CVARS - copy and paste to zombieplague.cfg

//Kamikaze
zp_kamikaze_radius 450        //Radius of people affected by blast
zp_kamikaze_fuse 15            //# of seconds before kamikaze blows Up
zp_kamikaze_surv 0            // Work on survivor rounds
zp_kamikaze_nem 0            // Work on nemesis rounds

*/

#include <amxmodx>
#include <fakemeta>
#include <fakemeta_util>
#include <zombieplague>

// GLOBAL VARIABLES
#define MAXPLAYERS 32
new bool:gHasKamikaze[MAXPLAYERS+1]
new 
gFuseTime[MAXPLAYERS+1]
new const 
gSoundCountdown[] = "buttons/blip2.wav"
new const gSoundFvox[11][] = {"""one""two""three""four""five""six""seven""eight""nine""ten"}
new 
gSpriteSmokegSpriteGas
new gMsgSync
new pCvarRadiuspCvarFusepCvarSurvRoundpCvarNemRound

// Zombie Attributes
new const zkamik_name[] = "Kamikaze Zombie" // name
new const zkamik_info[] = "Blows up" // description
new const zkamik_model[] = "zombie_hostage" // model
new const zkamik_clawmodel[] = "v_knife_zombie.mdl" // claw model
const zkamik_health 2000 // health
const zkamik_speed 200 // speed
const Float:zkamik_gravity 1.2 // gravity
const Float:zkamik_knockback 0.8 // knockback

// Class IDs
new g_zkamikid


//----------------------------------------------------------------------------------------------
public plugin_init()
{
    
register_plugin("[ZP] Kamikaze Zombie""0.1""AssKicR/JTP10181")

    
pCvarRadius register_cvar("zp_kamikaze_radius""450")
    
pCvarFuse register_cvar("zp_kamikaze_fuse""10")
    
pCvarSurvRound register_cvar("zp_kamikaze_surv""0")
    
pCvarNemRound register_cvar("zp_kamikaze_nem""0")

    
register_event("DeathMsg","EventDeathMsg","a")
    
register_forward(FM_PlayerPreThink,     "fwd_playerprethink")

    
gMsgSync CreateHudSyncObj()
}

// Zombie Classes MUST be registered on plugin_precache
public plugin_precache()
{
    
// Register the new class and store ID for reference
    
g_zkamikid zp_register_zombie_class(zkamik_namezkamik_infozkamik_modelzkamik_clawmodelzkamik_healthzkamik_speedzkamik_gravityzkamik_knockback)    

    
gSpriteSmoke precache_model("sprites/steam1.spr")
    
gSpriteGas precache_model("sprites/shockwave.spr")
    
precache_sound(gSoundCountdown)
}
//----------------------------------------------------------------------------------------------
// User Infected forward
public zp_user_infected_post(idinfector)
{
    
// No extra power to nemesis and survivor!
    
if (zp_get_user_survivor(id) || zp_get_user_nemesis(id))
        return

    
// Check if the infected player is using our custom zombie class
    
if (zp_get_user_zombie_class(id) == g_zkamikid)
        
gHasKamikaze[id] = true
}
//----------------------------------------------------------------------------------------------
public fwd_playerprethink(id
{
    
// No extra power to nemesis and survivor!
    
if (zp_get_user_survivor(id) || zp_get_user_nemesis(id))
        return 
FMRES_IGNORED

    
if(!gHasKamikaze[id] || !zp_get_user_zombie(id) || gFuseTime[id]) 
        return 
FMRES_IGNORED
        
    
if(zp_is_survivor_round() && get_pcvar_num(pCvarSurvRound) == 0)
        return 
FMRES_IGNORED
        
    
if(zp_is_nemesis_round() && get_pcvar_num(pCvarNemRound) == 0)
        return 
FMRES_IGNORED
    
    
new button fm_get_user_button(id)
    
    if((
button IN_USE) && (zp_get_user_zombie_class(id) == g_zkamikid))
    {
        
gFuseTime[id] = get_pcvar_num(pCvarFuse)
        
kamikaze_loop(id)
    }

    return 
FMRES_IGNORED
}
//----------------------------------------------------------------------------------------------
public kamikaze_loop(player)
{
    if (!
gHasKamikaze[player] || !is_user_alive(player) || !zp_get_user_zombie(player))
        return

    
// No extra power to nemesis and survivor!
    
if (zp_get_user_survivor(player) || zp_get_user_nemesis(player))
        return

    new 
fuseTime gFuseTime[player]

    if (
fuseTime 0)
    {
        
emit_sound(playerCHAN_ITEMgSoundCountdownVOL_NORMATTN_NORM0PITCH_NORM)

        
gFuseTime[player] = --fuseTime

        
if (fuseTime <= )
        {
            
infection_explode(player)
        }
        else
        {
            
// Decrement the counter
            
set_hudmessage(01002000.050.6520.021.00.010.1, -1)
            
ShowSyncHudMsg(playergMsgSync"You will explode in %d second%s"fuseTimefuseTime == "" "s")
            
// Say Time Remaining to the User Only.
            
if ( fuseTime == 11 ) {
                
client_cmd(player"fspk ^"vox/remaining^"")
            }
            else if ( 
fuseTime 11 ) {
                
client_cmd(player"fspk ^"vox/%s^""gSoundFvox[fuseTime])
            }
        }
    }
    
// Loop the task
    
set_task(1.0,"kamikaze_loop",player)
}
//----------------------------------------------------------------------------------------------
// Infection Bomb Explosion
public infection_explode(id)
{
    if ( 
id <= || id MAXPLAYERS ) return;

    if (!
is_user_connected(id) || !zp_get_user_zombie(id)) return;

    
// No extra power to nemesis and survivor!
    
if (zp_get_user_survivor(id) || zp_get_user_nemesis(id)) return;

    if(
zp_is_swarm_round()) return;

    if(
zp_is_survivor_round() && get_pcvar_num(pCvarSurvRound) == 0) return;
        
    if(
zp_is_nemesis_round() && get_pcvar_num(pCvarNemRound) == 0) return;

    
gFuseTime[id] = 0

    
// Get origin
    
static Float:originF[3]
    
pev(idpev_originoriginF)
    
    
// Kill id first, if alive, because he is the bomb
    
if (is_user_alive(id))
    {
        
set_pev(idpev_takedamageDAMAGE_AIM)        // Make sure they dont have godmode so we can kill them
        //set_pev(id,pev_health,0)    // KILL H@H@@H@H@H@H@H@HH@@@ lot of fun with that
        
user_kill(id1)
    }

    
// Make the explosion
    
create_blast(originF)
    
    
// Infection nade explode sound & msg
    
new name[32]
    
emit_sound(idCHAN_WEAPON"squeek/sqk_blast1.wav"1.0ATTN_NORM0PITCH_NORM)
    
get_user_name(idname31)
    
set_hudmessage(0200100.050.6520.021.00.010.1, -1)
    
ShowSyncHudMsg(0gMsgSync"%s has exploded"name)
    
    
// Collisions
    
static victim
    victim 
= -1
    
new Float:dmgRadius get_pcvar_float(pCvarRadius)
    
    while ((
victim engfunc(EngFunc_FindEntityInSpherevictimoriginFdmgRadius)) != 0)
    {
        
client_print(0print_chat,"DEBUG: Zone match!")

        
// Only effect alive
        
if (!is_user_alive(victim) || zp_get_user_zombie(victim)) continue;
        
        
// Last human
        
if (zp_get_user_last_human(victim)) continue;
        
        
client_print(0print_chat,"DEBUG: Infect!")

        
// Turn into zombie - BUGGY BULLSHIT
        
zp_infect_user(victimid01)
    }
}
//----------------------------------------------------------------------------------------------
// Infection Bomb: Green Blast
create_blast(const Float:originF[3])
{
    
// Smallest ring
    
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYoriginF0)
    
write_byte(TE_BEAMCYLINDER// TE id
    
engfunc(EngFunc_WriteCoordoriginF[0]) // x
    
engfunc(EngFunc_WriteCoordoriginF[1]) // y
    
engfunc(EngFunc_WriteCoordoriginF[2]) // z
    
engfunc(EngFunc_WriteCoordoriginF[0]) // x axis
    
engfunc(EngFunc_WriteCoordoriginF[1]) // y axis
    
engfunc(EngFunc_WriteCoordoriginF[2]+385.0// z axis
    
write_short(gSpriteGas// sprite
    
write_byte(0// startframe
    
write_byte(0// framerate
    
write_byte(4// life
    
write_byte(60// width
    
write_byte(0// noise
    
write_byte(0// red
    
write_byte(200// green
    
write_byte(0// blue
    
write_byte(200// brightness
    
write_byte(0// speed
    
message_end()
    
    
// Medium ring
    
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYoriginF0)
    
write_byte(TE_BEAMCYLINDER// TE id
    
engfunc(EngFunc_WriteCoordoriginF[0]) // x
    
engfunc(EngFunc_WriteCoordoriginF[1]) // y
    
engfunc(EngFunc_WriteCoordoriginF[2]) // z
    
engfunc(EngFunc_WriteCoordoriginF[0]) // x axis
    
engfunc(EngFunc_WriteCoordoriginF[1]) // y axis
    
engfunc(EngFunc_WriteCoordoriginF[2]+470.0// z axis
    
write_short(gSpriteGas// sprite
    
write_byte(0// startframe
    
write_byte(0// framerate
    
write_byte(4// life
    
write_byte(60// width
    
write_byte(0// noise
    
write_byte(0// red
    
write_byte(200// green
    
write_byte(0// blue
    
write_byte(200// brightness
    
write_byte(0// speed
    
message_end()
    
    
// Largest ring
    
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYoriginF0)
    
write_byte(TE_BEAMCYLINDER// TE id
    
engfunc(EngFunc_WriteCoordoriginF[0]) // x
    
engfunc(EngFunc_WriteCoordoriginF[1]) // y
    
engfunc(EngFunc_WriteCoordoriginF[2]) // z
    
engfunc(EngFunc_WriteCoordoriginF[0]) // x axis
    
engfunc(EngFunc_WriteCoordoriginF[1]) // y axis
    
engfunc(EngFunc_WriteCoordoriginF[2]+555.0// z axis
    
write_short(gSpriteGas// sprite
    
write_byte(0// startframe
    
write_byte(0// framerate
    
write_byte(4// life
    
write_byte(60// width
    
write_byte(0// noise
    
write_byte(0// red
    
write_byte(200// green
    
write_byte(0// blue
    
write_byte(200// brightness
    
write_byte(0// speed
    
message_end()

    
// Smoke
    
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYoriginF0)
    
write_byte(TE_SMOKE)        // 5
    
engfunc(EngFunc_WriteCoordoriginF[0])
    
engfunc(EngFunc_WriteCoordoriginF[1])
    
engfunc(EngFunc_WriteCoordoriginF[2])
    
write_short(gSpriteSmoke)
    
write_byte(10)        // scale in 0.1's
    
write_byte(10)        // framerate
    
message_end()

/*    // Smoke second?? untested
    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
    write_byte(TE_SMOKE)        // 5
    engfunc(EngFunc_WriteCoord, originF[0])
    engfunc(EngFunc_WriteCoord, originF[1]+10.0)
    engfunc(EngFunc_WriteCoord, originF[2]+10.0)
    write_short(gSpriteSmoke)
    write_byte(10)        // scale in 0.1's
    write_byte(10)        // framerate
    message_end()

    // Smoke third?? untested
    engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
    write_byte(TE_SMOKE)        // 5
    engfunc(EngFunc_WriteCoord, originF[0])
    engfunc(EngFunc_WriteCoord, originF[1]-10.0)
    engfunc(EngFunc_WriteCoord, originF[2]-10.0)
    write_short(gSpriteSmoke)
    write_byte(10)        // scale in 0.1's
    write_byte(10)        // framerate
    message_end()
*/
}
//----------------------------------------------------------------------------------------------
public EventDeathMsg()
{
    new 
victim read_data(2)
    
    if (
victim || victim MAXPLAYERS) return

    if (
gFuseTime[victim] > 0)
    {
        
// Delay to avoid recursion
        
set_task(0.1"infection_explode"victim)
    }
}
//----------------------------------------------------------------------------------------------
public client_connect(id)
{
    
gHasKamikaze[id] = false
    gFuseTime
[id] = 0
}
//----------------------------------------------------------------------------------------------
public client_disconnect(id)
{
    
gHasKamikaze[id] = false
    gFuseTime
[id] = 0
}
//---------------------------------------------------------------------------------------------- 


retribution 11-01-2009 03:12

Re: Help with ZP class pls!
 
I think I figured it out...thnx for viewing any way.


All times are GMT -4. The time now is 17:46.

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