Am.. it wouldn't work too? (check OnPlayerGiveDamage)
pawn Code:
#include <a_samp>
new TazerAcceso[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
TazerAcceso[playerid] = 0;
return true;
}
public OnPlayerDisconnect(playerid, reason)
{
TazerAcceso[playerid] = 0;
return true;
}
public OnPlayerDeath(playerid, killerid, reason)
{
TazerAcceso[playerid] = 0;
return true;
}
public OnPlayerUpdate(playerid)
{
if(TazerAcceso[playerid])
{
if(GetPlayerWeapon(playerid) == 0)
{
SetPlayerAttachedObject(playerid, 7, 18642, 6, 0.06, 0.01, 0.08, 180.0, 0.0, 0.0);
return true;
}
if(GetPlayerWeapon(playerid) != 0)
{
RemovePlayerAttachedObject(playerid, 7);
return true;
}
}
return true;
}
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
if(TazerAcceso[playerid])
{
if(GetPlayerWeapon(playerid) == 0)
{
ApplyAnimation(playerid, "KNIFE", "knife_3", 4.0, 0, 1, 1, 1, 1000);
SetTimerEx("TimerClear", 2000, false, "d", playerid);
if(IsPlayerConnected(damagedid))
{
new Float:health;
GetPlayerHealth(damagedid, health);
SetPlayerHealth(damagedid, health - 5.0);
SetTimerEx("TimerFall", 300, false, "d", damagedid);
TogglePlayerControllable(damagedid, 0);
SetTimerEx("Untaze", 20000, false, "i", damagedid);
}
}
}
return true;
}
forward Untaze(playerid);
public Untaze(playerid)
{
SendClientMessage(playerid, -1, "[Info:] You are not more Tased");
TogglePlayerControllable(playerid, 1);
return 1;
}
forward TimeClear(playerid);
public TimeClear(playerid)
{
ClearAnimations(playerid);
}
forward TimerFall(playerid);
public TimerFall(playerid)
{
ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
SetTimerEx("TimerClear",19700,false,"d",playerid);
}
forward TimerCrack(playerid);
public TimerCrack(playerid)
{
ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
SetTimerEx("TimeClear",19700,false,"d",playerid);
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/taser", cmdtext, true, 5) == 0)
{
if(TazerAcceso[playerid])
{
TazerAcceso[playerid] = 0;
RemovePlayerAttachedObject(playerid, 7);
SendClientMessage(playerid,-1,"[Info:] You turn off your taser, for turn on type /tazeron .");
SendClientMessage(playerid,-1,"[Info:] You turned off your taser! Remember to turn on it.");
}
else
{
TazerAcceso[playerid] = 1;
SetPlayerAttachedObject(playerid, 7, 18642, 6, 0.06, 0.01, 0.08, 180.0, 0.0, 0.0);
SendClientMessage(playerid,-1,"[Info:] Type /taser again to turn it off.");
SendClientMessage(playerid,-1,"[Info:] The taser will auto-equip when you select the fists.");
SendClientMessage(playerid,-1,"[Info:] For use the taser, you just need to punch with who you want use it.");
}
return true;
}
return false;
}