Raised This Month: $ Target: $400
 0% 

Solved Zombie Plague: Redux [rewrite version]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
happy_2012
Senior Member
Join Date: Aug 2012
Old 05-31-2022 , 11:21   Zombie Plague: Redux [rewrite version]
Reply With Quote #1

Hello,

I am rewriting the original Zombie Plague 5.0.8a from scratch, with some changes in the code, and I am stuck with a problem that I am almost 100% sure I have done everything right, and I just can't seem to find what's wrong with the code that it bugs like that!

Latest source code is on both main and development branches:
- Main: https://github.com/theycallmeyuzdi/z...edux/tree/main
- Development: https://github.com/theycallmeyuzdi/z...ee/development
- Resource files: https://downloads.rvrealm.com/game-s...-resources.zip

The problem is basically as follows:
- When someone becomes the first zombie in an infection game mode, if they were killed, they spawn as zombie the next round although it has been reset
- When the first zombie infects other humans, the same problem will occur for them the next round, unless they terminate all humans
- When there are two players in the server, the one that is already zombie will stay as zombie, and the other player may turn into a zombie, no one can kill the other and the round won't end, and on the next round the two players will be zombies

Maybe a more experienced coder can help out? What's the problem? What did I do wrong? How to fix it?
__________________
Discord contacts:
I rarely look at private messages here, but I am very active on Discord!

Last edited by happy_2012; 06-03-2022 at 16:56. Reason: Added link to resource files
happy_2012 is offline
zXCaptainXz
Member
Join Date: May 2017
Old 05-31-2022 , 12:03   Re: Zombie Plague: Redux [rewrite version]
Reply With Quote #2

Hi, I would be happy to help but there's 3 problems with your request:
1. You're rewriting an (almost) perfectly fine version of ZP, any reason why you're doing that?
2. There are many sketchy parts in your code, I won't bother pointing them out if you don't give a good reason why you're re-writing ZP in the first place.
3. You should attach your resources (models/sounds/sprites) so we can test the plugin out at least...
zXCaptainXz is offline
happy_2012
Senior Member
Join Date: Aug 2012
Old 05-31-2022 , 12:24   Re: Zombie Plague: Redux [rewrite version]
Reply With Quote #3

Rewriting reasons:
1. Better and more extended API
2. Fixing bugs present in the original mode
3. Giving the plugin API and subplugins more customizability
4. Trying to make zombie classes and human classes more customizable by removing or adding necessary stuff to make it less unified and more diverse instead

Sketchy parts? Buggy parts? Just point them out, or your messages and replies are no good here! That's the whole reason I am posting a "Scripting Help", also if you don't like my "rewrite" version, then do not use it, simple!

Resource files: https://downloads.rvrealm.com/game-s...-resources.zip
__________________
Discord contacts:
I rarely look at private messages here, but I am very active on Discord!

Last edited by happy_2012; 05-31-2022 at 12:35.
happy_2012 is offline
zXCaptainXz
Member
Join Date: May 2017
Old 05-31-2022 , 14:39   Re: Zombie Plague: Redux [rewrite version]
Reply With Quote #4

PHP Code:
public zp_fw_core_cure_posti_Client /* , i_Attacker, i_Force */ )
{
    if( !
is_user_valid_alivei_Client ) )
    {
        return;
    }

You should not check if the user is alive in any of your plugins when calling the cure/infect forwards. Remove that check and it will solve your problem.
I didn't plan to use your version in the first place, I'm just trying to save you some time because I believe ZP 5.0.8a is perfect as it is (99% of the time). I will point out some mistakes you are making throughout your plugins though.

Ham spawn should be registered as post
PHP Code:
    RegisterHamHam_Spawn"player""fwHamSpawnPost"truetrue ); 
You should check if the user is alive, not connected in Ham_Spawn, or it will throw nefarious results

PHP Code:
public fwHamSpawnPosti_Client )
{
    if(
is_user_alive(i_Client)
    
bitsum_setg_bIsAlivei_Client );

Ham_Killed should be registered as Post
PHP Code:
RegisterHamHam_Killed"player""fwHamKilledPost"truetrue ); 
You should not check if the player is connected/alive in Ham_Killed
PHP Code:

public fwHamKilledPosti_Victimi_Attacker )
{
    
bitsum_delg_bIsAlivei_Victim );

Now in zp_game_mode_infection, apart of the fact that you are using pre not post for ham_killed
PHP Code:
public fwHamKilledPrei_Victim /* , i_Attacker */ )
{
    if( 
g_iGMPlayer == i_Victim )
    {
        
g_iGMPlayer ftGetRandomAliverandom_num1ftGetCountAlive( ) ) );
    }

This code does literally nothing, only a bunch of useless calculations.

I doubt this is all that's wrong in there, you should avoid unnecessary checks and look up how to do things the proper way, or things will be prone to fail. If you don't know where to look, then ZP50 source code is a great place to start.
zXCaptainXz is offline
happy_2012
Senior Member
Join Date: Aug 2012
Old 05-31-2022 , 16:45   Re: Zombie Plague: Redux [rewrite version]
Reply With Quote #5

Thank you so very much, pointing out my mistakes taught me better coding and fixed the bug!

Updated the code on GitHub!
__________________
Discord contacts:
I rarely look at private messages here, but I am very active on Discord!

Last edited by happy_2012; 05-31-2022 at 16:46.
happy_2012 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 19:25.


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