Warning Does it matter in games?
#1

Penis
Reply
#2

We Need To See Your Code
Reply
#3

Quote:
Originally Posted by HayZatic
Посмотреть сообщение
We Need To See Your Code
I Will not show it Because it GameMode XD
What I ask is, What is the effect on the Game READ Thread BEfore Posting NuB XD
Reply
#4

Quote:
Originally Posted by SmileyForCheat
Посмотреть сообщение
I Will not show it Because it GameMode XD
What I ask is, What is the effect on the Game READ Thread BEfore Posting NuB XD
Don't flame, he miss-read the thread. Considering you hacked on my server, how about you gtfo nub.
Reply
#5

From what I see, you're code lacks proper indentation. The warnings regarding a local variable shadowing a variable at a preceding level are saying that you wrote 'new RandomSpawns;' more than you should've. It would be best if you got rid of those warnings to be sure that you won't have any bugs in your gamemode. I would be glad to fix it if you showed me the code, and don't try to say that I'm plotting to steal your gamemode because I could give a shit about it. I have a gamemode of my own that I'm working on and I have no problem with pasting a couple of lines on the forums from it if I know that someone would help me fix an error or two. I'm here to help, not to steal bits and pieces of code.
Reply
#6

From what I see these will do no harm, however try out some of your systems ingame to see if they all work properly.
Reply
#7

Well If You Just Dont Want To Show Us Might As Well Delete Your Gamemode. Or fix it yourself. Why Do We need your gamemode? were not the ones who are Having a problem right? and its not the whole Gamemode we looking at but w.e
Reply
#8

What an immature people.

Btw I better give you the explanation of it.

Quote:

loose indentation

Tabulation thing.

Quote:

local variable blablabla

You make a new variable that's already exist.

Quote:

symbol is never used:blablabla

You never use the variable you made.

Quote:

number of arguments does not match definition

It says all.
Reply
#9

Quote:
Originally Posted by varthshenon
Посмотреть сообщение
What an immature people.

Btw I better give you the explanation of it.


Tabulation thing.


You make a new variable that's already exist.


You never use the variable you made.


It says all.
Well he just summed up just about everything. If you want to know how to fix the errors it's quite simple.
Код:
loose indentation
pawn Код:
//bad indentation
OnPlayerConnect(playerid)
{
    //dosomething
               //dosomething
         //dosomething
}
//good indentation
OnPlayerConnect(playerid)
{
    //dosomething
    //dosomething
    //dosomething
}
Код:
local variables shadows another variable
pawn Код:
new string[128]; // this variable is already there
OnPlayerConnect(playerid)
{
    new string[128]; // this shouldn't be here
    format(string, sizeof(string), "Welcome to the server %s", PlayerName(playerid));
    SendClientMessage(playerid, COLOR_GREEN, string);
}
Код:
symbol is never used
pawn Код:
new string[128]; // I don't see this being used anywhere
OnPlayerConnect(playerid)
{
    return 1;
}
Код:
symbol is assigned to a value that is never used
pawn Код:
new vehicleid = GetPlayerVehicleID(playerid); // i don't see this being used
OnPlayerConnect(playerid)
{
    return 1;
}
Код:
number of arguments does not match definition
pawn Код:
OnPlayerSpawn(playerid)
{
    SetPlayerPos(playerid, x, y, z, a/*this isn't supposed to be there*/);
    return 1;
}
OnPlayerSpawn(playerid)
{
    SetPlayerPos(playerid, x, y, z); // now that's better
    return 1;
}
I hope this helped.
Reply
#10

I felt i should respond since his question wasnt exactly answered, and no one explained the importance of the warnings.

Yes, warnings matter. They may not render your GM unplayable but they generally complain about things that are worth warning you about! Its extremely bad practice to ignore warnings or use pragma's to cover them up.

Proper indentation:: This honestly is one of the best things to practice. You avoid annoying warnings regarding improper indentation after all :P. After every opening curl bracket (The symbol: "{") you should add four spaces to all your code until you hit a closing curl bracket (The symbol: "}"). This makes the code spread out and a lot easier on the eyes. The main reason why indentation is so important though is because it makes scope very clear (Scope is where soemthing iis declared, and where it can be used due to said location)! Here's an example if proper indentation:

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    //Opening curl bracket, so we indent four spaces (hit the tab key).

    if(!strcmp(cmdtext, "//example")) // strcmp just for the example
    {
        //Another opening curl bracket, so we indent four more spaces.

        //Some code...
    }
    //We're done with the if statement, and add a closing curly bracket, so we go back four spaces.
    return 0;
}
//Done with the callback, so we're back were we started (and we repeat :P).
local variables shadows another variable: This warning is pretty clear. It means two variables have the same name and are in the same scope. This is important to fix or you could have some unwanted results, as when you mod a variable when there's another variable with the same name, which one is getting changed? Are you sure its the one you want? There is a pretty simple fix for this, simply change the name of one of the variables!

before i get into the fix, here's a small lesson on scope.
  • Global scope - This is the point from where you declare your variable that is outside any function/callback, onward (so the rest of the file down).
  • Local scope - This is the area between any pairs of curl brackets. So if you put your variable immediately after an opening curly brace it can only be used in the entire area of that code block (until the closing curly brace for that opening curly brace is met).
It good practice to name all your global variables with a preceding "g_" to denote them as such. This makes it clear its a global variable, and avoids naming clashes.

Example (for consistency, lets use the same one):

Код:
new g_Example = 0;  // This is outside of any function or callback, so its global...can be used anywhere in this example

public OnPlayerCommandText(playerid, cmdtext[])
{
    new Example = 0; //Normally if our previous var didnt have the preceeding "g_" this would've given a warning.
    if(!strcmp(cmdtext, "//example")) 
    {
        new Example = 0 // This still will give a warning, as there's a var above it (in the same local scope) with the same name ... either use the previous one, or rename this one.

        
    }
    //The Example var (the warning one inside the if statement) is out of scope now.
    return 0;
}
//The first Example var (one before the if statement) is no out of scope

//g_Example is global so its been in scope the entire time, and still is.
Symbol is never used This one is also very clear. You declared a variable and didnt use it through the entirety of its scope. If your not gonna use a variable, there is no point in declaring it! This clutters up your code as its uneeded, and its bad practice (in some languages, this will just be allocated and ignored). If your not sure if a variable is going to be used, declare it as "stock". This makes it so if you dont use the variable, its not included in your code.

Example:

Код:
new stock g_MyVar = 0;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)