[Tutorial] SD Pistol Tazer using OnPlayerShootPlayer
#1


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_
Reply
#2

awasome
very useful for me..
i will use it...
Reply
#3

Thanks. Good luck.
Reply
#4

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

Maybe, I'll fix tomorrow, I'm off.
Reply
#6

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

Nice tutorial though.
Reply
#7

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

nice tut , very great for newbies.
Reply
#9

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.
Reply
#10

Ok last code fixed.
Reply
#11

Nice tut
Reply
#12

Awesome Tutorial, No Errors at All!
Reply
#13

Thanks)
Reply
#14

You are the best !!!!!!
TNX
Reply
#15

No problem.
Reply
#16

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

Wups include is no longer needed OnPlayerGiveDamage(blahblah)

Or

OnPlayerTakeDamage(blah blah)
Reply
#18

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
Reply
#19

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).
Reply
#20

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


Forum Jump:


Users browsing this thread: 3 Guest(s)