Author Topic: Overall Coding Help Needed for My Project  (Read 3213 times)

Hello. I am working on a gamemode called Zombie Survival. Zombie Survival is a gamemode where there are two teams, survivors and zombies. Survivors become zombies when they die. The round is 20 mins and is divided into 5 waves. Each wave last 4 mins. At the end of every wave, zombies are given something new to make them stronger. If at-least one survivor is alive after 5 rounds, the survivors win. The game features barricade upgrades, creepy surroundings, weapon shot, purchasable ammo crates, you name it.

I am still a noob coder and I needed some help. I have quite a few things so I put it in one thread.

1: I need to know how to have variables in prints.
2: I need to know how to make zombies stronger (change some inventory items) after a wave (Rounds are not using prints, they are using code.)
3: I need to know how to make my script reset on mini reset
4: I need to know how to make my loop play once the round has started.
Edit: I also need a way for the print to display what team your on.


Thanks you in advance if you help me out at all! If you do I will add your name to the credits list of the gamemode.


Current Code of Script:

Code: [Select]
function StartZombieSurvival(%client)
{
    if(%client.isAdmin)
    {
     %count = ClientGroup.getCount();
   for(%cl = 0; %cl < %count; %cl++)
   {
    %clientB = ClientGroup.getObject(%cl);
    %clientB.centerPrint("<font:impact:50><color:f420eb>Zombie Survival round begins in 30 seconds! Prepare yourself!",5);
   }
%time = 30;
serTimer(%time);
    }

    else
    {
messageClient(%client, '', '\c6Only Admins can Start Zombie Survival!');
    }
}

function serTimer(%time)
{
if (%time <= 0)
{
%count = ClientGroup.getCount();
   for(%cl = 0; %cl < %count; %cl++)
   {
    %clientB = ClientGroup.getObject(%cl);
    %clientB.centerPrint("<font:impact:50><color:f420eb>The next wave has begun!",5);
%clientB.bottomPrint("<color:f420eb>Wave: <color:ffffff>1 <color:1818ba>You are a <color:FFA500>Survivor");
   }
}
else
{
%time--;

$TimerSchedule = schedule(1000, 0, "serTimer", %time);
}
}

The code has been tested as a serverCMD Command.

« Last Edit: February 08, 2015, 07:03:04 PM by rggbnnnnn »

Edit: Here is an album of the gamemode to show what I am working with here:
http://imgur.com/a/93jTM

Double Edit: The Map is Darker in Final Version without Shaders.

Instead of looping through all the clients in the server to message them something you can just use commandToAll('centerPrint', "hello"); You can also use bottomPrint for the command.

I don't really know what you meant by variables in prints, but if you mean the center/bottomPrints you can do it like this: %clientB.bottomPrint("hello" SPC %variable);
SPC - Makes a space in between your text and the variable
@ - Just connects the variable, no spaces.
NL - Connects them but adds another line.
You can look at this to learn more about strings and variables.

If you're using Slayer you can package/parent the function function Slayer_MinigameSO::onReset(%this) and anything you do after you parent it will happen after the minigame resets.

As for displaying what team you are on you can use %client.getTeam().name;
« Last Edit: February 08, 2015, 10:23:16 PM by Crøwn »

-snip-
Okay. Thanks for the Help! I will try out what you have said later.

So I added some of the stuff you said, but i am getting a sintax error at 11:
Code: [Select]
function serverCmdStartZombieSurvival(%client)
{
    if(%client.isAdmin)
    {
commandToAll('bottomPrint', "<font:impact:50><color:f420eb>Zombie Survival round begins in 30 seconds! Prepare yourself!",5);

%time = 30;
serTimer(%time);
}
}

    else
{
    {
messageClient(%client, '', '\c6Only Admins can Start Zombie Survival!');
    }
}

function serTimer(%time)
{
if (%time <= 0)
{
%wave = 1;
commandToAll('centerPrint', "<font:impact:50><color:f420eb>The first wave has begun!",5);
commandToAll('bottomPrint', "<color:f420eb>Wave: <color:ffffff>" SPC %wave "<color:1818ba>You are a <color:FFFFFF>" SPC %client.getTeam().name);
}
}
else
{
%time--;

$TimerSchedule = schedule(1000, 0, "serTimer", %time);
}
}

So I added some of the stuff you said, but i am getting a sintax error at 11:

... okay, so just break this down. Follow the brackets.


function serverCmdStartZombieSurvival(%client)
{                                                      -- function opens here
    if(%client.isAdmin)
    {                                                  -- if statement opens here
        commandToAll('bottomPrint', "<font:impact:50><color:f420eb>Zombie Survival round begins in 30 seconds! Prepare yourself!",5);
   
        %time = 30;
        serTimer(%time);
    }                                                  -- if statement ends here
}                                                      -- function ends here

                                                       -- random else block outside of the function
    else                                               -- there is no if statement to match this with
{                                                      -- move this whole thing up before the end of the function
    {                                                  -- this bracket opens nothing
    messageClient(%client, '', '\c6Only Admins can Start Zombie Survival!');
    }
}
« Last Edit: February 09, 2015, 11:08:59 AM by portify »

