Detect player when fell at water off
#1

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

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

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?
Reply
#4

ColAndreas.

PHP Code:
CA_IsPlayerNearWater(playerid
Reply
#5

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

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

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;

Reply
#8

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

That won't work when you're behind the Las Venturas dam.
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)