[Include] CreateWater.inc | Create Custom Waters and Swim in them!!
#1

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 depth world=-interior=-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(playeridFloat: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 !
Reply
#2

This is quite nice, good job!
Reply
#3

Indeed. Great work!
Reply
#4

I guess you got on the ramp because the edge has ended before it, can players go through walls while they swim?
Reply
#5

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

Nice! Maybe you could move an invisible object underneath the player to make the movement smoother?
Reply
#7

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

Try creating transparent player object with collision beneath player to avoid that jumpy sync.
Reply
#9

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

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

Quote:
Originally Posted by dani16
View Post
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
View Post
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 !
Reply
#12

Does it work with boats?
Reply
#13

Quote:
Originally Posted by PeanutButter
View Post
Does it work with boats?
Nope , at least not yet.
Reply
#14

You said you’re going to add oxygen bar in that thread , anyway , GJ!
Reply
#15

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 ^^)
Reply
#16

Quote:
Originally Posted by amirab
View Post
You said you’re going to add oxygen bar in that thread , anyway , GJ!
Quote:
Originally Posted by Kwarde
View Post
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!
Reply
#17

Cool
Reply
#18

Nice
Reply
#19

Great idea
Reply
#20

Easy work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)