Hi, I just recently started out on SM, I was wondering if you guys could explain a little bit for me about the mechanics of the duplication of the knife, thats is in this plugin from Neuro Toxin, this is what I got so far:
*His/Her plugin is in the attachments btw*
My main goal here is to do the same effect as this plugin, but for the Primary Weapon & only duplicate the target weapon and give the copy to the client... thanks!
Code:
/* Plugin Template generated by Pawn Studio */
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#pragma semicolon 1
new bool:DisableSwitch[MAXPLAYERS + 1];
new iWeapon[MAXPLAYERS + 1];
public Plugin:myinfo =
{
name = "!takeweapon",
author = "Grandpa",
description = "n00b",
version = "101",
url = "http://steamcommunity.com/id/grandpakudos/"
}
/***********************************
* 1- create a command *
* 2- grab target *
* 3- grab primary weapon of target *
* 4- gib it to me *
* 5- yolo *
***********************************/
public OnPluginStart()
{
init();
}
stock init()
{
HookEvent("round_start", Event_RoundStart);
RegConsoleCmd("sm_takeweapon", command_takeWeapon, "woompa stomp!");
RegConsoleCmd("sm_takeweaponoff", Command_Switch, "disables the ability for other people to grab your weapon.");
}
public OnClientPutInServer(client)
{
DisableSwitch[client] = false;
}
public Action:Command_Switch(client, args)
{
DisableSwitch[client] = !DisableSwitch[client];
if(DisableSwitch[client])
{
PrintToChat(client, "[\x0EAlert!\x01] Your dragonlore is safe bud!");
}
else
{
PrintToChat(client, "[\x0EAlert!\x01] You have \x06enabled\x01 switching!");
}
return Plugin_Handled;
}
public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
// grab wep
for(new i = 1; i < MaxClients; i++)
{
if(IsClientInGame(i))
{
iWeapon[i] = GetPlayerWeaponSlot(i, 0);
}
else
{
iWeapon[i] = -1;
}
}
}
public Action:command_takeWeapon(client, args)
{
if(args < 1)
{
PrintToChat(client, "[\x0EAlert!\x01] Usage: sm_takeweapon <player>");
return Plugin_Handled;
}
new String:arg[32];
GetCmdArg(1, arg, sizeof(arg));
new target = FindTarget(client, arg, false, false);
if (target == -1)
{
PrintToChat(client, "[\x0EAlert!\x01] \x07Cannot find player!");
return Plugin_Handled;
}
//else if(target == client)
//{
// PrintToChat(client, "[\x0EAlert!\x01] \x07You cannot swap knives with yourself!");
// return Plugin_Handled;
//}
else if(DisableSwitch[target])
{
PrintToChat(client, "[\x0EAlert!\x01] \x07That person has disabled switching!");
return Plugin_Handled;
}
else if(!IsPlayerAlive(target))
{
PrintToChat(client, "[\x0EAlert!\x01] \x07That player is dead!");
return Plugin_Handled;
}
else if(!IsPlayerAlive(client))
{
PrintToChat(client, "[\x0EAlert!\x01] \x07You are dead!");
return Plugin_Handled;
}
else if(!GetPlayerWeaponSlot(target, 0))
{
PrintToChat(client, "[\x0EAlert!\x01] \x07He does not have a weapon!");
return Plugin_Handled;
}
PrintToChat(client, "[\x0EAlert!\x01] You are using the weapon of: \x09%N", target);
TakeWeapon(client, target);
return Plugin_Handled;
}
TakeWeapon(player1, player2)
{
if(!IsPlayerAlive(player1))
{
PrintToChat(player1, "[\x0EAlert!\x01]\x07 Cancelled: You are dead!");
return;
}
else if(!IsPlayerAlive(player2))
{
PrintToChat(player1, "[\x0EAlert!\x01]\x07 Cancelled: That player is dead!");
return;
}
new weapon1 = GetPlayerWeaponSlot(player2, 0);
new weapon2 = GetPlayerWeaponSlot(player1, 0);
if(weapon2 == -1)
{
PrintToChat(player1, "[\x0EAlert\x01]\x07 Cancelled: He doesn't have a weapon to switch!");
return;
}
RemovePlayerItem(player1, weapon1);
iWeapon[player1] = knife2;
iWeapon[player2] = knife1;
CreateTimer(0.1, Equipweapon, player1);
}
stock tfmWeapon(client, target)
{
// just to make sure there's no breach...
new targetwep = GetPlayerWeaponSlot(target, 0);
if (targetwep == -1)
{
ReplyToCommand(client, "[SM] Target does not have a weapon!");
return;
}
// Magic trick
}