Raised This Month: $32 Target: $400
 8% 

Help / Support [ZP 5.0] zp_infect_user to specific class


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dinogust
Member
Join Date: Jun 2009
Old 12-10-2021 , 10:44   [ZP 5.0] zp_infect_user to specific class
Reply With Quote #1

Is there any way to force someone to turns into specific zombie class? something that supersede their own zombie choice. In this case i want to use it for bot, in my case zp's own randomizing bot class picker overwrites the zp_set_user_zombie_class that i set and makes the bots turns into random zombie instad.
dinogust is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 12-13-2021 , 03:01   Re: [ZP 5.0] zp_infect_user to specific class
Reply With Quote #2

you can random between 0 and the total zombie class and then set that id at zp_user_infected_pre

PHP Code:
new iTotalClass zp_class_zombie_get_count() //Get total number of Zombie class 
new iRandomClass random_num(0iTotalClass 1//Get random number of classid.
zp_set_user_zombie_class(idiRandomClass
for 4.3, g_zclass_i is the total class counter.
__________________
My plugin:
Celena Luna is offline
TribalBlood
Member
Join Date: Oct 2020
Old 12-13-2021 , 10:38   Re: [ZP 5.0] zp_infect_user to specific class
Reply With Quote #3

zp_user_infected_pre(id, infector, nemesis)

new maxclass = [How many zombie classes have] - 1
zp_set_user_zombie_class(id, random_num(0, maxclass))
__________________
My Steam Profile

- Online Rarely -
TribalBlood is offline
dinogust
Member
Join Date: Jun 2009
Old 12-15-2021 , 12:08   Re: [ZP 5.0] zp_infect_user to specific class
Reply With Quote #4

i dont want to make the bot choose random zombie class, i want them to be the only specific class i want (e.g. all bots choose x zombie)
dinogust is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 12-15-2021 , 21:30   Re: [ZP 5.0] zp_infect_user to specific class
Reply With Quote #5

Quote:
Originally Posted by dinogust View Post
i dont want to make the bot choose random zombie class, i want them to be the only specific class i want (e.g. all bots choose x zombie)
you can check if the player is bot or not and set zombie class at zp_user_infected_pre
__________________
My plugin:
Celena Luna is offline
dinogust
Member
Join Date: Jun 2009
Old 12-16-2021 , 00:40   Re: [ZP 5.0] zp_infect_user to specific class
Reply With Quote #6

i did, as i said zp50_class_zombie has its own class randomizer for bots that overwrite zp_set_user_zombie
dinogust is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 12-16-2021 , 03:18   Re: [ZP 5.0] zp_infect_user to specific class
Reply With Quote #7

Quote:
Originally Posted by dinogust View Post
i did, as i said zp50_class_zombie has its own class randomizer for bots that overwrite zp_set_user_zombie
I just check zp50_class_zombie and I think the only way is to move this highlight part

Code:
public zp_fw_core_infect_post(id, attacker) {     // Show zombie class menu if they haven't chosen any (e.g. just connected)     if (g_ZombieClassNext[id] == ZP_INVALID_ZOMBIE_CLASS)     {         if (g_ZombieClassCount > 1)             show_menu_zombieclass(id)         else // If only one class is registered, choose it automatically             g_ZombieClassNext[id] = 0     }         // Bots pick class automatically
    if (is_user_bot(id))
    {
        // Try choosing class
        new index, start_index = random_num(0, g_ZombieClassCount - 1)
        for (index = start_index + 1; /* no condition */; index++)
        {
            // Start over when we reach the end
            if (index >= g_ZombieClassCount)
                index = 0
           
            // Execute class select attempt forward
            ExecuteForward(g_Forwards[FW_CLASS_SELECT_PRE], g_ForwardResult, id, index)
           
            // Class available to player?
            if (g_ForwardResult < ZP_CLASS_NOT_AVAILABLE)
            {
                g_ZombieClassNext[id] = index
                break;
            }
           
            // Loop completed, no class could be chosen
            if (index == start_index)
                break;
        }
    }
    // Set selected zombie class. If none selected yet, use the first one     g_ZombieClass[id] = g_ZombieClassNext[id]     if (g_ZombieClass[id] == ZP_INVALID_ZOMBIE_CLASS) g_ZombieClass[id] = 0         // Apply zombie attributes     set_user_health(id, ArrayGetCell(g_ZombieClassHealth, g_ZombieClass[id]))     set_user_gravity(id, Float:ArrayGetCell(g_ZombieClassGravity, g_ZombieClass[id]))     cs_set_player_maxspeed_auto(id, Float:ArrayGetCell(g_ZombieClassSpeed, g_ZombieClass[id]))

to zp_fw_core_infect_pre (if zp_fw_core_infect_pre didn't exist, just copy this one below)

PHP Code:
public zp_fw_core_infect_pre(idattacker)
{
    
// Bots pick class automatically
    
if (is_user_bot(id))
    {
        
// Try choosing class
        
new indexstart_index random_num(0g_ZombieClassCount 1)
        for (
index start_index 1/* no condition */index++)
        {
            
// Start over when we reach the end
            
if (index >= g_ZombieClassCount)
                
index 0
            
            
// Execute class select attempt forward
            
ExecuteForward(g_Forwards[FW_CLASS_SELECT_PRE], g_ForwardResultidindex)
            
            
// Class available to player?
            
if (g_ForwardResult ZP_CLASS_NOT_AVAILABLE)
            {
                
g_ZombieClassNext[id] = index
                
break;
            }
            
            
// Loop completed, no class could be chosen
            
if (index == start_index)
                break;
        }
    }
}

Then if you want to set specific class, you can set it in zp_fw_core_infect(can be use in other plugins outside zp50_class_zombie)
PHP Code:
public zp_fw_core_infect(idattacker)
{
    
zp_set_user_zombie_class(idiRandomClass)

Explain stuff (if you don't understand)
Spoiler
__________________
My plugin:

Last edited by Celena Luna; 12-16-2021 at 03:38.
Celena Luna is offline
dinogust
Member
Join Date: Jun 2009
Old 12-16-2021 , 06:48   Re: [ZP 5.0] zp_infect_user to specific class
Reply With Quote #8

Thanks luna, i'll be testing that tomorrow, im sure it will work. Also do we have something that makes you spawn as zombie right away? For example if someone's dead, i want to revive him but as a zombie. Found Ham_CS_RoundRespawn but it spawns you as human. Will cs_set_user_team work with zp?
dinogust is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 12-16-2021 , 11:07   Re: [ZP 5.0] zp_infect_user to specific class
Reply With Quote #9

Quote:
Originally Posted by dinogust View Post
Will cs_set_user_team work with zp?
It will only move you to Terrorist, you will have to MANUALLY set all the info like HP, speed,.... Not to mention all the forward from ZP won't execute too
__________________
My plugin:
Celena Luna is offline
dinogust
Member
Join Date: Jun 2009
Old 12-16-2021 , 14:46   Re: [ZP 5.0] zp_infect_user to specific class
Reply With Quote #10

so there is no way to spawn someone as a zombie, you gotta Ham_CS_RoundRespawn then zp_infect_user?
dinogust is offline
Reply


Thread Tools
Display Modes

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 11:31.


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