1 question about Variables
#1

Hey guys i wanna know where should i put the variable "Spawned" at ?

Does it includes all "IF STATEMENT" if i put it on the top ? or i should put it on each "IF Statement"

Example:
pawn Code:
public OnPlayerSpawn(playerid)
{
    Spawned[playerid] = 1;

    if(Somthing == "")
    {
        bla bla bla
        bla bla bla
    }
    if(Somthing == "")
    {
        bla bla bla
        bla bla bla
    }
    return 1;
}
And what would happen if i put it in the bottom
Reply
#2

pawn Code:
public OnPlayerSpawn(playerid)
{
    Spawned[playerid] = 1;
    if (Spawned[playerid]) /* Spawned */
    {
        // your code
    }
    else /* Not spawned */
    {
        // your code
    }
    return true;
}
EDIT: I hope this is just an example otherwise it makes no sense!
Reply
#3

why you put ( if spawned[playerid] ) and he's already spawned = 1
Reply
#4

Setting some value at that variable at the top is the correct way. If those if statements has nothing to do with it, then there's absolutely not a reason to do so.
Reply
#5

Quote:
Originally Posted by Konstantinos
View Post
Setting some value at that variable at the top is the correct way. If those if statements has nothing to do with it, then there's absolutely not a reason to do so.
so my method is correct ? what if it's like this:

pawn Code:
public OnPlayerSpawn(playerid)
{
    Spawned[playerid] = 1;

    if(Somthing == "")
    {
        if(Somthing == "")
        {
            bla bla bla
            bla bla bla
        }
    }
    if(Somthing == "")
    {
        bla bla bla
        bla bla bla
    }
    return 1;
}
Reply
#6

Like I said, it is correct.

You want to set the variable to 1 whenever a player spawns and that's what it should do. What would be the point of checking something for just setting it to 1? Totally none.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)