[Include] SetPlayerPosEx
#1

- Introduction -

v1.0 : This is my first include. I was roaming with friends so i thought of making a Stock function by which we can SetPlayerPos and we can SetPlayerFacingAngle as well with the same function. So i went back home and made it in 3 minutes. So thought of compiling an include to release this stock function so that everyone can use it.
v1.1 : Just after releasing v1.0 , iTorran suggested me to add new param's to the include. So i just added in some minutes and uploaded with added info!
- Functions -

pawn Код:
//v1.0
//There is only one Stock which is:
stock SetPlayerPosEx(playerid, Float:x ,Float:y,Float:z,Float:a) // Float x = X-Coordinate , Float y = Y-Coordinate , Float z = Z-Coordinate , Float a = Player's facing angle
{
    SetPlayerPos(playerid , x , y ,z);
    SetPlayerFacingAngle(a);
    return 1;  
}
/* Here this function input's Float values from actual argument's and transfer's the value to the format argument's inside the curly braces. First the stock Set's the Player's position according to the x,y,z and Sets the Players angle according to a which the facing angle. */
//v.1.1 -
stock SetPlayerPosEx(playerid, Float:x ,Float:y,Float:z,Float:a,interior,vw)
{
    SetPlayerPos(playerid , x , y ,z);
    SetPlayerFacingAngle(playerid, a);
    SetPlayerInterior(playerid, interior);
    SetPlayerVirtualWorld(playerid, vw);
    return 1;
}
/* In v1.1 the stock has new added parameter's which are interior and virtual world. These are integer values.
SetPlayerInterior & SetPlayerVirtualWorld collect's their value from actual argument's and return's 1 when task is over! */
- How to Use -

pawn Код:
// With v1.1 & 1.0 (Cross Compatible)
// You can use this without interior & virtual world param. (Default 0)
SetPlayerPosEx(playerid,-2650.9975, 1382.7977, 7.1888, 267.40);
// This will just set player's position and angle with int and vw as 0 (Default)
//
//                              OR
// With v1.1 Only
SetPlayerPosEx(playerid,-2650.9975, 1382.7977, 7.1888, 267.40,0,5);
// Here 0 = interior & 5 = Virtual World
- Installation -
pawn Код:
// Simple Add the line below on the top of your Game mode or where you have included other .inc files such as a_samp , etc.
#include <spsx>
- Download -
v1.0 - Mediafire -
v1.0 - Pastebin -

v1.1 - Mediafire - (Recommended) (Cross Compatible)
v1.1 - Pastebin - (Recommended) (Cross Compatible)
Mirrors: Allowed [Currently:None]

- Future Releases -

Spsx will have future releases. Thinking of updating the include with some new functions.

- Change Log -

v1.0 - spsx.inc was able to set Player's Postions as well as their Facing Angle.
v1.1 - spsx.inc is able to Set Player's interior and virtual world along with positions & angle.


- Known Bugs -
None

Report Bugs on this thread if you find any please or post a suggestion if you have any.


- Credits -
- v1.0
Ballu Miaa : For writing the whole include
Kalcor & Team : For developing SetPlayerPos & SetPlayerFacing Angle


- v1.1
Ballu Miaa : For the Include.
Kalcor & Team : For SA-MP
iTorran : For his great idea of adding new param's to the stock.
****** : For making v1.1 cross compatible with v1.0


- BMiaa
Reply
#2

3 minutes.. really?
Anyway its eh good i guess, add an optional interior parameter
Reply
#3

Quote:
Originally Posted by iTorran
Посмотреть сообщение
3 minutes.. really?
Anyway its eh good i guess, add an optional interior parameter
Yeah it took me 3 minutes by the way Thanks! Oh Right!!! Thats it , The v1.1 will have Interior param as well as virtual world param. Ill go work on it! See you will be updating the new version soon!

Thanks for the idea!
Reply
#4

Released spsx.inc v1.1 Check the Main Post for information.
Reply
#5

Quote:
Originally Posted by ******
Посмотреть сообщение
If you do:

