im using this unconscious system.
Код:
///////////////////////
#include <a_samp>
#include "../include/gl_common.inc"
//--Settings--
#define DIZZ_WAIT 5 //Seconds to wait until player gets dizzy.
#define FULL_WAIT 40 //Seconds after becoming dizzy to wait until the player regains full control.
//------------
#define COLOR_NOTICE 0xFF7F00FF
forward RegainCons1(playerid);
forward RegainCons2(playerid);
forward DeathRC(playerid);
forward SimpleDrunk(playerid);
enum pInfo
{
pKO,
pDrunk,
};
new PlayerInfo[MAX_PLAYERS][pInfo];
new Keys,up,down;
new Float:PlayerHP;
new RC1tim;
new RC2tim;
new WaitSeconds = DIZZ_WAIT * 1000;
new RCWaitSeconds = FULL_WAIT * 1000;
public OnFilterScriptInit()
{
print("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
print("| SWEMike's Knockout |");
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new idx;
cmd = strtok(cmdtext, idx);
//--TEST--
if(IsPlayerAdmin(playerid))
{
if(strcmp(cmd, "/knockout", true) == 0)
{
SetPlayerHealth(playerid, 20);
return 1;
}
}
return 0;
}
public OnPlayerDeath(playerid, killerid, reason)
{
DeathRC(playerid);
return 1;
}
public OnPlayerUpdate(playerid)
{
GetPlayerKeys(playerid,Keys,up,down);
if(!IsPlayerInAnyVehicle(playerid))
{
if(PlayerInfo[playerid][pDrunk] == 1)
{
if(Keys == KEY_JUMP || Keys == KEY_SECONDARY_ATTACK || Keys == KEY_FIRE || Keys == KEY_ACTION || Keys == KEY_WALK)
{
SimpleDrunk(playerid);
}
}
}
new string[256];
GetPlayerHealth(playerid, PlayerHP);
if(PlayerHP <= 20 && PlayerInfo[playerid][pKO] == 0)
{
format(string, sizeof(string), "You have been knocked out, please wait %d seconds to regain your consciousness.", DIZZ_WAIT);
SendClientMessage(playerid, COLOR_NOTICE, string);
TogglePlayerControllable(playerid, true);
if(!IsPlayerInAnyVehicle(playerid))
{
ClearAnimations(playerid);
ApplyAnimation(playerid, "BEACH", "CRCKIDLE1", 4.1, 1, 1, 1, 1, 1);
}
RC1tim = SetTimerEx("RegainCons1", WaitSeconds, false, "i", playerid);
PlayerInfo[playerid][pKO] = 1;
}
else if(PlayerHP > 20 && PlayerInfo[playerid][pKO] == 1)
{
PlayerInfo[playerid][pKO] = 0;
SetPlayerDrunkLevel(playerid, 0);
ClearAnimations(playerid);
}
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
public RegainCons1(playerid)
{
SendClientMessage(playerid, COLOR_NOTICE, "You have regained your consciousness but you are very dizzy.");
TogglePlayerControllable(playerid, true);
SetPlayerDrunkLevel(playerid, 20000);
if(!IsPlayerInAnyVehicle(playerid))
{
ClearAnimations(playerid);
ApplyAnimation(playerid,"PED","WALK_DRUNK",4.1,1,1,1,1,1);
PlayerInfo[playerid][pDrunk] = 1;
}
RC2tim = SetTimerEx("RegainCons2", RCWaitSeconds, false, "i", playerid);
return 1;
}
public RegainCons2(playerid)
{
SendClientMessage(playerid, COLOR_NOTICE, "You have fully regained control over your body and can continue normally.");
SetPlayerDrunkLevel(playerid, 0);
PlayerInfo[playerid][pDrunk] = 0;
ClearAnimations(playerid);
return 1;
}
public DeathRC(playerid)
{
KillTimer(RC1tim);
KillTimer(RC2tim);
PlayerInfo[playerid][pKO] = 0;
SetPlayerDrunkLevel(playerid, 0);
PlayerInfo[playerid][pDrunk] = 0;
ClearAnimations(playerid);
return 1;
}
public SimpleDrunk(playerid)
{
ClearAnimations(playerid);
ApplyAnimation(playerid,"PED","WALK_DRUNK",4.1,1,1,1,1,1);
}
To remove the freezing effect just delete all instances of TogglePlayerControllable.
i changed it.
Now when i fall down i want to make it to be freezed on the fall animation ( i mean that the player will stay down for some seconds) how can i do it?
The function is ApplyAnimation(playerid, animlib[], animname[], Float:fDelta, loop, lockx, locky, freeze, time, forcesync). Setting "freeze" to 1 will freeze the animation at the end of it. If you want them to stand up after a few seconds you'll need to create a timer for ClearAnimations(playerid);