SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 03/10/2017, 03:14 AM   #1
leon44
Huge Clucker
 
Join Date: Apr 2013
Posts: 239
Reputation: 3
Default Detect a vehicle when falling at water off

Hi, I have a mini derby game in my gamemode and and is missing that when a player throws other player off to water he will be as spectator, I just need that to complete it, but the player needs to be detected when is underwater and after that detection he will be auto killed.

Last edited by leon44; 04/10/2017 at 06:14 PM.
leon44 is offline   Reply With Quote
Old 03/10/2017, 03:21 AM   #2
DTV
Banned
 
Join Date: Dec 2010
Posts: 547
Reputation: 125
Default Re: Detect player when fell at water off

I've never made a detection script for something like that but something that I think can help is checking their position as whenever they're in the water, their z coord will be 0.0 or lower.
DTV is offline   Reply With Quote
Old 03/10/2017, 03:31 AM   #3
leon44
Huge Clucker
 
Join Date: Apr 2013
Posts: 239
Reputation: 3
Default Re: Detect player when fell at water off

Quote:
Originally Posted by DTV View Post
I've never made a detection script for something like that but something that I think can help is checking their position as whenever they're in the water, their z coord will be 0.0 or lower.
I've thought in something like this but I don't know if it will work, check it out:

Code:
forward WaterDetection();
public WaterDetection()
{
    new Float:Z;
    for(new i; i<MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        GetPlayerPos(i, Z, Z, Z);
        if(Z < 0.0) 
        {
            SetPlayerHealth(playerid, 0)
        }
    }
    return 1;
}
What do you think? Any other better way to make it?
leon44 is offline   Reply With Quote
Old 03/10/2017, 03:46 AM   #4
Dignity
High-roller
 
Dignity's Avatar
 
Join Date: May 2013
Location: Belgium
Posts: 1,661
Reputation: 1211
Default Re: Detect player when fell at water off

ColAndreas.

PHP Code:
CA_IsPlayerNearWater(playerid
Dignity is offline   Reply With Quote
Old 03/10/2017, 04:07 AM   #5
leon44
Huge Clucker
 
Join Date: Apr 2013
Posts: 239
Reputation: 3
Default Re: Detect player when fell at water off

Quote:
Originally Posted by Dignity View Post
ColAndreas.

PHP Code:
CA_IsPlayerNearWater(playerid
But I don't wanna check if the player is near of water, I need it to check it when he's under water.
leon44 is offline   Reply With Quote
Old 03/10/2017, 04:10 AM   #6
Dignity
High-roller
 
Dignity's Avatar
 
Join Date: May 2013
Location: Belgium
Posts: 1,661
Reputation: 1211
Default Re: Detect player when fell at water off

All water sources except the water behind the dam in Las Venturas are at 0.0, so you have to check below that.

The dam's water is at ~40.0, give or take a few.
Dignity is offline   Reply With Quote
Old 03/10/2017, 04:14 AM   #7
Swankeh
Big Clucker
 
Join Date: Jul 2017
Posts: 62
Reputation: 6
Default Re: Detect player when fell at water off

PHP Code:
public OnPlayerUpdate(playerid){
    new 
FloatPosXFloatPosYFloatPosZ;
    
GetPlayerPos(playeridPosXPosYPosZ);
    if(
PosZ 0.0){
    
SendClientMessage(playerid, -1"You are in the water");
    
//Your Code.
    
}
    return 
1;

Swankeh is offline   Reply With Quote
Old 03/10/2017, 07:10 AM   #8
leon44
Huge Clucker
 
Join Date: Apr 2013
Posts: 239
Reputation: 3
Default Re: Detect player when fell at water off

Quote:
Originally Posted by Swankeh View Post
PHP Code:
public OnPlayerUpdate(playerid){
    new 
FloatPosXFloatPosYFloatPosZ;
    
GetPlayerPos(playeridPosXPosYPosZ);
    if(
PosZ 0.0){
    
SendClientMessage(playerid, -1"You are in the water");
    
//Your Code.
    
}
    return 
1;

It worked good, thank you mate +rep
By the way, just one more thing, can I create a timer to run the action I wanna take, for example: the player fell at the water off and after 5 seconds he will be automatically killed by setplayerhealth.
leon44 is offline   Reply With Quote
Old 03/10/2017, 07:11 AM   #9
Dignity
High-roller
 
Dignity's Avatar
 
Join Date: May 2013
Location: Belgium
Posts: 1,661
Reputation: 1211
Default Re: Detect player when fell at water off

That won't work when you're behind the Las Venturas dam.
Dignity is offline   Reply With Quote
Old 03/10/2017, 07:15 AM   #10
leon44
Huge Clucker
 
Join Date: Apr 2013
Posts: 239
Reputation: 3
Default Re: Detect player when fell at water off

Quote:
Originally Posted by Dignity View Post
That won't work when you're behind the Las Venturas dam.
So instead of 0.0 need I to put 40.0? Because I want this works in all waters.
leon44 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
detect vehicle is in water COL Scripting Help 5 24/01/2014 05:37 PM
Is there a way to detect if the player is in water? K9IsGodly Scripting Help 5 10/01/2014 04:21 PM
Detect if player is in under water? Admigo Scripting Help 3 14/04/2012 03:10 PM
How to detect if player's car is in water? Outcast Help Archive 2 16/01/2011 04:21 PM
Detect if player is in water? Biscottinis Help Archive 2 20/06/2010 10:47 AM


All times are GMT. The time now is 04:09 PM.


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