SA-MP Forums Archive
[Tutorial] SD Pistol Tazer using OnPlayerShootPlayer - 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)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] SD Pistol Tazer using OnPlayerShootPlayer (/showthread.php?tid=272548)

Pages: 1 2


SD Pistol Tazer using OnPlayerShootPlayer - GangsTa_ - 28.07.2011


Introduction:

Alright, many of you been asking how to make a silenced pistol tazer for RP servers. I'll give you out an example using OnPlayerShootPlayer callback by wups. I just had nothing to do, made this script for my own upcoming server, and decided to share it with others. This is a bit like the LS:RP tazer script, just like the same.
Let's get it started already!

STEP 1:

As I've stated above, you'll need OnPlayerShootPlayer callback made by wups. You can download it here:

https://sampforum.blast.hk/showthread.php?tid=195439

All credits are going to WUPS who made this callback. Let's download it and put it in pawno/include folder. There's only a pastebin version, so edit a .inc file and copy & paste the pastebin content to the .inc file. I suggest you to name the file 'OPSP'.

So, you made it. Let's move to the next step.

STEP 2:

Alright, so we put the include into the pawno/include directory. After we're done with this, open your gamemode, and add the following line to the top of your gamemode!

pawn Код:
#include <OPSP>


This is the .inc file which we put into the include folder and we will need this for the tazer system.

STEP 3:

Add the OnPlayerShootPlayer callback somewhere into your script...

pawn Код:
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)
{
    return 1;
}

STEP 4:

Okay, if you'd like to make the tazer working only for a specific team, for example 'TEAM_COPS', then we'll make it only for cops.

Add the following line under OnPlayerShootPlayer.

pawn Код:
if(gTeam[Shooter] == TEAM_COPS)

It should look like:

pawn Код:
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)
{
    if(gTeam[Shooter] == TEAM_COPS)
    {
   
    }
    return 1;
}

STEP 5:

Ok, we're making it only for the cops team.

Now we need to make it only for the silenced pistol, so add the following line after the gTeam 'if':

pawn Код:
if(GetPlayerWeapon(Shooter) == 23)

Should look like this:

pawn Код:
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)
{
    if(gTeam[Shooter] == TEAM_COPS)
    {
        if(GetPlayerWeapon(Shooter) == 23)
        {
           
        }
    }
    return 1;
}

STEP 6:

Ok, we're starting the script now. Now we'll force the player to use an animation when getting tazed, then the player will get frozen.

pawn Код:
TogglePlayerControllable(Target, false);
ApplyAnimation(Target,"CRACK","crckdeth2",4.1,1,1,1,1,1);

STEP 7:

Now we're making the timer and the variable.

The variable:

At the top of your script:

pawn Код:
new pTazed[MAX_PLAYERS];

Under OnPlayerConnect:

pawn Код:
pTazed[playerid] = 0;

_________________________________________

The timer is easy, just do the following:

At the top of the script:

pawn Код:
forward Tazed(playerid);

Somewhere in the script:

pawn Код:
public Tazed(playerid)
{
      pTazed[playerid] = 0;
      TogglePlayerControllable(playerid, true);
      ClearAnimations(playerid);
      return 1;
}

_________________________________________

Let's go back to OPSP.

STEP 8:

When the player gets tazed we'll set the variable to TRUE and start the timer, with sending an advising message:

pawn Код:
pTazed[Target] = 1;
SetTimerEx("Tazed", 10000, 0, "d", Target);
SendClientMessage(Target, 0xFF0000FF, "You've been tazed for 10 seconds!");

Overall OPSP callback:

pawn Код:
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)
{
    if(gTeam[Shooter] == TEAM_COPS)
    {
        if(GetPlayerWeapon(Shooter) == 23)
        {
            TogglePlayerControllable(Target, false);
            ApplyAnimation(Target,"CRACK","crckdeth2",4.1,1,1,1,1,1);
            pTazed[Target] = 1;
            SetTimerEx("Tazed", 10000, 0, "d", Target);
            SendClientMessage(Target, 0xFF0000FF, "You've been tazed for 10 seconds!");
        }
    }
    return 1;
}

The system is done, but let's not forget about grabbing the SD...

STEP 9:

Add the following variable to your top of the script:

pawn Код:
new pTazer[MAX_PLAYERS];

Under OnPlayerConnect (So the variable will be set as FALSE):

pawn Код:
pTazer[playerid] = 0;

STEP 10:

Tazer command:

