SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 20/12/2017, 08:53 AM   #1
iAmir
Big Clucker
 
iAmir's Avatar
 
Join Date: May 2017
Posts: 84
Reputation: 133
Exclamation CreateWater.inc | Create Custom Waters and Swim in them!

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 :
Code:
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:
Code:
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 Code:

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 Code:
public OnPlayerEnterWater(playerid waterid)
public 
OnPlayerLeaveWater(playerid waterid)
// they'll be called when player enters/leaves water 
Water Types:
PHP Code:
enum
{
    
WATER_TYPE_LIGHT,
    
WATER_TYPE_NORMAL,
    
WATER_TYPE_DARK,
    
WATER_TYPE_CLOUDY

Swim Styles:
PHP Code:
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 > http://forum.sa-mp.com/showthread.php?t=102865

Download:

Github link


Credits:

Incognito - for Streamer Plugin

Bugs and Ideas:
feel free to share you ideas and report bugs here !
__________________
Quote:
Originally Posted by Freshncool
haha

Last edited by iAmir; 08/07/2018 at 09:19 PM.
iAmir is offline   Reply With Quote
Old 20/12/2017, 09:25 AM   #2
Gforcez1337
High-roller
 
Gforcez1337's Avatar
 
Join Date: Jul 2010
Location: The Netherlands.
Posts: 1,102
Reputation: 367
Default Re: CreateWater.inc | Create Custom Waters and Swim in them!!

This is quite nice, good job!
__________________

Gforcez1337 is online now   Reply With Quote
Old 20/12/2017, 09:39 AM   #3
biker122
Gangsta
 
Join Date: Feb 2014
Posts: 775
Reputation: 59
Default Re: CreateWater.inc | Create Custom Waters and Swim in them!!

Indeed. Great work!
__________________
k
biker122 is offline   Reply With Quote
Old 20/12/2017, 09:47 AM   #4
Kaperstone
High-roller
 
Kaperstone's Avatar
 
Join Date: May 2011
Location: Russia
Posts: 3,352
Reputation: 824
Default Re: CreateWater.inc | Create Custom Waters and Swim in them!!

I guess you got on the ramp because the edge has ended before it, can players go through walls while they swim?
__________________
Kaperstone is offline   Reply With Quote
Old 20/12/2017, 09:58 AM   #5
iAmir
Big Clucker
 
iAmir's Avatar
 
Join Date: May 2017
Posts: 84
Reputation: 133
Default Re: CreateWater.inc | Create Custom Waters and Swim in them!!

Quote:
Originally Posted by Kaperstone View Post
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.
__________________
Quote:
Originally Posted by Freshncool
haha
iAmir is offline   Reply With Quote
Old 20/12/2017, 10:01 AM   #6
pyrodojo25
Big Clucker
 
pyrodojo25's Avatar
 
Join Date: Mar 2012
Location: ::1
Posts: 52
Reputation: 2
Default Re: CreateWater.inc | Create Custom Waters and Swim in them!!

Nice! Maybe you could move an invisible object underneath the player to make the movement smoother?
pyrodojo25 is offline   Reply With Quote
Old 20/12/2017, 10:47 AM   #7
Crayder
High-roller
 
Crayder's Avatar
 
Join Date: Sep 2013
Location: Flames of Hell
Posts: 3,864
Reputation: 589
Default Re: CreateWater.inc | Create Custom Waters and Swim in them!!

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!
__________________
Those who deserve reputation, do not need to beg for it.
Also, don't expect the help you need when offering reputation, you'll just be attracting Rep Hunters.
Join SA-MP Discord!
Crayder is offline   Reply With Quote
Old 20/12/2017, 03:04 PM   #8
DRIFT_HUNTER
High-roller
 
Join Date: Oct 2009
Posts: 2,144
Reputation: 169
Default Re: CreateWater.inc | Create Custom Waters and Swim in them!!

Try creating transparent player object with collision beneath player to avoid that jumpy sync.
__________________
Путин here,
Путин there,
Путин просто everywhere.


Any PM's that include question about any kind of help will be ignored.
Use appropriate boards for that
DRIFT_HUNTER is offline   Reply With Quote
Old 20/12/2017, 03:27 PM   #9
iAmir
Big Clucker
 
iAmir's Avatar
 
Join Date: May 2017
Posts: 84
Reputation: 133
Default Re: CreateWater.inc | Create Custom Waters and Swim in them!!

Quote:
Originally Posted by pyrodojo25 View Post
Nice! Maybe you could move an invisible object underneath the player to make the movement smoother?
Quote:
Originally Posted by DRIFT_HUNTER View Post
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 View Post
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.
__________________
Quote:
Originally Posted by Freshncool
haha

Last edited by iAmir; 21/12/2017 at 03:56 AM.
iAmir is offline   Reply With Quote
Old 20/12/2017, 11:33 PM   #10
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,565
Reputation: 338
Default Re: CreateWater.inc | Create Custom Waters and Swim in them!!

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
__________________
Code:
I'm available to script stuff for cash PM me here or on discord @ Andy[RDZ]#0040
[Tutorial]:Anti-cheat guide ||Mini-game 101||VC/LC maps install||
Array index out of bounds


[Github]:Link [Pastebin]:Link [Forum]:Link [Server]:Link [Discord]:Link


RogueDrifter is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I create my own include file for my custom map? terasss2 Scripting Help 3 30/01/2015 05:19 PM
How to create this custom class menu Kanoru Scripting Help 1 25/12/2014 07:55 PM
Create Custom Model Object help me chuck100 Scripting Help 1 27/05/2013 01:07 PM
[Map] [Help] How can I create a custom interior? InsaniManES Maps 7 24/03/2011 07:50 AM


All times are GMT. The time now is 08:15 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.