Post by Morgoneth on Mar 3, 2023 16:41:45 GMT
Hi guys, I have a bug with this class
After I left the server, I join another server and the force duck effect still continues to affect me, how do I fix this bug? Please help me
After I left the server, I join another server and the force duck effect still continues to affect me, how do I fix this bug? Please help me
/*================================================================================
----------------------------------
-*- [ZP] Zombie Class: Crawler -*-
----------------------------------
~~~~~~~~~~~~~~~
- Description -
~~~~~~~~~~~~~~~
This zombie class is Full-Time Duck. What does it mean? The player that
selects this class will crouch all the time while zombie.
Health has been lowered, speed has been increased due to crouching,
gravity has been lowered too and knockback set a little bit higher.
Original forum thread: http://forums.alliedmods.net/showthread.php?t=123479
~~~~~~~~~~~~~
- Thanks to -
~~~~~~~~~~~~~
Sam Tsuki - For the code from his "Head Crab Me" mod
MeRcyLeZZ - For such an awesome mod like "Zombie Plague"
and for some code i used from it
Fry!, lucas_7_94 - For helping me make this plugin
wrecked_ - For helping me optimize the plugin
fezh - For answering me some important coding questions
re333 - For feedback
WelcomE~ - For providing a model for this class
suNx - For supporting me all the time. <3 u bro!
And all my real friends out there...
~~~~~~~~~~~~~
- Changelog -
~~~~~~~~~~~~~
* v1.0 (5 Apr 2010)
- First release
* v1.1 (6 Apr 2010)
- Optimized some code (10x to wrecked_)
- Fixed a bug where players that have this class
remain crouched after round end (on round start)
* v1.2 (14 Apr 2010)
- Optimized some code (thanks to wrecked_ again)
- Finally fixed the duck bug...for good (not really)
* v1.3 (19 Apr 2010)
- Totally rewritten the plugin
- Added code to set clients' speeds to the zombie
class' speed and to prevent the server from
limiting the zombie's speed.
Also the client is attetioned about the cvars value
changes since i couldn't come up with a temporary
memory code solution to remember his original values
and then restore them back on client disconnect.
Any help is welcome...
- Unducking a player is now coded as a task
- Added some more support for bots
- Fixed the duck bug...let's hope this time i'm right
(tested and there are no more problems)
* v1.4 (24 Apr 2010)
- Removed bot support. Can't set MaxSpeed 'cause ZP main
plugin is allready setting it in PreThink
- Added support for reconnecting and map change
================================================================================*/
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
// Zombie Attributes
new const zclass_name[] = "Crawl Zombie" // name
new const zclass_info[] = "Full-Time Duck" // description
new const zclass_model[] = "zombie_source" // model
new const zclass_clawmodel[] = "v_knife_zombie.mdl" // claw model
const zclass_health = 957 // health
const zclass_speed = 975 // speed
const Float:zclass_gravity = 0.5 // gravity
const Float:zclass_knockback = 1.15 // knockback
// Class IDs
new g_zcrawl
// Player is ducked
new g_ducked[33]
// Get server's max players and speed | Create a custom chat print
new g_maxplayers, g_maxspeed, g_msgSayText
public plugin_init()
{
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
register_logevent("logevent_round_end", 2, "1=Round_End")
register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
g_maxplayers = get_maxplayers()
g_maxspeed = get_cvar_pointer("sv_maxspeed")
g_msgSayText = get_user_msgid("SayText")
}
// Zombie Classes MUST be registered on plugin_precache
public plugin_precache()
{
register_plugin("[ZP] Zombie Class: Crawler", "1.4", "93()|29!/<")
// Register the new class and store ID for reference
g_zcrawl = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)
}
// User Infected forward
public zp_user_infected_post(id, infector, nemesis)
{
// Check if the player has been turned into nemesis
if (nemesis)
{
// Get up
unduck_player(id)
g_ducked[id] = false
return;
}
if (zp_get_user_zombie_class(id) != g_zcrawl)
{
g_ducked[id] = false
return;
}
client_cmd(id, "cl_forwardspeed %d; cl_backspeed %d; cl_sidespeed %d", Float:zclass_speed, Float:zclass_speed, Float:zclass_speed)
zp_colored_print(id, "^x04[ZP]^x03 Attention!^x01 The following client cvar values have been set conforming to")
zp_colored_print(id, "^x04[ZP]^x01 this zombie class' speed:^x04 cl_forwardspeed^x01,^x04 cl_backspeed^x01,^x04 cl_sidespeed")
g_ducked[id] = true
}
// User Humanized forward
public zp_user_humanized_post(id, survivor)
{
// Stand up
unduck_player(id)
g_ducked[id] = false
}
// Player has just connected/reconnected
public client_connect(id)
{
g_ducked[id] = false
}
// Client is disconnecting
public client_disconnect(id)
{
// Stop ducking
unduck_player(id)
}
// Forward Player PreThink
public fw_PlayerPreThink(id)
{
// Checks...
if (zp_get_user_nemesis(id) || !zp_get_user_zombie(id) || is_user_bot(id)
|| zp_get_user_zombie_class(id) != g_zcrawl || !is_user_alive(id))
return;
// Make the player crouch
set_pev(id, pev_bInDuck, 1)
client_cmd(id, "+duck")
g_ducked[id] = true
}
// Ham Player Killed Forward
public fw_PlayerKilled(id)
{
// Make the player stand up
unduck_player(id)
g_ducked[id] = false
}
// Log Event Round End
public logevent_round_end()
{
static id
for (id = 1; id <= g_maxplayers; id++)
{
// Some extra checks on round end aren't bad...i think
if (zp_get_user_nemesis(id) || !zp_get_user_zombie(id) || zp_get_user_zombie_class(id) != g_zcrawl || !is_user_alive(id))
g_ducked[id] = false
else
g_ducked[id] = true
}
}
// Event Round Start
public event_round_start()
{
// Make sure the server isn't blocking our zombie's speed
if (get_pcvar_float(g_maxspeed) < Float:zclass_speed)
server_cmd("sv_maxspeed 99999") // Better than setting it to the zombie speed value
static id
for (id = 1; id <= g_maxplayers; id++)
{
// Get the hell up
unduck_player(id)
g_ducked[id] = false
}
}
// Make the player stand up
public unduck_player(id)
{
// Isn't ducked | Is a bot
if (!g_ducked[id] || is_user_bot(id))
return;
set_pev(id, pev_bInDuck, 0)
client_cmd(id, "-duck")
client_cmd(id, "-duck") // Prevent death spectator camera bug
}
// Colored chat print. Thanks to MeRcyLeZZ
zp_colored_print(target, const message[], any:...)
{
static buffer[512], i, argscount
argscount = numargs()
// Send to everyone
if (!target)
{
static player
for (player = 1; player <= g_maxplayers; player++)
{
// Not connected
if (!is_user_connected(player))
continue;
// Remember changed arguments
static changed[5], changedcount // [5] = max LANG_PLAYER occurencies
changedcount = 0
// Replace LANG_PLAYER with player id
for (i = 2; i < argscount; i++)
{
if (getarg(i) == LANG_PLAYER)
{
setarg(i, 0, player)
changed[changedcount] = i
changedcount++
}
}
// Format message for player
vformat(buffer, charsmax(buffer), message, 3)
// Send it
message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, player)
write_byte(player)
write_string(buffer)
message_end()
// Replace back player id's with LANG_PLAYER
for (i = 0; i < changedcount; i++)
setarg(changed[i], 0, LANG_PLAYER)
}
}
// Send to specific target
else
{
// Format message for player
vformat(buffer, charsmax(buffer), message, 3)
// Send it
message_begin(MSG_ONE, g_msgSayText, _, target)
write_byte(target)
write_string(buffer)
message_end()
}
}