Tazing timer
#1

Hello,

I just made a tazer for cops using a include.
I made this script:

Код:
public OnPlayerShootPlayer(shooter,target,Float:damage)
{
    if(GetPlayerWeapon(shooter) == 23)
    {
  		if(IsACop[shooter] == 1 && OnDuty[shooter] == 1)
		{
		    if(IsACop[target] == 1 && OnDuty[target] == 1)
		    {
		        SendClientMessage(shooter, COLOR_GREY, "  You can't taze cops.");
		        return 1;
			}
        	new otherplayer = target;
        	new Float:Pos[3];
        	GetPlayerPos(otherplayer, Pos[0], Pos[1], Pos[2]);
        	if(!IsPlayerConnected(otherplayer)) return SendClientMessage(shooter,COLOR_RED,"  Bad Playerid.");

			new string[256], name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
			GetPlayerName(shooter, name, sizeof(name));
			GetPlayerName(otherplayer, name2, sizeof(name2));

			if(IsPlayerInRangeOfPoint(shooter, 10, Pos[0], Pos[1], Pos[2]))
   			{
    			format(string, sizeof(string), "* You were Tazed by %s.", name);
				SendClientMessage(otherplayer, COLOR_WHITE, string);
				format(string, sizeof(string), "* You Tazed %s.", name2);
				SendClientMessage(shooter, COLOR_WHITE, string);
				format(string, sizeof(string), "* %s shoots with his Tazer at %s and tazed him.", name ,name2);
				ProxDetector(30.0, shooter, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				GameTextForPlayer(otherplayer, "~r~Tazed", 2500, 3);
				TogglePlayerControllable(otherplayer, 0);
				LoopingAnim(otherplayer, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
			}
			else
			{
			    SendClientMessage(shooter, COLOR_YELLOW, "  The player you want to taze is too far away.");
			}
		}
		else
		{
		    SendClientMessage(shooter, COLOR_GREY, "  You must be a LEO 'On Duty' to taze someone.");
  		}
  		return 1;
    }
    return 1;
}
So what the problem is, I can't really make a timer to stop the
tazer effect on the target. I don't exactly know how to do that.

Can someone give me tips?

Thanks!
Reply
#2

https://sampwiki.blast.hk/wiki/SetTimer
https://sampwiki.blast.hk/wiki/SetTimerEx
https://sampwiki.blast.hk/wiki/KillTimer
Reply
#3

doesn't help, i need something that fits my script..
I NEED help from a advanced scripter.
Reply
#4

pawn Код:
public OnPlayerShootPlayer(shooter,target,Float:damage)
{
    if(GetPlayerWeapon(shooter) == 23)
    {
        if(IsACop[shooter] == 1 && OnDuty[shooter] == 1)
        {
            if(IsACop[target] == 1 && OnDuty[target] == 1)
            {
                SendClientMessage(shooter, COLOR_GREY, "  You can't taze cops.");
                return 1;
            }
            new otherplayer = target;
            new Float:Pos[3];
            GetPlayerPos(otherplayer, Pos[0], Pos[1], Pos[2]);
            if(!IsPlayerConnected(otherplayer)) return SendClientMessage(shooter,COLOR_RED,"  Bad Playerid.");

            new string[256], name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
            GetPlayerName(shooter, name, sizeof(name));
            GetPlayerName(otherplayer, name2, sizeof(name2));

            if(IsPlayerInRangeOfPoint(shooter, 10, Pos[0], Pos[1], Pos[2]))
            {
                format(string, sizeof(string), "* You were Tazed by %s.", name);
                SendClientMessage(otherplayer, COLOR_WHITE, string);
                format(string, sizeof(string), "* You Tazed %s.", name2);
                SendClientMessage(shooter, COLOR_WHITE, string);
                format(string, sizeof(string), "* %s shoots with his Tazer at %s and tazed him.", name ,name2);
                ProxDetector(30.0, shooter, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                GameTextForPlayer(otherplayer, "~r~Tazed", 2500, 3);
                TogglePlayerControllable(otherplayer, 0);
                LoopingAnim(otherplayer, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
                SetTimerEx("unfreeze",20000,false,"d",target);
            }
            else
            {
                SendClientMessage(shooter, COLOR_YELLOW, "  The player you want to taze is too far away.");
            }
        }
        else
        {
            SendClientMessage(shooter, COLOR_GREY, "  You must be a LEO 'On Duty' to taze someone.");
        }
        return 1;
    }
    return 1;
}

public unfreeze(playerid)
{
    new name[MAX_PLAYER_NAME], str[128], Float:X,Float:Y,Float:Z;
    ClearAnimations(playerid);
    TogglePlayerControllable(playerid, 1);
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    format(str, 128, "%s stumbles up to his feet.", name);
    GetPlayerPos(playerid,X,Y,Z);
    foreach(Player, i)
    {
        If(IsPlayerInRangeOfPoint(i, 40.0, X,Y,Z)
        {
            SendClientMessage(i, 0x9900FF, str);
            return 1;
        }
    }
    return 1;
}
UNTESTED.
Reply
#5

You dont need to be advanced scripter to create timers -.-
pawn Код:
// at the top
forward Tazed(playerid);
pawn Код:
public OnPlayerShootPlayer(shooter,target,Float:damage)
{
    if(GetPlayerWeapon(shooter) == 23)
    {
        if(IsACop[shooter] == 1 && OnDuty[shooter] == 1)
        {
            if(IsACop[target] == 1 && OnDuty[target] == 1)
            {
                SendClientMessage(shooter, COLOR_GREY, "  You can't taze cops.");
                return 1;
            }
            new otherplayer = target;
            new Float:Pos[3];
            GetPlayerPos(otherplayer, Pos[0], Pos[1], Pos[2]);
            if(!IsPlayerConnected(otherplayer)) return SendClientMessage(shooter,COLOR_RED,"  Bad Playerid.");

            new string[256], name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
            GetPlayerName(shooter, name, sizeof(name));
            GetPlayerName(otherplayer, name2, sizeof(name2));

            if(IsPlayerInRangeOfPoint(shooter, 10, Pos[0], Pos[1], Pos[2]))
            {
                format(string, sizeof(string), "* You were Tazed by %s.", name);
                SendClientMessage(otherplayer, COLOR_WHITE, string);
                format(string, sizeof(string), "* You Tazed %s.", name2);
                SendClientMessage(shooter, COLOR_WHITE, string);
                format(string, sizeof(string), "* %s shoots with his Tazer at %s and tazed him.", name ,name2);
                ProxDetector(30.0, shooter, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                GameTextForPlayer(otherplayer, "~r~Tazed", 2500, 3);
                TogglePlayerControllable(otherplayer, 0);
                LoopingAnim(otherplayer, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
                                             SetTimerEx("Tazed",8*1000,true,"i",playerid);
            }
            else
            {
                SendClientMessage(shooter, COLOR_YELLOW, "  The player you want to taze is too far away.");
            }
        }
        else
        {
            SendClientMessage(shooter, COLOR_GREY, "  You must be a LEO 'On Duty' to taze someone.");
        }
        return 1;
    }
    return 1;
}
pawn Код:
//somewhere not in a function/callback
public Tazed(playerid)
{
    TogglePlayerControllable(playerid,1);
    ClearAnimations(playerid);
    SendClientMessage(playerid,color,"You are now un-tazed!");
    return 1;
}
EDIT:
Quote:
pawn Код:
new name[MAX_PLAYER_NAME], str[128], X,Y,Z;
X,Y,Z are Floats. So..
pawn Код:
new Float:X, Float:Y, Float:Z;
AND use ProxDetector
Reply
#6

Quote:
Originally Posted by Marricio
Посмотреть сообщение
SetTimerEx("Tazed",8*1000,true,"i",playerid);
[/pawn]

EDIT:

X,Y,Z are Floats. So..
pawn Код:
new Float:X, Float:Y, Float:Z;
AND use ProxDetector
Fuck ProxDetector I don't like it.
Thanks for the Float:X,Y,Z tho.
Also,
Why did you use 'playerid' not 'shooter'?
That's most likely useless...
Reply
#7

If you mean in the Timer thanks, i didn't notice. Im not used to OnPlayerShootPlayer :P

pawn Код:
public OnPlayerShootPlayer(shooter,target,Float:damage)
{
    if(GetPlayerWeapon(shooter) == 23)
    {
        if(IsACop[shooter] == 1 && OnDuty[shooter] == 1)
        {
            if(IsACop[target] == 1 && OnDuty[target] == 1)
            {
                SendClientMessage(shooter, COLOR_GREY, "  You can't taze cops.");
                return 1;
            }
            new otherplayer = target;
            new Float:Pos[3];
            GetPlayerPos(otherplayer, Pos[0], Pos[1], Pos[2]);
            if(!IsPlayerConnected(otherplayer)) return SendClientMessage(shooter,COLOR_RED,"  Bad Playerid.");

            new string[256], name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
            GetPlayerName(shooter, name, sizeof(name));
            GetPlayerName(otherplayer, name2, sizeof(name2));

            if(IsPlayerInRangeOfPoint(shooter, 10, Pos[0], Pos[1], Pos[2]))
            {
                format(string, sizeof(string), "* You were Tazed by %s.", name);
                SendClientMessage(otherplayer, COLOR_WHITE, string);
                format(string, sizeof(string), "* You Tazed %s.", name2);
                SendClientMessage(shooter, COLOR_WHITE, string);
                format(string, sizeof(string), "* %s shoots with his Tazer at %s and tazed him.", name ,name2);
                ProxDetector(30.0, shooter, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                GameTextForPlayer(otherplayer, "~r~Tazed", 2500, 3);
                TogglePlayerControllable(otherplayer, 0);
                LoopingAnim(otherplayer, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
                                             SetTimerEx("Tazed",8*1000,true,"i",target); // or otherplayer
            }
            else
            {
                SendClientMessage(shooter, COLOR_YELLOW, "  The player you want to taze is too far away.");
            }
        }
        else
        {
            SendClientMessage(shooter, COLOR_GREY, "  You must be a LEO 'On Duty' to taze someone.");
        }
        return 1;
    }
    return 1;
}
Reply
#8

Quote:
Originally Posted by Marricio
Посмотреть сообщение
If you mean in the Timer thanks, i didn't notice. Im not used to OnPlayerShootPlayer :P

pawn Код:
public OnPlayerShootPlayer(shooter,target,Float:damage)
{
    if(GetPlayerWeapon(shooter) == 23)
    {
        if(IsACop[shooter] == 1 && OnDuty[shooter] == 1)
        {
            if(IsACop[target] == 1 && OnDuty[target] == 1)
            {
                SendClientMessage(shooter, COLOR_GREY, "  You can't taze cops.");
                return 1;
            }
            new otherplayer = target;
            new Float:Pos[3];
            GetPlayerPos(otherplayer, Pos[0], Pos[1], Pos[2]);
            if(!IsPlayerConnected(otherplayer)) return SendClientMessage(shooter,COLOR_RED,"  Bad Playerid.");

            new string[256], name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
            GetPlayerName(shooter, name, sizeof(name));
            GetPlayerName(otherplayer, name2, sizeof(name2));

            if(IsPlayerInRangeOfPoint(shooter, 10, Pos[0], Pos[1], Pos[2]))
            {
                format(string, sizeof(string), "* You were Tazed by %s.", name);
                SendClientMessage(otherplayer, COLOR_WHITE, string);
                format(string, sizeof(string), "* You Tazed %s.", name2);
                SendClientMessage(shooter, COLOR_WHITE, string);
                format(string, sizeof(string), "* %s shoots with his Tazer at %s and tazed him.", name ,name2);
                ProxDetector(30.0, shooter, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                GameTextForPlayer(otherplayer, "~r~Tazed", 2500, 3);
                TogglePlayerControllable(otherplayer, 0);
                LoopingAnim(otherplayer, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
                                             SetTimerEx("Tazed",8*1000,true,"i",target); // or otherplayer
            }
            else
            {
                SendClientMessage(shooter, COLOR_YELLOW, "  The player you want to taze is too far away.");
            }
        }
        else
        {
            SendClientMessage(shooter, COLOR_GREY, "  You must be a LEO 'On Duty' to taze someone.");
        }
        return 1;
    }
    return 1;
}
I didn't even know it exists :P
Reply
#9

Quote:
Originally Posted by maramizo
Посмотреть сообщение
pawn Код:
public OnPlayerShootPlayer(shooter,target,Float:damage)
{
    if(GetPlayerWeapon(shooter) == 23)
    {
        if(IsACop[shooter] == 1 && OnDuty[shooter] == 1)
        {
            if(IsACop[target] == 1 && OnDuty[target] == 1)
            {
                SendClientMessage(shooter, COLOR_GREY, "  You can't taze cops.");
                return 1;
            }
            new otherplayer = target;
            new Float:Pos[3];
            GetPlayerPos(otherplayer, Pos[0], Pos[1], Pos[2]);
            if(!IsPlayerConnected(otherplayer)) return SendClientMessage(shooter,COLOR_RED,"  Bad Playerid.");

            new string[256], name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
            GetPlayerName(shooter, name, sizeof(name));
            GetPlayerName(otherplayer, name2, sizeof(name2));

            if(IsPlayerInRangeOfPoint(shooter, 10, Pos[0], Pos[1], Pos[2]))
            {
                format(string, sizeof(string), "* You were Tazed by %s.", name);
                SendClientMessage(otherplayer, COLOR_WHITE, string);
                format(string, sizeof(string), "* You Tazed %s.", name2);
                SendClientMessage(shooter, COLOR_WHITE, string);
                format(string, sizeof(string), "* %s shoots with his Tazer at %s and tazed him.", name ,name2);
                ProxDetector(30.0, shooter, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                GameTextForPlayer(otherplayer, "~r~Tazed", 2500, 3);
                TogglePlayerControllable(otherplayer, 0);
                LoopingAnim(otherplayer, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
                SetTimerEx("unfreeze",20000,false,"d",target);
            }
            else
            {
                SendClientMessage(shooter, COLOR_YELLOW, "  The player you want to taze is too far away.");
            }
        }
        else
        {
            SendClientMessage(shooter, COLOR_GREY, "  You must be a LEO 'On Duty' to taze someone.");
        }
        return 1;
    }
    return 1;
}

public unfreeze(playerid)
{
    new name[MAX_PLAYER_NAME], str[128], Float:X,Float:Y,Float:Z;
    ClearAnimations(playerid);
    TogglePlayerControllable(playerid, 1);
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    format(str, 128, "%s stumbles up to his feet.", name);
    GetPlayerPos(playerid,X,Y,Z);
    foreach(Player, i)
    {
        If(IsPlayerInRangeOfPoint(i, 40.0, X,Y,Z)
        {
            SendClientMessage(i, 0x9900FF, str);
            return 1;
        }
    }
    return 1;
}
UNTESTED.
Thank you very much, your method worked.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)