pawn Код:
stock SetPlayerPosEx(playerid, Float:x ,Float:y,Float:z,Float:a,interior = 0,vw = 0)
Then you will make the last two parameters optional, which means you can just specify xyza as in your v1.0, or all the parameters as in your v1.1. Basically this will make it slightly more backwards compatible.
Awesome! Your just fucking awesome bro. Thanks for that even i was thinking how can i do that?

I will keep that in mind when actual argument's are defined as 0 in the stock they become optional!

spsx.inc is updated! v1.1 is Cross Compatible with v1.0 , Now interior & virtual world params are optional!
Reply
#6

Not bad. Easy to make. Good for first.

Btw ****** thanks for the tip. I am creating a small library and I would use that for sure.
Reply
#7

Its nice but very sinple to do.
Reply
#8

Cool one!!
Reply
#9

Quote:
Originally Posted by [HK]Ryder[AN]
Посмотреть сообщение
Not bad. Easy to make. Good for first.

Btw ****** thanks for the tip. I am creating a small library and I would use that for sure.
Yeah i know! Chea thanks to ****** for the great tip i say xD!

Quote:
Originally Posted by Shadow_
Посмотреть сообщение
Its nice but very sinple to do.
Yeah simple but there was none like this so made it!

Quote:
Originally Posted by ******
Посмотреть сообщение
Not just "0", you can have any value as a default value, even on strings. From one of my libraries:

pawn Код:
stock Style:TD_Create(Float:x = 0.0, Float:y = 0.0, Float:letterX = 0.48, Float:letterY = 1.12, Float:textX = 1280.0, Float:textY = 1280.0, colour = 0xE1E1E1FF, boxColour = 0x80808080, bgColour = 0x000000FF, shadow = 2, outline = 0, align = _:td_align_none, font = 1, bool:proportional = false, bool:box = false, time = 0, name[] = "\1")
What's more, there are a lot of optional parameters there, you can specialise just one if you want:

pawn Код:
TD_Create(.box = true);
By specifying ".parameter = value" when you CALL the function, it will set that parameter to your chosen value and leave all others the same. You can also use "_" to mean "default":

pawn Код:
TD_Create(_, _, 0.5);
That will leave the first two parameters as their defaults, and set the third parameter to "0.5". You can even combine the two and don't have to do named parameters in order:

pawn Код:
TD_Create(_, _, 0.5, .box = true, .letterY = 1.0, .name = "A String");
The "box" parameter comes after the "letterY" parameter in the function definition, but because we specify the name, it can come before here.
Okay ****** that's confusing for me? If i put "_" somewhere so that will its value = to its default value? How will we define its default value then? Thanks for this explanation on Functions and Argument's.

Quote:
Originally Posted by Niko_boy
Посмотреть сообщение
Cool one!!
Thanks Amigo!
Reply
#10

Quote:
Originally Posted by Ballu Miaa
View Post
Okay Y_Less that's confusing for me? If i put "_" somewhere so that will its value = to its default value? How will we define its default value then? Thanks for this explanation on Functions and Argument's.
OK, I need to make clear the difference between "definition" of a function and "calling" a function:

pawn Code:
MyFunc(a, b = 27, c[] = "Hi")
{
    printf("%d %d %s", a, b, c);
}
That is a function "definition", with one required parameter and two optional parameters. The first defaults to 27, the second to "hi". These, on the other hand, are function calls:

pawn Code:
MyFunc(); // Warning (required parameter is missing).
MyFunc(42); // Prints "42 27 hi".
MyFunc(42, 42); // Prints "42 42 hi".
MyFunc(42, 42, "hello"); // Prints "42 42 hello".
Now it may be that you want to change the third parameter, but leave the second as default. There are three ways of doing this AT THE CALL SITE:

pawn Code:
MyFunc(42, 27, "hello"); // Prints "42 27 hello".
MyFunc(42, _, "hello"); // Prints "42 27 hello".
MyFunc(42, .c = "hello"); // Prints "42 27 hello".
The first version is not brilliant, if the default value on the function definition changes, this will continue to print "27" instead of the new default value.

The second version uses "_" to mean "default", with the parameters still specified in order.

The third version doesn't mention the second parameter at all, instead it sets the third parameter by name using ".".

Named parameters do not have to be in order:

pawn Code:
MyFunc(42, .c = "hello", .b = 42); // Prints "42 42 hello".
Hopefully that clears up my last post.
Reply
#11

Quote:
Originally Posted by ******
Посмотреть сообщение
OK, I need to make clear the difference between "definition" of a function and "calling" a function:

pawn Код:
MyFunc(a, b = 27, c[] = "Hi")
{
    printf("%d %d %s", a, b, c);
}
That is a function "definition", with one required parameter and two optional parameters. The first defaults to 27, the second to "hi". These, on the other hand, are function calls:

pawn Код:
MyFunc(); // Warning (required parameter is missing).
MyFunc(42); // Prints "42 27 hi".
MyFunc(42, 42); // Prints "42 42 hi".
MyFunc(42, 42, "hello"); // Prints "42 42 hello".
Now it may be that you want to change the third parameter, but leave the second as default. There are three ways of doing this AT THE CALL SITE:

pawn Код:
MyFunc(42, 27, "hello"); // Prints "42 27 hello".
MyFunc(42, _, "hello"); // Prints "42 27 hello".
MyFunc(42, .c = "hello"); // Prints "42 27 hello".
The first version is not brilliant, if the default value on the function definition changes, this will continue to print "27" instead of the new default value.

The second version uses "_" to mean "default", with the parameters still specified in order.

The third version doesn't mention the second parameter at all, instead it sets the third parameter by name using ".".

Named parameters do not have to be in order:

pawn Код:
MyFunc(42, .c = "hello", .b = 42); // Prints "42 42 hello".
Hopefully that clears up my last post.
Wow that seriously clear's the fact. So named parameters can be called in any order. But other's params need to be ordered according to the definition!

Params are missing warning! Thats a new thing. Wow i learnt lot of stuff about Programming today. Thanks alot bro!

You're the Boss!
Reply
#12

But if their vw or interior was ie 9 it will set it to 0 won't it?

Edit: o nvm. Didn't read your last post.
Reply
#13

Quote:
Originally Posted by legodude
View Post
But if their vw or interior was ie 9 it will set it to 0 won't it?

Edit: o nvm. Didn't read your last post.
All good Fella.
Reply
#14

i'm using it,thanks!
Reply
#15

Quote:
Originally Posted by willzyyy
View Post
i'm using it,thanks!
Glad to know that! All good Mate.
Reply
#16

Nice to see you have released your first script.
Reply
#17

Quote:
Originally Posted by Jochemd
View Post
Nice to see you have released your first script.
Yeah Thank Jochemd! Always wanted to have the first release but it was hard to think what it will be !
Reply
#18

pawn Code:
stock SetPlayerPosEx(playerid, Float:x, Float:y, Float:z, Float:a = -1.0, interior = -1, vw = -1)
{
    SetPlayerPos(playerid, x, y, z);
   
    if(a == -1.0)
        GetPlayerFacingAngle(playerid, a);
    SetPlayerFacingAngle(playerid, a);
   
    if(interior == -1)
        interior = GetPlayerInterior(playerid);
    SetPlayerInterior(playerid, interior);
   
    if(vw == -1)
        vw = GetPlayerVirtualWorld(playerid);
    SetPlayerVirtualWorld(playerid, vw);
    return 1;
}
The expanded version.
Reply
#19

Quote:
Originally Posted by kacper55331
View Post
pawn Code:
stock SetPlayerPosEx(playerid, Float:x, Float:y, Float:z, Float:a = -1.0, interior = -1, vw = -1)
{
    SetPlayerPos(playerid, x, y, z);
   
    if(a == -1.0)
        GetPlayerFacingAngle(playerid, a);
    SetPlayerFacingAngle(playerid, a);
   
    if(interior == -1)
        interior = GetPlayerInterior(playerid);
    SetPlayerInterior(playerid, interior);
   
    if(vw == -1)
        vw = GetPlayerVirtualWorld(playerid);
    SetPlayerVirtualWorld(playerid, vw);
    return 1;
}
The expanded version.
Could you please explain that now? What it will do if a = -1.0 or something. Please explain?
Reply
#20

-1.0 means not to change that value. So if interior is set to -1, it means keep the player's interior the same when he teleports.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)