Raised This Month: $51 Target: $400
 12% 

API Scripting Help [ZP 5.0] Extra Class: [Admin]Headcrab


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Y060N
BANNED
Join Date: Dec 2011
Location: www.equilibriumcs.com
Old 01-04-2012 , 20:05   [ZP 5.0] Extra Class: [Admin]Headcrab
Reply With Quote #1

Hey guys, trying to convert over Aaarnas' headcrab for ZM 4.3 with some failure.

Here's my sma:

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <fun>
#include <zombieplague>
#include <zp50_class_nemesis>
#include <zp50_class_zombie>

#define VERSION "1.0"

new const zclass_name[] = { "[Admin]Headcrab" }
new const 
zclass_info[] = { "Small and fast" }
new const 
zclass_model[][] = { "headcrab" }
new const 
zclass_clawmodel[][] = { "models/zombie_plague/v_headcrab.mdl" }
const 
zclass_health 1100
const Float:zclass_speed 7.5
const Float:zclass_gravity 0.65
const Float:zclass_knockback 2.5

new g_zclass_crab
new g_headcrab[33][2]

public 
plugin_precache()
{
    
register_plugin("[Admin]Headcrab"VERSION"aaarnas")

    new 
index

    g_zclass_crab 
zp_class_zombie_register(zclass_namezclass_infozclass_healthzclass_speedzclass_gravity)
    
zp_class_zombie_register_kb(g_zclass_crabzclass_knockback)
    
    for (
index 0index sizeof zclass_modelindex++)
        
zp_class_zombie_register_model(g_zclass_crabzclass_model[index])
    for (
index 0index sizeof zclass_clawmodelindex++)
        
zp_class_zombie_register_claw(g_zclass_crabzclass_clawmodel[index])
}

public 
zp_fw_class_zombie_select_pre(id,cid)
{
    if(
cid == g_zclass_crab)
    {
        if(!
is_user_admin(id))
            return 
ZP_CLASS_NOT_AVAILABLE
    
}
    return 
ZP_CLASS_AVAILABLE
}

public 
plugin_init()
{    
    
register_cvar("zp_headcrab_version"VERSIONFCVAR_SERVER|FCVAR_SPONLY)
    
set_cvar_string("zp_headcrab_version"VERSION)
    
RegisterHam(Ham_Spawn"player""FwdHamPlayerSpawnPost")
    
RegisterHam(Ham_Killed"player""fw_PlayerKilled")
}
public 
client_connect(id)
{
    
g_headcrab[id][0] = false
    g_headcrab
[id][1] = false
}    
public 
client_disconnect(id)
{
    
g_headcrab[id][0] = false
    g_headcrab
[id][1] = false
    set_pev
(idpev_bInDuck0)
    
client_cmd(id"-duck")
}
public 
FwdHamPlayerSpawnPost(id)
{
    if(
g_headcrab[id][0]) {
        
g_headcrab[id][0] = false
        set_user_hitzones
(0id255)
        
set_pev(idpev_bInDuck0)
        
client_cmd(id"-duck")
    }
    if(
g_headcrab[id][1]) {
        
set_user_hitzones(0id255)
        
g_headcrab[id][1] = false
    
}
}
public 
fw_PlayerKilled(id)
{
    if(
g_headcrab[id][0]) {
        
g_headcrab[id][0] = false
        set_user_hitzones
(0id255)
        
client_cmd(id"cl_forwardspeed 400; cl_backspeed 400; cl_sidespeed 400")
        
set_pev(idpev_bInDuck0)
        
client_cmd(id"-duck")
    }
}

