The codes i will show in this thread are codes meant to be used as mods in the source code of ZP, not to be compiled as separated plugins.
The codes are supposed to add a function that will make the radius around the center of the explosion of the infection grenade to be infective for X seconds, infecting humans who go inside this radius. Is this what the codes actually do, or are the codes just generalized codes that aren't specialized and are dysfunctional (not working)?
Here are the two codes:
Code:
new const Float:INFECTION_RADIUS = 200.0; // Adjust the radius as needed
public plugin_init()
{
register_event("DeathMsg", "event_death", "b");
}
public event_death(victim, attacker, weapon)
{
if (get_user_team(attacker) == CS_TEAM_ZOMBIE && weapon == ZP_WEAPON_INFECTION_GRENADE)
{
create_harmful_cloud(get_user_origin(attacker), INFECTION_RADIUS);
infect_nearby_players(get_user_origin(attacker), INFECTION_RADIUS);
}
return PLUGIN_CONTINUE;
}
public create_harmful_cloud(position[], radius)
{
new entity = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
engfunc(EngFunc_SetOrigin, entity, position);
engfunc(EngFunc_SetModel, entity, "sprites/green_cloud.spr"); // Replace with the path to your green cloud sprite file
engfunc(EngFunc_SetSize, entity, Vector(-radius, -radius, -radius), Vector(radius, radius, radius));
engfunc(EngFunc_SetRenderColor, entity, 0, 255, 0); // Adjust the color as desired
set_task(10.0, "remove_harmful_cloud", entity); // Remove the cloud after 10 seconds
}
public remove_harmful_cloud(entity)
{
engfunc(EngFunc_RemoveEntity, entity);
}
public infect_nearby_players(position[], radius)
{
new Float:origin[3], distance;
for (new i = 1; i <= get_max_players(); i++)
{
if (!is_user_connected(i) || get_user_team(i) != CS_TEAM_TERRORIST)
continue;
get_user_origin(i, origin);
distance = get_distance(position, origin);
if (distance <= radius)
{
set_user_team(i, CS_TEAM_ZOMBIE, true); // Infect the player
set_user_godmode(i, true); // Make the infected player invulnerable temporarily
set_task(10.0, "reset_godmode", i); // Reset the godmode after 10 seconds
}
}
}
public reset_godmode(player)
{
set_user_godmode(player, false); // Reset godmode
}
Here is the second code:
Code:
new const Float:INFECTION_RADIUS = 200.0; // Adjust the radius as needed
public plugin_init()
{
register_event("DeathMsg", "event_death", "b");
}
public event_death(victim, attacker, weapon)
{
if (get_user_team(attacker) == CS_TEAM_ZOMBIE && weapon == ZP_WEAPON_INFECTION_GRENADE)
{
infect_nearby_players(get_user_origin(attacker), INFECTION_RADIUS);
set_task(10.0, "reset_infected_players");
}
return PLUGIN_CONTINUE;
}
public infect_nearby_players(position[], radius)
{
new Float:origin[3], distance;
for (new i = 1; i <= get_max_players(); i++)
{
if (!is_user_connected(i) || get_user_team(i) != CS_TEAM_TERRORIST)
continue;
get_user_origin(i, origin);
distance = get_distance(position, origin);
if (distance <= radius)
{
set_user_team(i, CS_TEAM_ZOMBIE, true); // Infect the player
set_user_godmode(i, true); // Make the infected player invulnerable temporarily
set_task(10.0, "reset_godmode", i); // Reset the godmode after 10 seconds
}
}
}
public reset_godmode(player)
{
set_user_godmode(player, false); // Reset godmode
}
public reset_infected_players()
{
for (new i = 1; i <= get_max_players(); i++)
{
if (!is_user_connected(i) || get_user_team(i) != CS_TEAM_ZOMBIE)
continue;
set_user_team(i, CS_TEAM_TERRORIST, true); // Reset infected players to human team
}
}