Tazer command.. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Tazer command.. (
/showthread.php?tid=353429)
Tazer command.. -
Euan Hughes - 23.06.2012
Hey so i have made a tazer command but i have a few problems when the tazer is meant to be recharging and i go to taze someone it sends me a message saying that the tazer is still recharging but it still tazes the person.. Also if they are in a car it still tazes them please help
pawn Код:
if(IsKeyJustDown(KEY_FIRE, newkeys, oldkeys))
{
new NearestPlayer = GetClosestPlayer(playerid), string[128];
if((gettime() - 12) < lastTaze[playerid]) return SendClientMessage(playerid, WHITE, "Your tazer is recharging");
if(Player[playerid][Group] == 1)
{
if(Player[playerid][HoldingTaser] == 1)
{
if(GetDistanceBetweenPlayers(playerid, GetClosestPlayer(playerid)) < 5)
{
format(string, sizeof(string), "%s has tazed %s with their tazer", GetNameNoUnderScore(playerid), GetNameNoUnderScore(GetClosestPlayer(playerid)));
NearByMessage(playerid, PURPLE, string);
if(IsPlayerInAnyVehicle(GetClosestPlayer(playerid))) return SendClientMessage(playerid, WHITE, "You can not taze someone that is in a car");
ApplyAnimation(playerid, "MUSCULAR", "Mscle_run_Csaw", 4.1, 0, 1, 1, 0, 0);
TogglePlayerControllable(GetClosestPlayer(playerid), 0);
SendClientMessage(GetClosestPlayer(playerid), YELLOW, "You have been tazed this will last for 12 seconds");
Player[GetClosestPlayer(playerid)][Tazed] = 1;
lastTaze[playerid] = gettime();
SetTimerEx("UntazePlayer", 12000, false, "d", NearestPlayer);
}
else
{
if((gettime() - 12) < lastTaze[playerid]) return SendClientMessage(playerid, WHITE, "Your tazer is recharging");
lastTaze[playerid] = gettime();
}
}
}
}
If you need any more code just ask
Thanks
Re: Tazer command.. -
Faisal_khan - 23.06.2012
Try this untested I have doubt if its working or not:
pawn Код:
if(IsKeyJustDown(KEY_FIRE, newkeys, oldkeys))
{
new NearestPlayer = GetClosestPlayer(playerid), string[128];
if((gettime() - 12) < lastTaze[playerid]) return SendClientMessage(playerid, WHITE, "Your tazer is recharging");
if(Player[playerid][Group] == 1)
{
if(Player[playerid][HoldingTaser] == 1)
{
if((GetDistanceBetweenPlayers(playerid, GetClosestPlayer(playerid)) < 5) && (!IsPlayerInAnyVehicle(GetClosestPlayer(playerid))))
{
format(string, sizeof(string), "%s has tazed %s with their tazer", GetNameNoUnderScore(playerid), GetNameNoUnderScore(GetClosestPlayer(playerid)));
NearByMessage(playerid, PURPLE, string);
ApplyAnimation(playerid, "MUSCULAR", "Mscle_run_Csaw", 4.1, 0, 1, 1, 0, 0);
TogglePlayerControllable(GetClosestPlayer(playerid), 0);
SendClientMessage(GetClosestPlayer(playerid), YELLOW, "You have been tazed this will last for 12 seconds");
Player[GetClosestPlayer(playerid)][Tazed] = 1;
lastTaze[playerid] = gettime();
SetTimerEx("UntazePlayer", 12000, false, "d", NearestPlayer);
}
else
{
if((gettime() - 12) < lastTaze[playerid]) return SendClientMessage(playerid, WHITE, "Your tazer is recharging");
lastTaze[playerid] = gettime();
}
}
}
}