28.07.2011, 21:13
(
Последний раз редактировалось GangsTa_; 29.07.2011 в 06:49.
)
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_