URI:
   DIR Return Create A Forum - Home
       ---------------------------------------------------------
       High Stakes Roleplay
  HTML https://highstakes.createaforum.com
       ---------------------------------------------------------
       *****************************************************
   DIR Return to: Coders' corner
       *****************************************************
       #Post#: 21--------------------------------------------------
       Real Newbie
   DIR By: Joe
       Date: March 20, 2012, 5:10 pm
       ---------------------------------------------------------
       Im a real newbie to scripting/coding. But If somebody who knows
       everything about it and will explain clearly I will learn fast.
       I need a guide, Step-By-Step and results in it. Something that
       will help me learn how to script or at least give others a
       chance to learn from the pros.
       NO AND I DONT WANT WIKIPIEDIA OK!?!
       #Post#: 25--------------------------------------------------
       Re: Real Newbie
   DIR By: Jack Shred
       Date: March 20, 2012, 11:49 pm
       ---------------------------------------------------------
       wikipedia plz
       #Post#: 26--------------------------------------------------
       Re: Real Newbie
   DIR By: Joe
       Date: March 21, 2012, 2:54 am
       ---------------------------------------------------------
       Tried wikipedia but didn't really understand.... :<
       #Post#: 27--------------------------------------------------
       Re: Real Newbie
   DIR By: Joey Tucker
       Date: March 21, 2012, 11:09 am
       ---------------------------------------------------------
       First of all, basic data types.
       All data is declared as a new variable with the pawno function
       'new'.
       For example,
       --- Code ---
       new OnlinePlayers;
       --- End Code ---
       Integers
       Integers are known as 'whole numbers' in basic math.
       To declare a new integer, use the following piece of code.
       --- Code ---
       new Variable;
       --- End Code ---
       "new" - Declaring 'Variable' as a new variable.
       "Variable" - Naming the variable. It could also be 'new
       PlayersOnline;' or 'new AmountOfCars;'
       ";" - End the declaration or function.
       This automatically sets 'Variable' to 0. You can change the
       value of Variable by using as follows.
       --- Code ---
       new Variable = 5;
       --- End Code ---
       Where 5 is the value of Variable.
       Floats
       Floats are the exact same as integers, but can hold 1/10s,
       1/100s and even 1/1000s. Known as a 'decimal number' in basic
       math.
       --- Code ---
       new Float:Variable;
       --- End Code ---
       The "Float:" part declares 'Variable' as a float number.
       You could also represent that as
       --- Code ---
       new Float:Variable = 0.0;
       --- End Code ---
       Where 0.0 is the decimal value of Variable, eg 5.5, or 3.142.
       --- Code ---
       new Float:Pi = 3.1415926535;
       --- End Code ---
       Strings
       String are strings of characters, be it numerical or
       alphabetical.
       String are declared the same way as integers, with an added pair
       of enclosing square brackets, containing the string size.
       --- Code ---
       new String[128];
       --- End Code ---
       - Create a string named 'String' that can hold up to 128
       characters on slots 0 to 127.
       You can then format a string to contain text.
       --- Code ---
       format(String, sizeof(String), "Hello. This is a string!");
       --- End Code ---
       The "sizeof(String)" can be replaced with "128", as you know the
       string size.
       Arrays
       The exact same as a string, just used differently.
       --- Code ---
       new Array[128];
       --- End Code ---
       You can then either use it as a string, using "format()" or you
       can use it as an array, using
       --- Code ---
       Array[x] = y;
       --- End Code ---
       Where x is the array slot (0 to 127) and y is the integer value.
       You can even create float arrays, or use them as strings.
       --- Code ---
       new Float:Array[128];
       --- End Code ---
       --- Code ---
       Array[x] = y.z;
       --- End Code ---
       Where x is the array slot (0 to 127) and y.z is the decimal
       representation. (eg 5.1, 3.1415926535)
       --- Code ---
       Array[x] = "Hello";
       --- End Code ---
       Where x is the array slot (0 to 127).
       Basic function use.
       --- Code ---
       public OnPlayerConnect(playerid)
       --- End Code ---
       -  What happens when player with id playerid logs in?
       Let's send him a message, saying welcome.
       --- Code ---
       public OnPlayerConnect(playerid)
       {
       SendClientMessage(playerid, 0xFFFFFF00, "Hello! Welcome to
       our server.");
       }
       --- End Code ---
       Where 0xFFFFFF00 is the HTML colour code in the format RRGGBBAA.
       (AA does not effect client messages, only player colours)
       This looks boring, and so let's spice it up a bit.
       --- Code ---
       public OnPlayerConnect(playerid)
       {
       new name[MAX_PLAYER_NAME];
       GetPlayerName(playerid, name, sizeof(name));
       new string[129];
       format(string, 129, "Hello, %s. Welcome to our server! You
       are player ID %d.",name,playerid);
       SendClientMessage(playerid, 0xFFFFFF00, string);
       }
       --- End Code ---
       The 'name[MAX_PLAYER_NAME] is a string. MAX_PLAYER_NAME is at
       default 24, which is the maximum size a player's name can be.
       That is the same as doing
       --- Code ---
       new name[24];
       --- End Code ---
       The 'GetPlayerName()' is self-explanatory.
       --- Code ---
       native GetPlayerName(playerid, name, max_length);
       --- End Code ---
       "%s" means 'insert STRING'. The string to insert is defined
       after the formatting is complete.
       "%d" and "%i" mean 'insert INTEGER'. The integer to insert is
       also defined after the string has been formatted.
       The 'name, playerid' part is actually defining the
       string/integer to insert. This must be in the order you stringed
       it in. %s came before %d, so name should come before playerid.
       String insertions
       The different symbol phrases to use for inserting different
       variables go as follows.
       --- Code ---
       %s - string/alphabetical value of (an) array slot(s)
       %d or %i - integer/numerical value of (an) array slot(s)
       %f - float
       %% - a % sign
       --- End Code ---
       If you need anything else explained, I'll make another post.
       #Post#: 195--------------------------------------------------
       Re: Real Newbie
   DIR By: Jack Shred
       Date: March 29, 2012, 3:53 pm
       ---------------------------------------------------------
       You have way too much time.
       #Post#: 198--------------------------------------------------
       Re: Real Newbie
   DIR By: Joe
       Date: March 30, 2012, 2:49 am
       ---------------------------------------------------------
       I agree with the post above.
       *****************************************************
       Page 1 of 1