Here's some example, hope it will help. This will set movetype to fly (not noclip) whenever you press Secondary attack. Press it once more and you will return to default MOVETYPE. Take a note that you may need to fully stop, before you can return to default MOVETYPE.
You can use this as a base. I suggest you check following FLAGS and what they do and if they works.
#define FL_INWATER (1 << 9) // In water
#define FL_FLY (1 << 10) // Changes the SV_Movestep() behavior to not need to be on ground
#define FL_SWIM
EDIT: It seems its just information flags and they not affecting actual game (pretty much like event). When player is in water he have INWATER flag etc. You can check these flags and if he is in vater you can set clients move type (though i dont know if FLY is right movement type for swimming).
EDIT 2: Almost forgot you need SM 1.3 to use OnPlayerRunCmd function.
PHP Code:
#define PLUGIN_VERSION "1.0"
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1
new bool:InFly[MAXPLAYERS+1];
public Plugin:myinfo =
// SetEntDataFloat(
{
name = "TEST CODE",
author = "Olj",
description = "WANNA FLY BABY?",
version = PLUGIN_VERSION,
url = "http://www.sourcemod.net/"
}
public OnPluginStart()
{
for (new i = 1; i <=MaxClients; i++)
{
InFly[i] = false;
}
}
public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
{
if (client==0) return Plugin_Continue;
if (buttons & IN_ATTACK2)
{
if (!InFly[client])
{
SetEntityMoveType(client, MOVETYPE_FLY);
InFly[client] = true;
return Plugin_Continue;
}
else if (InFly[client])
{
SetEntityMoveType(client, MOVETYPE_CUSTOM);
InFly[client] = false;
return Plugin_Continue;
}
}
return Plugin_Continue;
}
__________________