How to?
#4

I understand now, you need to use a timer to check if the players are on water, then, call the function.

Your include should be like this:
pawn Код:
#include <a_samp>

forward WaterChecking();

static max_players;

new bool:AlreadyInWater[MAX_PLAYERS];

public OnGameModeInit()
{  
    max_players = GetMaxPlayers();
    SetTimer("WaterChecking", 1000, true);
    return CallLocalFunction("H_OnGameModeInit","");
}


public WaterChecking()
{
    for(new i = 0; i < max_players; i++)
    {
        if(IsPlayerConnected(i) && !IsPlayerNPC(i))
        {
             if(PlayerInWater(i))
             {
                 if(!AlreadyInWater[i])
                 {
                     CallLocalFunction("IsPlayerInWater", "d", playerid);
                     AlreadyInWater[i] = true;
                 }                
             }
             else
             {
                 AlreadyInWater[i] = false;                
             }    
        }
    }
    return 1;
}

PlayerInWater(playerid)
{
    new animlib[32],tmp[32];
    GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,tmp,32);
    if(!strcmp(animlib, "SWIM") && !IsPlayerInAnyVehicle(playerid)) return true;
    return false;
}

#if defined _ALS_OnGameModeInit
    #undef OnGameModeInit
#else
    #define _ALS_OnGameModeInit
#endif
#define OnGameModeInit H_OnGameModeInit
forward H_OnGameModeInit();
Reply


Messages In This Thread
How to? - by [BFK]MetalHead - 30.01.2012, 13:51
Re: How to? - by CyNiC - 30.01.2012, 14:10
Re: How to? - by [BFK]MetalHead - 30.01.2012, 14:13
Re: How to? - by CyNiC - 30.01.2012, 14:32
Re: How to? - by [BFK]MetalHead - 30.01.2012, 14:35

Forum Jump:


Users browsing this thread: 1 Guest(s)