pawn Код:
if(strcmp(cmd, "/tazer", true) ==0 || strcmp(cmd, "/ta", true) ==0)
{
// We make it again for TEAM_COPS
    if(gTeam[playerid] == TEAM_COPS) // For cops
    {
        if(IsPlayerInAnyVehicle(playerid)) // Checks if the player is in a vehicle.
        {
            SendClientMessage(playerid, 0xFF0000FF, "You can't use this command while in a car!");
            return 1;
        }
        if(pTazer[playerid] == 0) // If the player has no tazer withdrawn.
        {
            GivePlayerWeapon(playerid, 23, 20); // Gives a SD.
            pTazer[playerid] = 1; // Sets the var to true.
            return 1;
        }
        else if(pTazer[playerid == 1) // If the player has the tazer withdrawn to holster it.
        {
            GivePlayerWeapon(playerid, 24, 100); // Gives a deagle.
            pTazer[playerid] = 0; // Sets the var to false.
            return 1;
        }
    }// Not a cop.
    return 1;
}

* Everything commented above.

Well, I guess it should be done!

Have fun, more than 50% of credits are going to wups for his awesome OPSP function.

- I'm sorry if I didn't make it with more BBCodes, organized and so on, I was in hurry because it's night and I'm tired...

Kindest regards,
GangsTa_



Re: SD Pistol Tazer using OnPlayerShootPlayer - Kaperstone - 28.07.2011

awasome
very useful for me..
i will use it...


Re: SD Pistol Tazer using OnPlayerShootPlayer - GangsTa_ - 28.07.2011

Thanks. Good luck.


Re: SD Pistol Tazer using OnPlayerShootPlayer - Mikkel_Pedersen - 28.07.2011

pawn Код:
SetTimer("Tazed", 10000, 0);
It should be:
pawn Код:
SetTimerEx("Tazed", 10000, 0, "d", Target);
Because your "Tazed" function needs the 'playerid' parameter.


Re: SD Pistol Tazer using OnPlayerShootPlayer - GangsTa_ - 28.07.2011

Maybe, I'll fix tomorrow, I'm off.


Re: SD Pistol Tazer using OnPlayerShootPlayer - wups - 28.07.2011

As far as i know, the animation will disappear(like ClearAnimations) if you're being freezed after ApplyAnimation.

Nice tutorial though.


Re: SD Pistol Tazer using OnPlayerShootPlayer - Guest3598475934857938411 - 29.07.2011

Nice tutorial, colourful But really nice use of wups OPSP.


Re: SD Pistol Tazer using OnPlayerShootPlayer - Kitten - 29.07.2011

nice tut , very great for newbies.


Re: SD Pistol Tazer using OnPlayerShootPlayer - GangsTa_ - 29.07.2011

Quote:
Originally Posted by wups
Посмотреть сообщение
As far as i know, the animation will disappear(like ClearAnimations) if you're being freezed after ApplyAnimation.

Nice tutorial though.
Hmm, I didn't test it with the crack anim, but it should work after being freezed not before it.


Re: SD Pistol Tazer using OnPlayerShootPlayer - GangsTa_ - 29.07.2011

Ok last code fixed.


Re: SD Pistol Tazer using OnPlayerShootPlayer - Juicy_J - 30.07.2011

Nice tut


Re: SD Pistol Tazer using OnPlayerShootPlayer - seanny - 30.07.2011

Awesome Tutorial, No Errors at All!


Re: SD Pistol Tazer using OnPlayerShootPlayer - GangsTa_ - 02.08.2011

Thanks)


Re: SD Pistol Tazer using OnPlayerShootPlayer - MarkoniGHS - 21.10.2011

You are the best !!!!!!
TNX


Re: SD Pistol Tazer using OnPlayerShootPlayer - GangsTa_ - 21.10.2011

No problem.


Re: SD Pistol Tazer using OnPlayerShootPlayer - JaKe Elite - 10.06.2012

Gonna use it for sure , Sorry for bumping 1 year old topic


Re: SD Pistol Tazer using OnPlayerShootPlayer - JhnzRep - 10.06.2012

Wups include is no longer needed OnPlayerGiveDamage(blahblah)

Or

OnPlayerTakeDamage(blah blah)


Re: SD Pistol Tazer using OnPlayerShootPlayer - JaKe Elite - 10.06.2012

I will try your method JhnzRep once I'm in my pc I'm current in mobile every morning I always use mobile and in afternoon I use my PC


Re: SD Pistol Tazer using OnPlayerShootPlayer - JhnzRep - 10.06.2012

All right, but only use one of the functions, do not try combining them somehow together, as they do not match up(due to lag).


Re : SD Pistol Tazer using OnPlayerShootPlayer - Alvin007 - 11.06.2012

How to make the TEAM_COPS? If we're using factions..?