SA-MP Forums Archive
PLEase HELP ME! Variables??? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: PLEase HELP ME! Variables??? (/showthread.php?tid=334479)



PLEase HELP ME! Variables??? - Andrew97 - 14.04.2012

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


Re: PLEase HELP ME! Variables??? - Kitten - 14.04.2012

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;
}



Re: PLEase HELP ME! Variables??? - Andrew97 - 14.04.2012

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


Re: PLEase HELP ME! Variables??? - MP2 - 14.04.2012

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?


Re: PLEase HELP ME! Variables??? - Andrew97 - 14.04.2012

So why should I use Variable NEW?

and when you wrote..

NEW var;

var=1

what this will do in my server?


Re: PLEase HELP ME! Variables??? - MP2 - 14.04.2012

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


Re: PLEase HELP ME! Variables??? - Andrew97 - 14.04.2012

I mean :

new variable

what this will Change in my server?

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


Re: PLEase HELP ME! Variables??? - Kitten - 14.04.2012

@Andrew97

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


Re: PLEase HELP ME! Variables??? - MP2 - 14.04.2012

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

P.S. You need 50 posts to give rep.


Re: PLEase HELP ME! Variables??? - Andrew97 - 14.04.2012

Like If I made: New PLayers= 0

then onplayerconnect:

players ++

this will Count the players online?