[Include] Limex's Swimming Include (Detect swimming!)
#1

Limex's Swimming Include


Features 1 function, and 2 callbacks!

New function: IsPlayerSwimming(playerid)

New callbacks: OnPlayerStartSwimming(playerid) and OnPlayerStopSwimming(playerid)

HOW TO USE

Make a limex-swim.inc file in your includes folder!

Put the following code in it:

pawn Code:
/*  =============================

    Limex's Swimming Include
   
    Made by Limex / A
   
    New function:
    IsPlayerSwimming(playerid)
   
    New callbacks:
    OnPlayerStartSwimming(playerid)
    OnPlayerStopSwimming(playerid)
   
    Enjoy!

    ============================= */


#include <a_samp>

new bool:swimming[MAX_PLAYERS];

forward OnPlayerStartSwimming(playerid);
forward OnPlayerStopSwimming(playerid);
forward IsPlayerSwimming(playerid);

public IsPlayerSwimming(playerid)
{
    if(swimming[playerid]) return 1;
    return 0;
}

public OnPlayerUpdate(playerid)
{
    if(GetPlayerAnimationIndex(playerid))
    {
        new animlib[32];
        new animname[32];
        GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32);
        if(strcmp(animlib, "SWIM", true) == 0 && !swimming[playerid])
        {
            swimming[playerid] = true;
            OnPlayerStartSwimming(playerid);
        }
        else if(strcmp(animlib, "SWIM", true) != 0 && swimming[playerid] && strfind(animname, "jump", true) == -1)
        {
            swimming[playerid] = false;
            OnPlayerStopSwimming(playerid);
        }
    }
    else if(swimming[playerid])
    {
        swimming[playerid] = false;
        OnPlayerStopSwimming(playerid);
    }
    return 1;
}
Include it into your script with:

pawn Code:
#include <limex-swim>
You must add the following two callbacks into your script!

pawn Code:
public OnPlayerStartSwimming(playerid)
{
    // EXAMPLE CODE START //
    SendClientMessage(playerid, 0x33CCFFAA, "You started swimming!");
    // EXAMPLE CODE END //
    return 1;
}

public OnPlayerStopSwimming(playerid)
{
    // EXAMPLE CODE START //
    SendClientMessage(playerid, 0x33CCFFAA, "You stopped swimming!");
    // EXAMPLE CODE END //
    return 1;
}
Reply


Messages In This Thread
Limex's Swimming Include (Detect swimming!) - by Limex - 04.09.2010, 04:39
Re: Limex's Swimming Include (Detect swimming!) - by willsuckformoney - 04.09.2010, 05:22
Re: Limex's Swimming Include (Detect swimming!) - by WillyP - 04.09.2010, 11:12
Re: Limex's Swimming Include (Detect swimming!) - by Grim_ - 04.09.2010, 11:52
Re: Limex's Swimming Include (Detect swimming!) - by DiddyBop - 04.09.2010, 13:28
Re: Limex's Swimming Include (Detect swimming!) - by General Abe - 04.09.2010, 14:02
Re: Limex's Swimming Include (Detect swimming!) - by CYB3RN - 04.09.2010, 14:07
Re: Limex's Swimming Include (Detect swimming!) - by Mauzen - 04.09.2010, 14:11
Re: Limex's Swimming Include (Detect swimming!) - by Limex - 05.09.2010, 21:57
Re: Limex's Swimming Include (Detect swimming!) - by Hijolion - 06.09.2010, 21:54
Re: Limex's Swimming Include (Detect swimming!) - by Limex - 06.09.2010, 23:36
Re: Limex's Swimming Include (Detect swimming!) - by MrDeath537 - 07.09.2010, 01:03
Re: Limex's Swimming Include (Detect swimming!) - by willsuckformoney - 07.09.2010, 01:15
Re: Limex's Swimming Include (Detect swimming!) - by Limex - 12.09.2010, 02:37
Re: Limex's Swimming Include (Detect swimming!) - by willsuckformoney - 12.09.2010, 02:56
Re: Limex's Swimming Include (Detect swimming!) - by wups - 12.09.2010, 07:56
Re: Limex's Swimming Include (Detect swimming!) - by Limex - 12.11.2010, 21:26
Re: Limex's Swimming Include (Detect swimming!) - by Grim_ - 12.11.2010, 21:29
Re: Limex's Swimming Include (Detect swimming!) - by Hiddos - 12.11.2010, 21:30
Re: Limex's Swimming Include (Detect swimming!) - by dark_clown - 12.11.2010, 21:38
Re: Limex's Swimming Include (Detect swimming!) - by Gigi-The-Beast - 13.11.2010, 11:11
Re: Limex's Swimming Include (Detect swimming!) - by Grim_ - 13.11.2010, 17:48
Re: Limex's Swimming Include (Detect swimming!) - by Limex - 12.12.2010, 22:00
Re: Limex's Swimming Include (Detect swimming!) - by Mean - 24.12.2010, 14:37
Re: Limex's Swimming Include (Detect swimming!) - by Limex - 27.12.2010, 00:24
Re: Limex's Swimming Include (Detect swimming!) - by Bodo4you - 27.12.2010, 08:16
Re: Limex's Swimming Include (Detect swimming!) - by Lorenc_ - 27.12.2010, 08:38
Re: Limex's Swimming Include (Detect swimming!) - by Limex - 28.12.2010, 07:03
Re: Limex's Swimming Include (Detect swimming!) - by TheKingWillem - 28.12.2010, 14:09
Re: Limex's Swimming Include (Detect swimming!) - by wups - 28.12.2010, 14:38
Re: Limex's Swimming Include (Detect swimming!) - by Limex - 13.01.2011, 20:36
Re: Limex's Swimming Include (Detect swimming!) - by Gamer_Z - 07.06.2011, 01:21
Re: Limex's Swimming Include (Detect swimming!) - by Deskoft - 07.06.2011, 01:32
Re: Limex's Swimming Include (Detect swimming!) - by Gamer_Z - 07.06.2011, 01:40
Re: Limex's Swimming Include (Detect swimming!) - by Denisucoz - 27.05.2014, 16:02

Forum Jump:


Users browsing this thread: 1 Guest(s)