Trying to be better scripter. -
GaGlets(R) - 04.09.2010
Hello everyone reader.
I am not new scripter, usually i use some of the symbols and i know what they mean but now i want to know something more about them, actualy about what they are doing or meaning of them. Some of these i know, but anywhay i will ask. This should be useful for newbies too..
Symbols:
&& :
& :
pawn Код:
//for example usage in:
if(function1 & function 2)
//any differences between this?
if(function1 && function2)
< :
<< :
>> :
> :
| : (if this exists)
|| :
* :
- :
-- :
= :
== :
+ :
++ :
% :
>= :
<= :
-= :
+= :
If there is anything else then just write it under my list, write the meaning of that symbol and how it works (you can make some script example and describe it)
Re: Trying to be better scripter. -
woot - 04.09.2010
Are you asking what they are or are you doing a tutorial? lol
Re: Trying to be better scripter. -
Thebest96 - 04.09.2010
LOL, i dont understand anithing
Re: Trying to be better scripter. -
LarzI - 04.09.2010
He wants someone to explain and show examples with all those operators, I believe.
Look up the Pawn Language PDF, all information is stated in there.
Re: Trying to be better scripter. -
Toni - 05.09.2010
These symbols (or at least some of them) are related to general math/algebra.
Symbols:
&& : - This means
and, in terms of PAWN, you could do 2 functions in 1 if statement. Example is below.
pawn Код:
if(IsPlayerConnected(playerid) && IsPlayerAdmin(playerid))
& : This I do not really know yet, but I do know a way you could use it. Example is below.
< : Less then, 1 < 5 - 1 is less then 5.
pawn Код:
if(PlayerInfo[playerid][Money] < GetPlayerMoney(playerid)) - //If their money is less then their client side money.
<< : I do not know yet.
>> : I do not know yet.
> : Greater then, 5 > 1 - 5 is greater then 1.
pawn Код:
if(GetPlayerMoney(playerid) > PlayerInfo[playerid][Money]) - //If their client side money is larger then their var money.
| : I do not know yet.
|| : This is like &&, but this is "or". You can use this for many things, such as strcmp.
pawn Код:
if(!strcmp(cmd, "/help", true) || !strcmp(cmd, "/h", true)) - //Comparing if they used /h or /help.
* : This is a math symbol, multiplication.
pawn Код:
75 * 3 - //Same thing as 75 x 3
- : This is a math symbol, subtraction. But this is used inside a function.
-- : This is used to downgrade or subtract a variable.
= : This is a math symbol, basically equal to. It is used to assign a value to a var or array, etc.
pawn Код:
new Float:Health = 3000.0
== : This is a math symbol, similar to the equal sign, but instead, this is used to compare two functions/vars/arrays/etc.
pawn Код:
if(playerid == INVALID_PLAYER_ID) // This is used in a PM cmd, to see if they typed a invalid playerid.
+ : This is like subtraction, except, it is addition, you use it inside a function, to add numbers or variables/values.
++ : This is like the subtraction sign for vars, but this is addition.
pawn Код:
CountDown++; //Will count upwards.
% : This is used to format a specifier, inside a format.
pawn Код:
%d - Whole Intenger | %s - string | %f - Float | %c - Single Character and more (search wiki)
>= : This is using the greater then, but also like assigning a var. This can be used to see a player's admin level in a if statement.
pawn Код:
if(PlayerInfo[playerid][pAdmin] >= 4) // This will check if the person's level is 4 or higher.
<= : This is using the less then, but also like assigning a var. This can be used to see a player's admin level in a if statement.
pawn Код:
if(PlayerInfo[playerid][pAdmin] <= 4) // This will check if the person's level is 4 or lower.
-= : This is like the subtraction sign, except used for vars/arrays/enums etc.
pawn Код:
PlayerInfo[playerid][Money] -= amount;
+= : This is like the addition sign, except used for vars/arrays/enums etc.
pawn Код:
PlayerInfo[palyerid][Money] += amount;
Hope this helped.
Re: Trying to be better scripter. -
GaGlets(R) - 05.09.2010
****** will look in.
Ahm,
I didn`t know only
<<
>>
&
symbols, everything else i know, dont blame me.
Re: Trying to be better scripter. -
Toni - 05.09.2010
should have said that
took me like 10 minutes of my wasted life D:
Re: Trying to be better scripter. -
RSX - 05.09.2010
Quote:
Originally Posted by The Toni
These symbols (or at least some of them) are related to general math/algebra.
& : This I do not really know yet, but I do know a way you could use it. Example is below.
% : This is used to format a specifier, inside a format.
pawn Код:
%d - Whole Intenger | %s - string | %f - Float | %c - Single Character and more (search wiki)
Hope this helped.
|
To quate : WTF. Really? Read some topics, i even wrote how & is used with keys.. and what it does... and it was recently.
I can teach some usages of them whenever i have time, PM me, for example, i'm totaly sure that binary shift << is tons of times faster than float multiplication (* in pawno) num<<1 =num*2; num<<2 =num*4 num>>1=num/2 num>>2=num/4; (Rounds down always, as actually just loses the byte);
Re: Trying to be better scripter. -
Toni - 05.09.2010
Quote:
Originally Posted by RSX
To quate : WTF. Really? Read some topics, i even wrote how & is used with keys.. and what it does... and it was recently.
I can teach some usages of them whenever i have time, PM me, for example, i'm totaly sure that binary shift << is tons of times faster than float multiplication (* in pawno) num<<1 =num*2; num<<2 =num*4 num>>1=num/2 num>>2=num/4; (Rounds down always, as actually just loses the byte);
|
I'm not stupid, and maybe I haven't seen those topics.
It's funny how people criticize other people if they don't know it, or don't know it correctly.
Also, pointing out to what ****** said, * is not a float multiplication, but a normal multiplication, that you can do with many values.
Thanks for the examples though, I do see what you mean.
Edit:
@ ******, I am a little confused on 'sleep'.
From the .pdf :
sleep expressionAbort the program, but leave it in a re-startable state. The expression
is optional. If included, the sleep instruction returns the
expression value (plus the expression tag) to the host application.
The significance and purpose of exit codes/tags is implementation
defined; typically, an application uses the sleep instruction to allow
for light-weight multi-tasking of several concurrent pawn programs,
or to implement “latent” functions.
Re: Trying to be better scripter. -
Nero_3D - 05.09.2010
Quote:
Originally Posted by The Toni
@ ******, I am a little confused on 'sleep'.
From the .pdf :
sleep expressionAbort the program, but leave it in a re-startable state. The expression
is optional. If included, the sleep instruction returns the
expression value (plus the expression tag) to the host application.
The significance and purpose of exit codes/tags is implementation
defined; typically, an application uses the sleep instruction to allow
for light-weight multi-tasking of several concurrent pawn programs,
or to implement “latent” functions.
|
I know that sleep only works in main and main is an extra task which is executed next to the script
I would like to know in what unit of time the expression should be (I suppose ms) and what happens without expression