Plug-ins compatibility with Zombie Escape 1.x only!
-
Night Fury
- Mod Developer
- Posts: 677
- Joined: 7 years ago
-
Contact:
-
Quote
-
0
login to like this post
#1
Post
by Night Fury » 5 years ago
| Description:
- This plugin is going to replace the disconnected player' with another randomly chosen player to be the zombie/human instead of his place.
| Code:
#include <zombie_escape>
public plugin_init()
{
register_plugin("[ZE] Addon: Replace disconnected players", "1.0", "Jack")
}
public ze_player_disconnect(id)
{
// Game wasn't started? || Wasn't alive? || Last player?
if (!ze_is_game_started() || !is_user_alive(id) || GetAllAlivePlayersNum() <= 1)
return 0; // Continue
// We are in freeze time?
if (!get_member_game(m_bFreezePeriod))
{
new iIndex
// Last Zombie
if (ze_is_user_zombie(id) && ze_get_zombies_number() == 1)
{
if (ze_get_humans_number() == 1)
return 0; // Continue
// Find replacement
while ((iIndex = GetRandomAlive(random_num(1, ze_get_humans_number()))) == id) { /* keep looping */ }
new name[32]
get_user_name(iIndex, name, charsmax(name))
ze_colored_print(0, "!tThe last zombie has left!y. !g%s !thas been the new zombie!y.", name)
ze_set_user_zombie(iIndex)
UpdateOrigin(iIndex, id)
return 1; // Stop main function
}
// Last Human
else if (!ze_is_user_zombie(id) && ze_get_humans_number() == 1)
{
if (ze_get_zombies_number() == 1)
return 0;
// Find replacement
while ((iIndex = GetRandomAlive(random_num(1, ze_get_zombies_number()))) == id) { /* keep looping */ }
new name[32]
get_user_name(iIndex, name, charsmax(name))
ze_colored_print(0, "!tThe last human has left!y. !g%s !thas been the new human!y.", name)
ze_set_user_human(iIndex)
UpdateOrigin(iIndex, id)
return 1; // Stop main function
}
}
return 0; // Continue
}
UpdateOrigin(iIndex, id)
{
new Float:flOrigin[3]
get_entvar(id, var_origin, flOrigin)
set_entvar(iIndex, var_origin, flOrigin)
}
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
-
th3_king
- VIP
- Posts: 35
- Joined: 6 years ago
- Location: Egypt
-
Contact:
-
Quote
-
0
login to like this post
#2
Post
by th3_king » 5 years ago
Good Work,
New Idea: Better than choosing randomly, >> Choose the player who has the lowest played time << You can also make the both Ideas ( Random Choose And My Idea with Cvar ).
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute
Register
Sign in
Users browsing this forum: No registered users and 0 guests