Quote from: code
function serverCmdStartZombieSurvival(%client)
{
   if(%client.isAdmin)
    {
      commandToAll('bottomPrint', "<font:impact:50><color:f420eb>Zombie Survival round begins in 30 seconds! Prepare yourself!",5); Just use bottomprintall();.
   
      %time = 30; Change this to a global variable so that it isnt only referenced in this function.
      serTimer(%time);
   }
}

   else Why would you possibly put this outside of the function?
{
    {
   messageClient(%client, '', '\c6Only Admins can Start Zombie Survival!');
    }
}

function serTimer(%time) Is this suppost to be setTimer?
{
   if (%time <= 0) You cannot use a space between the function and the parameters. It MUST be if(%time <= 0), not if (%time <= 0)
   {
      %wave = 1; Needs to be global, not local
      commandToAll('centerPrint', "<font:impact:50><color:f420eb>The first wave has begun!",5);
      commandToAll('bottomPrint', "<color:f420eb>Wave: <color:ffffff>" SPC %wave "<color:1818ba>You are a <color:FFFFFF>" SPC %client.getTeam().name);   You are calling something that isn't defined in the parameters. (%client). You need to have @ symbols when displaying a variable in any chat form. Example, if I were to call the client who activated a servercmd's name to himself, I would do the following: messageclient(%client,'',"\c6Your name is "@%client.name);
   }
}
   else Why would you possibly put this outside of the function?
   {
      %time--;
   
      $TimerSchedule = schedule(1000, 0, "serTimer", %time);
   }
}
[/quote]
I will fix it for you. The first function, anyways.
Code: [Select]
function serverCmdStartZombieSurvival(%client)
{
    if(%client.isAdmin)
    {
bottomprintall("<font:impact:50><color:f420eb>Zombie Survival round begins in 30 seconds! Prepare yourself!",5);
$time = 30;
serTimer(%client,$time);
    }
    else
    {
messageClient(%client,'',"\c6Only Admins can Start Zombie Survival!");
    }
}

//FUNCTION 2

function serTimer(%client,%this)
{
if(%this <= 0)
{
$wave = 1;
centerPrintall("<font:impact:50><color:f420eb>The first wave has begun!",5);
bottomprintall("<color:f420eb>Wave: <color:ffffff>"@%wave@"<color:1818ba>You are a <color:FFFFFF>"@%client.getTeam().name);
}
else
{
$this--;
$TimerSchedule = schedule(1000, 0, "serTimer", %this);
}
}
EDIT: Also, why were there random spaces in your code?
EDIT2: Fixed everything that I could.
« Last Edit: February 09, 2015, 02:41:28 PM by RTBARCHIVE »

EDIT: Also, why were there random spaces in your code?
Readability. It's good programming practice to space out things in such a way that they're easy to read.

Quote from: code
It isnt calling a boolean, so the else command wont even work.

Please do not blatantly spread misinformation


Fixed
It's... It's still just as bad.

Quote
Else you can replace this with if(!isadmin) or if(%client.isadmin == 1)
First off, !isadmin will always be true. Entire script is broken and everyone can use it.
Second, %client.isadmin == 1 is redundant. You don't need the == 1 since %client.isAdmin is already a 0 or 1. That entire if statement, as he has it, is perfect.

You are calling something that isn't defined in the parameters. (%client). You need to have @ symbols when displaying a variable in any chat form. Example, if I were to call the client who activated a servercmd's name to himself, I would do the following: messageclient(%client,'',"\c6Your name is "@%client.name);
He doesn't need @ symbols, he can use SPC. Although he is missing one and %client still isn't defined.
I don't really know what you meant by variables in prints, but if you mean the center/bottomPrints you can do it like this: %clientB.bottomPrint("hello" SPC %variable);
SPC - Makes a space in between your text and the variable
@ - Just connects the variable, no spaces.
NL - Connects them but adds another line.
You can look at this to learn more about strings and variables.

Is this suppost to be setTimer?
Obviously not, as he calls serTime(%time); in the function before, meaning:
Change this to a global variable so that it isnt only referenced in this function.
is unneeded.

Edit:
Hopefully cleared miscommunication.
« Last Edit: February 09, 2015, 06:23:25 PM by Thorfin25 »

Basically you should learn a bit more before you dedicate yourself to helping others in their coding practices.

Thanks for all of help! I will try what Port, Thorfin, and Crown said and get a semi final script done soon. (It is lunch period at my school right now.)

He doesn't need @ symbols, he can use SPC. Although he is missing one and %client still isn't defined.
Thanks for your useless response, but I was just telling him in case he didn't want a space in his future coding.