PLEase HELP ME! Variables???
#1

I really Can't Understand the Variables? I Read WIKI many times and I can't understand It at all!!

please Describe it to me please
Reply
#2

pawn Код:
new variable;

public OnPlayerConnect(playerid)
{
     variable = 0;
     return 1;
}

public OnPlayerSpawn(playerid)
{
     if(variable == 0)
     {
          printf("variable is 0");
          variable = 1;
     }
     else
     {
          printf("variable is 1");
     }
     return 1;
}
Reply
#3

what do you mean by this? I can't understand you!
Reply
#4

A variable is memory that is allocated to store a value, which can vary (variable). To create a variable:

pawn Код:
new var;
to set it to a number:
pawn Код:
var = 1;
to get a variable:

pawn Код:
printf("var is %i", var);
Arrays can hold many values in one variable:

pawn Код:
new array[5];
You can then set those 5 values:

pawn Код:
array[0] = 1;
array[1] = 5;
array[2] = 28;
array[3] = 85;
array[4] = 69;
Array indexes start at 0.

Anything else?
Reply
#5

So why should I use Variable NEW?

and when you wrote..

NEW var;

var=1

what this will do in my server?
Reply
#6

It will create the variable called 'var' and set it to 1. 'new' declares (creates) a variable.
Reply
#7

I mean :

new variable

what this will Change in my server?

BTW thanks for helping me Special thank for you!! (+1 Rep for you)
Reply
#8

@Andrew97

It will not change you're server, just defining a variable to the gamemode.
Reply
#9

It won't 'DO' anything. It's memory.

P.S. You need 50 posts to give rep.
Reply
#10

Like If I made: New PLayers= 0

then onplayerconnect:

players ++

this will Count the players online?
Reply


Forum Jump:


Users browsing this thread: