CreateWater.inc | Create Custom Waters and Swim in them! -
iAmir - 20.12.2017
CreateWater.inc | v2.0
NEW UPDATE
Fully controllable custom oxygen bar has been added.
Added new functions.
Fixed under water swim move.
Optimized swim/move styles.
Changed function IsPlayerInWaterEx to IsPlayerInCustomWater.
Added a simple example script in github.
----------------------------------------------------------------------------
Start and Informations
So Hi ! , maybe you know I posted it on Screenshot and Videos section and as I said , I'm releasing it now.
About 4years ago that I started scripting in SAMP , I wanted to make pool but I couldn't make it anywhere I wanted
I had to make it on water and make objects to make it like a pool.
I searched a lot to see if anyone made this possible before or not , the only results was MultiTheftAuto's function :
Код:
createWater(blah blah blah)
So a week ago that I was working on my project , water waves annoyed me so much , I thought why not making it server sided!?
And I started making zones with NO COLL objects and set their material as water texture.
then scripted a server sided swiming (and big thanks to SAMP Devs , vectors update (camera rate) updates slowly like +500ms , but it works , no other way (as I know) , and also you can keep holding KEY_AIM , so it sends on foot package faster ) .
NVM , let's go xD
Changelog:
Код:
v2.0 :
Fully controllable custom oxygen bar has been added.
Added new functions.
Fixed under water swim move.
Optimized swim/move styles.
Changed function IsPlayerInWaterEx to IsPlayerInCustomWater.
Added a simple example script in github.
v1.1 :
Added 4 types of water you can create with CreateWater
v1.0 (can be used without any bugs , fixed jumping issue)
Fixed jumping issue with addin invisible object.
Added 2 new parameter to CreateWater as world and interior.
v0.2 :
Added new function , DestroyWater(waterid);
Removed YSI(y_hook)
New optimizations (removing some loops and using extraid)
Unlimited water objects ! (create big waters as much as you want !)
v0.1 :
Released.
Video:
New version video including oxygen bar feature:
******* Video
Old Versions :
Click
Click On Meh -_-
PS : the music is lit I already know . LOL xD
Functions:
PHP код:
CreateWater(minx , miny , maxx , maxy , z , depth , world=-1 , interior=-1 , type=WATER_TYPE_NORMAL);
// Creates Water
// parameters : minx/y and maxx/y just works like making zones , z for water Z cord. and depth for its depth/height , world and interior for Virtual world and interiors , type for 4 water types
DestroyWater(waterid);
// returns 0 if ID is not available , returns 1 if it can destory water
IsPlayerInCustomWater(playerid);
// return 1 if player is in water and return 0 if not
IsPlayerUnderCustomWater(playerid);
// return 1 if player is under water and return 0 if not
GetPlayerWaterID(playerid);
// returns player's water ID which is swiming in it
GetWaterDepth(waterid);
// returns water's depth
GetPlayerSwimStyle(playerid);
// returns player's swiming style (only works with custom waters)
GetPlayerCustomOxygen(playerid);
// returns current oxygen value of player as a float variable
SetPlayerCustomOxygen(playerid, Float:ox_value);
// sets player's oxygen value
ShowCustomOxygenBarForPlayer(playerid);
// shows player's custom oxygen bar
HideCustomOxygenBarForPlayer(playerid);
// hides player's custom oxygen bar
Callbacks:
PHP код:
public OnPlayerEnterWater(playerid , waterid)
public OnPlayerLeaveWater(playerid , waterid)
// they'll be called when player enters/leaves water
Water Types:
PHP код:
enum
{
WATER_TYPE_LIGHT,
WATER_TYPE_NORMAL,
WATER_TYPE_DARK,
WATER_TYPE_CLOUDY
}
Swim Styles:
PHP код:
enum
{
SWIM_STYLE_IDLE_ON_WATER,
SWIM_STYLE_MOVE_ON_WATER,
SWIM_STYLE_DIVE_UNDER_WATER,
SWIM_STYLE_MOVE_UNDER_WATER,
SWIM_STYLE_COMING_UP,
SWIM_STYLE_MOVE_FAST_ON_WATER,
SWIM_STYLE_INVALID
}
Things you need:
Streamer - Plugin Thread >
https://sampforum.blast.hk/showthread.php?tid=102865
Download:
Github link
Credits:
Incognito - for Streamer Plugin
Bugs and Ideas:
feel free to share you ideas and report bugs here !
Re: CreateWater.inc | Create Custom Waters and Swim in them!! -
Gforcez - 20.12.2017
This is quite nice, good job!
Re: CreateWater.inc | Create Custom Waters and Swim in them!! -
biker122 - 20.12.2017
Indeed. Great work!
Re: CreateWater.inc | Create Custom Waters and Swim in them!! -
Kaperstone - 20.12.2017
I guess you got on the ramp because the edge has ended before it, can players go through walls while they swim?
Re: CreateWater.inc | Create Custom Waters and Swim in them!! -
iAmir - 20.12.2017
Quote:
Originally Posted by Kaperstone
I guess you got on the ramp because the edge has ended before it, can players go through walls while they swim?
|
No they do not go through walls , cause it uses velocity not positions.
Re: CreateWater.inc | Create Custom Waters and Swim in them!! -
pyrodojo25 - 20.12.2017
Nice! Maybe you could move an invisible object underneath the player to make the movement smoother?
Re: CreateWater.inc | Create Custom Waters and Swim in them!! -
Crayder - 20.12.2017
Not too shabby at all. Though I suggest, since you are already using y_hooks, you could use iterators instead of the way you are handling indexes and loops.
Nice job!
Re: CreateWater.inc | Create Custom Waters and Swim in them!! -
DRIFT_HUNTER - 20.12.2017
Try creating transparent player object with collision beneath player to avoid that jumpy sync.
Re: CreateWater.inc | Create Custom Waters and Swim in them!! -
iAmir - 20.12.2017
Quote:
Originally Posted by pyrodojo25
Nice! Maybe you could move an invisible object underneath the player to make the movement smoother?
|
Quote:
Originally Posted by DRIFT_HUNTER
Try creating transparent player object with collision beneath player to avoid that jumpy sync.
|
Maybe I think about some way tho.
Quote:
Originally Posted by Crayder
Not too shabby at all. Though I suggest, since you are already using y_hooks, you could use iterators instead of the way you are handling indexes and loops.
Nice job!
|
Actually I didn’t even want to use y_hook , just because people in here love it , I did, when u do ALS hook method they say why noy y_hook ? . I prefer not using a huge project with hundreds of files just for some small codes , so I’ll go back to ALS as soon as I get back to my system.
Re: CreateWater.inc | Create Custom Waters and Swim in them!! -
RogueDrifter - 20.12.2017
wondering how do you create the water? like how would i get the exact coords for it? will a map editor do it if i create the object you set the material to? btw good job +rep
Re: CreateWater.inc | Create Custom Waters and Swim in them!! -
iAmir - 21.12.2017
Quote:
Originally Posted by dani16
I see something very simple and useful, good job. But, objects do not consume memory, right?
|
I had something else in my mind like adding removing setting some vars for it , I edited my post.
Quote:
Originally Posted by RogueDrifter
wondering how do you create the water? like how would i get the exact coords for it? will a map editor do it if i create the object you set the material to? btw good job +rep
|
I’m using a square shaped object (not exactly square) , doing some math to get next square cords dud to I have the exact size of width and height of it. Check Te Code And U See !
Re: CreateWater.inc | Create Custom Waters and Swim in them!! -
PeanutButter - 21.12.2017
Does it work with boats?
Re: CreateWater.inc | Create Custom Waters and Swim in them!! -
iAmir - 21.12.2017
Quote:
Originally Posted by PeanutButter
Does it work with boats?
|
Nope , at least not yet.
Re: CreateWater.inc | Create Custom Waters and Swim in them!! -
amirab - 22.12.2017
You said you’re going to add oxygen bar in that thread
, anyway , GJ!
Re: CreateWater.inc | Create Custom Waters and Swim in them!! -
Kwarde - 23.12.2017
Nice! Might perhaps come in handy in the future in my current project. I will surely take a look at this later! (And hope there'll be some nice updates and improvements ^^)
Re: CreateWater.inc | Create Custom Waters and Swim in them!! -
iAmir - 23.12.2017
Quote:
Originally Posted by amirab
You said you’re going to add oxygen bar in that thread , anyway , GJ!
|
Quote:
Originally Posted by Kwarde
Nice! Might perhaps come in handy in the future in my current project. I will surely take a look at this later! (And hope there'll be some nice updates and improvements ^^)
|
Thanks , I’m working on new update , I’m gonna release it today maybe!
Re: CreateWater.inc | Create Custom Waters and Swim in them!! -
Ramin - 23.12.2017
Cool
Re: CreateWater.inc | Create Custom Waters and Swim in them!! -
SyS - 23.12.2017
Nice
Re: CreateWater.inc | Create Custom Waters and Swim in them!! -
Matz - 23.12.2017
Great idea
Re: CreateWater.inc | Create Custom Waters and Swim in them!! -
Arithmetic - 23.12.2017
Easy work.