31.05.2012, 20:44
Hi.. Could someone give me a helping hand and try to script a working automatic "crack" system, when player's health is 20 or lower. It should use animation "KO_spin_L " (from "PED" cate).
So what i need, is a timer which checks every, lets say 3 seconds, if someone's health is under 20 (easy timer). When their HP us under 20, they will be send in "KO_spin_L " animation, also frozen in it (ONLY ONCE, which gives me problems <.<). Only way to get out of this is next what i need:
I also need 2 commands, to get off from the "auto-crack". They should be like this:
- /getup, you could use /getup only after there has passed 2,5 minutes from when you fell in the "auto-crack" (I got problems with this... The timer of it fucked up after first /getup o.o)
- /helpup [ID], you could help someone up from "auto-crack" any time when you're near them. There should be animation "BOM_Plant" (from "BOMB" cate). Also, this animation should be ran for 7 seconds. (Or around 7 seconds) (Not so needed but would love it. Can add it later myself too if I want to :P)
If anyone can make this quick, just throw it to me via a PM. I'd be nice and slam you some rep+ of course.
I think someone already gave this to me, but it didn't work so well... It doesn't work for other players, and after the first /getup it's timer won't repeat after going next time in auto-crack (except after die'ing it works again, due to OnPlayerSpawn it'll repeat...)
So what i need, is a timer which checks every, lets say 3 seconds, if someone's health is under 20 (easy timer). When their HP us under 20, they will be send in "KO_spin_L " animation, also frozen in it (ONLY ONCE, which gives me problems <.<). Only way to get out of this is next what i need:
I also need 2 commands, to get off from the "auto-crack". They should be like this:
- /getup, you could use /getup only after there has passed 2,5 minutes from when you fell in the "auto-crack" (I got problems with this... The timer of it fucked up after first /getup o.o)
- /helpup [ID], you could help someone up from "auto-crack" any time when you're near them. There should be animation "BOM_Plant" (from "BOMB" cate). Also, this animation should be ran for 7 seconds. (Or around 7 seconds) (Not so needed but would love it. Can add it later myself too if I want to :P)
If anyone can make this quick, just throw it to me via a PM. I'd be nice and slam you some rep+ of course.
I think someone already gave this to me, but it didn't work so well... It doesn't work for other players, and after the first /getup it's timer won't repeat after going next time in auto-crack (except after die'ing it works again, due to OnPlayerSpawn it'll repeat...)
pawn Код:
#include a_samp
enum crack2
{
bool: is_cracked,
timer,
c_down,
bool:c_isover,
Float:health
};
new crack[MAX_PLAYERS][crack2];
forward Crack_Timer(playerid);
forward Count_Down(playerid);
public OnPlayerSpawn(playerid)
{
crack[playerid][is_cracked] = false;
crack[playerid][c_isover] = false;
crack[playerid][timer] = SetTimerEx("Crack_Timer",1500,true,"i",playerid);
crack[playerid][c_down] = SetTimerEx("Count_Down", 5 * 60 * 250, false, "i", playerid);
return 1;
}
public Crack_Timer(playerid)
{
GetPlayerHealth(playerid,crack[playerid][health]);
if( (crack[playerid][health] <= 20) && (crack[playerid][is_cracked] == false) )
{
if(crack[playerid][is_cracked] == false) crack[playerid][is_cracked] = true;
TogglePlayerControllable(playerid,false);
ApplyAnimation(playerid,"PED","KO_spin_L",2.8,0,1,1,1,0);
}
return 1;
}
public Count_Down(playerid)
{
if(crack[playerid][is_cracked] == true)
{
crack[playerid][c_isover] = true;
KillTimer(crack[playerid][timer]);
}
return 1;
}
PlayerToPlayer(playerid,toplayerid)
{
new Float:pos[2][3];
GetPlayerPos(playerid,pos[0][0],pos[0][1],pos[0][2]);
GetPlayerPos(toplayerid,pos[1][0],pos[1][1],pos[1][2]);
pos[0][0] -= pos[1][0];
pos[0][1] -= pos[1][1];
pos[0][2] -= pos[1][2];
return floatround( floatsqroot( (floatpower(pos[0][0],2) + floatpower(pos[0][1],2) + floatpower(pos[0][2],2) ) ), floatround_round);
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext,"/getup",true))
{
if( (crack[playerid][is_cracked] == true) && (crack[playerid][c_isover] == true))
{
SendClientMessage(playerid, -1, "You got up!");
crack[playerid][is_cracked] = false;
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
TogglePlayerControllable(playerid,true);
SetPlayerHealth(playerid, 25);
SetTimerEx("Crack_Timer",2000,true,"i",playerid);
}
return 1;
}
if(!strcmp(cmdtext,"/helpup",true,9))
{
if(!cmdtext[8]) SendClientMessage(playerid,-1,"USAGE: /helpup [ID]");
else if (PlayerToPlayer(playerid,cmdtext[9]) >= 5) SendClientMessage(playerid,-1,"Player too far!");
else if( (crack[cmdtext[9]][is_cracked] == true) && (cmdtext[9] != playerid))
{
ApplyAnimation(playerid,"BOMBER","BOM_Plant",2.6,1,1,1,0,6800);
crack[cmdtext[9]][is_cracked] = false;
crack[cmdtext[9]][c_isover] = false;
KillTimer(crack[cmdtext[9]][timer]);
KillTimer(crack[cmdtext[9]][c_down]);
SetPlayerSpecialAction(cmdtext[9],SPECIAL_ACTION_NONE);
}
return 1;
}
return 0;
}