public 
zp_user_infect_attempt(id) {
    
    if(
is_user_bot(id))
        
zp_set_user_zombie_class(id0)
}
public 
zp_user_infected_post(idinfector)
{        
    if(
zp_class_zombie_get_current(id) == g_zclass_crab && !zp_class_nemesis_get(id)) {
        
client_cmd(id"speak sound/headcrab/hc_headbite")
        
g_headcrab[id][0] = true
        g_headcrab
[id][1] = true
        client_cmd
(id"cl_forwardspeed 2000; cl_backspeed 2000; cl_sidespeed 2000")
        
set_pev(idpev_bInDuck1)
        
console_cmd(id"+duck")
        
set_user_hitzones(0id200)
        
set_user_footsteps(id1)
    }
    else if(
zp_class_zombie_get_current(id) == g_zclass_crab) {
        
g_headcrab[id][0] = false
        set_user_hitzones
(0id255)
        
set_pev(idpev_bInDuck0)
        
client_cmd(id"-duck")
    }
    else 
g_headcrab[id][0] = false
}
public 
zp_user_humanized_post(id)
{
    
g_headcrab[id][0] = false
    set_user_hitzones
(0id255)
    
client_cmd(id"cl_forwardspeed 400; cl_backspeed 400; cl_sidespeed 400")
    
set_pev(idpev_bInDuck0)
    
client_cmd(id"-duck")
}
public 
client_PreThink(id)
{
    if(
g_headcrab[id][0]) {
        
set_pev(idpev_bInDuck1)
        
console_cmd(id"+duck")
    }

and here is what happens:

PHP Code:
[[Admin]Headcrab]
NAME = [Admin]Headcrab

[[Admin]Headcrab]
INFO Small and fast

[[Admin]Headcrab]
MODELS zombie

[[Admin]Headcrab]
CLAWMODEL models/zombie_plague/v_knife_zombie.mdl

[[Admin]Headcrab]
HEALTH 1100

[[Admin]Headcrab]
SPEED 7.50

[[Admin]Headcrab]
GRAVITY 0.64

[[Admin]Headcrab]
KNOCKBACK 1.00

[[Admin]Headcrab]
KNOCKBACK 2.50

[[Admin]Headcrab]
MODELS headcrab

[[Admin]Headcrab]
CLAWMODEL models/zombie_plague/v_headcrab.mdl 
So it is registering it multiple times for each line, and I don't get why it is doing that. It is an admin only plugin, but it shouldn't be the issue.

This causes the headcrab to walk extremely slow (since it's crouched position).

If anyone could help I'd appreciate it
Y060N is offline
H.RED.ZONE
Veteran Member
Join Date: Sep 2011
Location: Serbia, Belgrade
Old 01-05-2012 , 00:05   Re: [ZP 5.0] Extra Class: [Admin]Headcrab
Reply With Quote #2

Quote:
Originally Posted by aaarnas View Post
This plugin has no bugs(or if found one, please tell me ). Except one thing. After server start change map or restart server. It fix the problem, that crab don't have speed as set.
[/CODE]
You mean this problem?
__________________
H.RED.ZONE is offline
Y060N
BANNED
Join Date: Dec 2011
Location: www.equilibriumcs.com
Old 01-05-2012 , 00:11   Re: [ZP 5.0] Extra Class: [Admin]Headcrab
Reply With Quote #3

Indeed, I obviously can't read LOL. I will try that ;)
Y060N is offline
H.RED.ZONE
Veteran Member
Join Date: Sep 2011
Location: Serbia, Belgrade
Old 01-05-2012 , 01:26   Re: [ZP 5.0] Extra Class: [Admin]Headcrab
Reply With Quote #4

I think this should remove the speed bug.
Attached Files
File Type: sma Get Plugin or Get Source (zp5.0_headcrab_admin_only.sma - 645 views - 3.6 KB)
__________________
H.RED.ZONE is offline
Y060N
BANNED
Join Date: Dec 2011
Location: www.equilibriumcs.com
Old 01-05-2012 , 03:47   Re: [ZP 5.0] Extra Class: [Admin]Headcrab
Reply With Quote #5

It didn't. Anyone else got any insight?
Y060N is offline
Y060N
BANNED
Join Date: Dec 2011
Location: www.equilibriumcs.com
Old 01-06-2012 , 04:34   Re: [ZP 5.0] Extra Class: [Admin]Headcrab
Reply With Quote #6

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <fun>
#include <zombieplague>
#include <zp50_class_nemesis>
#include <zp50_class_zombie>

#define VERSION "1.0"

new const zclass_name[] = { "[Admin]Headcrab" }
new const 
zclass_info[] = { "Small and fast" }
new const 
zclass_model[][] = { "headcrab" }
new const 
zclass_clawmodel[][] = { "models/zombie_plague/v_headcrab.mdl" }
const 
zclass_health 1100
const Float:zclass_speed 2.2
const Float:zclass_gravity 0.75
const Float:zclass_knockback 2.5

new g_zclass_crab

public plugin_precache()
{
    
register_plugin("[Admin]Headcrab"VERSION"Aaarnas")

    new 
index

    g_zclass_crab 
zp_class_zombie_register(zclass_namezclass_infozclass_healthzclass_speed

zclass_gravity)
    
zp_class_zombie_register_kb(g_zclass_crabzclass_knockback)
    
    for (
index 0index sizeof zclass_modelindex++)
        
zp_class_zombie_register_model(g_zclass_crabzclass_model[index])
    for (
index 0index sizeof zclass_clawmodelindex++)
        
zp_class_zombie_register_claw(g_zclass_crabzclass_clawmodel[index])
}

public 
zp_fw_class_zombie_select_pre(id,cid)
{
    if(
cid == g_zclass_crab)
    {
        if(!
is_user_admin(id))
            return 
ZP_CLASS_NOT_AVAILABLE
    
}
    return 
ZP_CLASS_AVAILABLE
}

public 
plugin_init()
{    
    
register_cvar("zp_headcrab_version"VERSIONFCVAR_SERVER|FCVAR_SPONLY)
    
set_cvar_string("zp_headcrab_version"VERSION)
    
RegisterHam(Ham_Spawn"player""FwdHamPlayerSpawnPost")
    
RegisterHam(Ham_Killed"player""fw_PlayerKilled")
}

public 
FwdHamPlayerSpawnPost(id)
{
    
set_user_hitzones(0id255)
}

public 
fw_PlayerKilled(id)
{
    
set_user_hitzones(0id255)
}

public 
zp_user_infected_post(idinfector)
{        
    if(
zp_class_zombie_get_current(id) == g_zclass_crab && !zp_class_nemesis_get(id)) {
        
client_cmd(id"speak sound/headcrab/hc_headbite")
        
set_user_hitzones(0id200)
    }

    else {
    
set_user_hitzones(0id255)
    }
}

public 
zp_user_humanized_post(id)
{
    
set_user_hitzones(0id255)

Am I under the correct assumption that these commands are only used when a player has this class selected? If so, then I removed the whole system where it checks to see if the array values are true or false. It just sets the hitboxes straight back to normal. If this isn't the case then this code is extremely inefficient right now as it will set all the players hitboxes to what they are currently set to. If that IS the case, though, can I check if a user has the class selected using zp_class_zombie_get_current(id) when they are human?

I haven't tested this as my live server is full, but will soon.
Y060N is offline
JoKeR LauGh
Veteran Member
Join Date: May 2011
Location: Malaysia
Old 01-06-2012 , 04:56   Re: [ZP 5.0] Extra Class: [Admin]Headcrab
Reply With Quote #7

remove
PHP Code:
#include <zombieplague> 
__________________
Quote:
Originally Posted by addons_zz View Post
Also, just to not read `the article`, read all you find. Read and read, for ever and ever. Never stop reading.
Why? Because there is not one single universal truth which holds the meaning for everything.
JoKeR LauGh is offline
Isaac999
Senior Member
Join Date: Nov 2011
Location: Home
Old 01-06-2012 , 07:08   Re: [ZP 5.0] Extra Class: [Admin]Headcrab
Reply With Quote #8

I think you should remove [ADMIN] or change it to (ADMIN)
__________________
Isaac999 is offline
Y060N
BANNED
Join Date: Dec 2011
Location: www.equilibriumcs.com
Old 01-06-2012 , 10:37   Re: [ZP 5.0] Extra Class: [Admin]Headcrab
Reply With Quote #9

Quote:
Originally Posted by JoKeR LauGh View Post
remove
PHP Code:
#include <zombieplague> 
Thanks

And the name matches all the other messages/name of my server ;)

Last edited by Y060N; 01-06-2012 at 10:55.
Y060N is offline
MeRcyLeZZ
Veteran Member
Join Date: Dec 2007
Old 01-09-2012 , 10:50   Re: [ZP 5.0] Extra Class: [Admin]Headcrab
Reply With Quote #10

Quote:
Originally Posted by Isaac999 View Post
I think you should remove [ADMIN] or change it to (ADMIN)
Yep, ZP Settings API still needs to have that fixed...
__________________
MeRcyLeZZ is offline
Reply



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 13:09.


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