-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 421b621
Showing
10 changed files
with
776 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
plugins/ | ||
build.bat |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Pistol | ||
|
||
- Gives players a gun | ||
|
||
### Supported games | ||
|
||
- Day of Defeat: Source | ||
|
||
### Installation | ||
|
||
- Download latest [release](https://github.com/kalbmar/pistol/releases) (compiled for SourceMod 1.11) | ||
- Extract "plugins" folder to "addons/sourcemod" folder of your server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
PLUGIN_NAME="pistol" | ||
|
||
cd scripting | ||
spcomp $PLUGIN_NAME.sp -i include -o../plugins/$PLUGIN_NAME.smx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#if defined _pistol_timer_included | ||
#endinput | ||
#endif | ||
#define _pistol_timer_included | ||
|
||
#define TEAM_ALLIES 2 | ||
#define TEAM_AXIS 3 | ||
#define ALLIES_PISTOL_IN_ARRAY 1 | ||
#define AXIS_PISTOL_IN_ARRAY 2 | ||
#define ALLIES_PISTOL_CLASS_NAME "weapon_colt" | ||
#define AXIS_PISTOL_CLASS_NAME "weapon_p38" | ||
#define ALLIES_BULLETS_FOR_PISTOL 14 | ||
#define AXIS_BULLETS_FOR_PISTOL 16 | ||
#define CLASS_RIFLEMAN 0 | ||
#define CLASS_SUPPORT 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
bool Client_IsValid(int client) { | ||
return (1 <= client <= MaxClients && IsClientInGame(client)) ? true : false; | ||
} | ||
|
||
int Client_GetClass(int client) { | ||
return GetEntProp(client, Prop_Send, "m_iPlayerClass"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
void Event_Create() { | ||
HookEvent("player_spawn", Event_PlayerSpawn); | ||
} | ||
|
||
public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast) { | ||
int userId = event.GetInt("userid"); | ||
|
||
CreateTimer(0.1, Timer_GivePlayerPistol, userId, TIMER_FLAG_NO_MAPCHANGE); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
public Action Timer_GivePlayerPistol(Handle timer, int userId) { | ||
int client = GetClientOfUserId(userId); | ||
|
||
if (!Client_IsValid(client)) { | ||
return Plugin_Stop; | ||
} | ||
|
||
int team = GetClientTeam(client); | ||
int class = Client_GetClass(client); | ||
|
||
if (class == CLASS_RIFLEMAN || class == CLASS_SUPPORT) { | ||
if (team == TEAM_ALLIES) { | ||
UseCase_GivePlayerPistol(client, ALLIES_PISTOL_CLASS_NAME); | ||
UseCase_SetBulletsForPistol(client, ALLIES_BULLETS_FOR_PISTOL, ALLIES_PISTOL_IN_ARRAY); | ||
|
||
} else if (team == TEAM_AXIS) { | ||
UseCase_GivePlayerPistol(client, AXIS_PISTOL_CLASS_NAME); | ||
UseCase_SetBulletsForPistol(client, AXIS_BULLETS_FOR_PISTOL, AXIS_PISTOL_IN_ARRAY); | ||
} | ||
} | ||
|
||
return Plugin_Continue; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
void UseCase_GivePlayerPistol(int client, const char[] pistolName) { | ||
GivePlayerItem(client, pistolName); | ||
} | ||
|
||
void UseCase_SetBulletsForPistol(int client, int bullets, int pistols) { | ||
SetEntProp(client, Prop_Send, "m_iAmmo", bullets, _, pistols); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <sourcemod> | ||
#include <sdktools> | ||
|
||
#include "timer" | ||
|
||
#include "modules/event.sp" | ||
#include "modules/timer.sp" | ||
#include "modules/use-case.sp" | ||
#include "modules/client.sp" | ||
|
||
public Plugin myinfo = { | ||
name = "Pistol", | ||
author = "Kalbmar", | ||
description = "Gives players a gun", | ||
version = "1.0.0", | ||
url = "https://github.com/kalbmar/pistol", | ||
}; | ||
|
||
public void OnPluginStart() { | ||
Event_Create(); | ||
} |