Is math use in scripting?
#1

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?
Reply
#2

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

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.
Reply
#4

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.
Reply
#5

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

Even a math reaction script is there.
Reply
#6

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

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.
Reply
#8

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
Reply
#9

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
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)