SA-MP Forums Archive
Is math use in scripting? - 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: Is math use in scripting? (/showthread.php?tid=377614)



Is math use in scripting? - JaKe Elite - 15.09.2012

I wonder if math is use in scripting.

Because i saw on LuxAdmin while i'm reviewing it.
It seems like this.

pawn Код:
RX = startX - endX;
    RY = startY - endY;
    RZ = startZ - endZ;
    new Float:sqrt = floatsqroot((RX * RX) + (RY * RY) + (RZ * RZ));
    if (sqrt < 0.01)
        sqrt = 0.01;
    RX = -length * (RX / sqrt) + startX;
    RY = -length * (RY / sqrt) + startY;
    RZ = -length * (RZ / sqrt) + startZ;
on the stock function GetOnLine3D.

What it does means?.

Is Math really use in scripting some how?


Re: Is math use in scripting? - Slaykler - 15.09.2012

Are you asking if Mathematics Is Used in Coding? If you are, it is. In most Scripting Languages actually.


Re: Is math use in scripting? - JaKe Elite - 15.09.2012

Yes i'm asking it.

So it is really use in scripting all the time??

like this?

pawn Код:
new Float:x,
      Float:y,
      Float:z;

GetPlayerPos(playerid, x, y, z);
SetPlayerPos(playerid, x+5, y+10, z+2);
SetPlayerPos(playerid, x, y, z+1);
Like that?

i don't understand if i'm using Math in the code i give or not.


Re: Is math use in scripting? - ReneG - 15.09.2012

In short, yes, math is used in scripting. Your example is a very simple form though.

Also, check this video out.
[ame="http://www.youtube.com/watch?v=E7nDgCleeWU&feature=player_embedded"]http://www.youtube.com/watch?v=E7nDgCleeWU&feature=player_embedded[/ame]
It was made by a very talented scripter here, this is the original thread. https://sampforum.blast.hk/showthread.php?tid=368071

and here is a snippet by that same dude
http://pastebin.com/YQjzqD5G

It's very interesting, yet not something you learn overnight.


Re: Is math use in scripting? - Lordzy - 15.09.2012

Yes,math is usually used in some cases of scripting.

Even a math reaction script is there.


Re: Is math use in scripting? - trapstar2020 - 15.09.2012

You cant do most things without maths you basically use most of these things in our everyday scripting
Код:
/ <<<<<<<<for dividing
+ <<<<<adding
- <<<<<<minus
=<<<<<<<equal



Re: Is math use in scripting? - clarencecuzz - 15.09.2012

I'm in the top maths class in my school, and to be honest, the maths functions in SAMP scripting confuse even me. It's hard to master, but if you regularly use it and understand what each function does, you'll understand it in no time. I won't be attempting it anytime soon though.


Re: Is math use in scripting? - Lordzy - 15.09.2012

Quote:
Originally Posted by trapstar2020
Посмотреть сообщение
You cant do most things without maths you basically use most of these things in our everyday scripting
Код:
/ <<<<<<<<for dividing
+ <<<<<adding
- <<<<<<minus
=<<<<<<<equal
You missed multiplication
Код:
* for multiplying



Re: Is math use in scripting? - [ABK]Antonio - 15.09.2012

It's defiantly used if you want to make certain things

for instance, a speedometer would be something like (xvel^2 + yvel^2 + zvel^2) * a number
and it can get pretty complicated when using things like cosine etc - which you would use to figure out the position behind the player

also useful if you're just making a stat system with basic math like kills/deaths=ratio or kills++ (kills+1) etc


Re: Is math use in scripting? - JaKe Elite - 15.09.2012

Thank you VincentDunn.
clarence and Antonio for such a wonderful explaination about math.