mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-02-18 02:41:54 +00:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae56b18a3c | ||
|
|
c907911cd1 | ||
|
|
1aa486cd7d | ||
|
|
5e62c7c597 | ||
|
|
819ac6233c | ||
|
|
ed24eb0dfc | ||
|
|
1a9f7ad108 | ||
|
|
6cd1bb3bf5 | ||
|
|
4f94b831c2 | ||
|
|
969d40b970 | ||
|
|
7f41607d54 | ||
|
|
928c1e1466 | ||
|
|
78649f5dcf | ||
|
|
4e72f10326 | ||
|
|
3ddbf7e11e | ||
|
|
ee770fd8c2 | ||
|
|
72c5df53b5 | ||
|
|
d0ed0f4c0b |
@@ -210,7 +210,7 @@ namespace WeaponPaints
|
|||||||
int.TryParse(weaponDefIndexObj.ToString(), out var weaponDefIndex) &&
|
int.TryParse(weaponDefIndexObj.ToString(), out var weaponDefIndex) &&
|
||||||
int.TryParse(selectedPaintID, out var paintID))
|
int.TryParse(selectedPaintID, out var paintID))
|
||||||
{
|
{
|
||||||
p!.Print(Localizer["f", selectedSkin]);
|
p!.Print(Localizer["wp_skin_menu_select", selectedSkin]);
|
||||||
|
|
||||||
if (!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
|
if (!gPlayerWeaponsInfo[playerIndex].ContainsKey(weaponDefIndex))
|
||||||
{
|
{
|
||||||
|
|||||||
38
README.md
38
README.md
@@ -9,18 +9,19 @@ Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin
|
|||||||
[](https://ko-fi.com/E1E2G0P2O) or [](https://steamcommunity.com/tradeoffer/new/?partner=41515647&token=gW2W-nXE)
|
[](https://ko-fi.com/E1E2G0P2O) or [](https://steamcommunity.com/tradeoffer/new/?partner=41515647&token=gW2W-nXE)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- Changes only paint, seed and wear on weapons and knives;
|
- Changes only paint, seed and wear on weapons and knives
|
||||||
- MySQL based or global website at [weaponpaints.fun](https://weaponpaints.fun/), so you dont need MySQL/Website;
|
- MySQL based or global website at [weaponpaints.fun](https://weaponpaints.fun/), so you dont need MySQL/Website
|
||||||
- Data sync on player connect;
|
- Data sync on player connect
|
||||||
- Added command **`!wp`** to refresh skins; ***(with cooldown in second can be configured)***
|
- Added command **`!wp`** to refresh skins ***(with cooldown in second can be configured)***
|
||||||
- Added command **`!ws`** to show website;
|
- Added command **`!ws`** to show website
|
||||||
- Added command **`!knife`** to show menu with knives;
|
- Added command **`!knife`** to show menu with knives
|
||||||
- Knife change is now limited to have these cvars empty **`mp_t_default_melee ""`** and **`mp_ct_default_melee ""`**;
|
- Knife change is now limited to have these cvars empty **`mp_t_default_melee ""`** and **`mp_ct_default_melee ""`**
|
||||||
|
- Translations support, submit a PR if you want to share your translation
|
||||||
|
|
||||||
## CS2 Server
|
## CS2 Server
|
||||||
- Compile and copy plugin to plugins, [more info here](https://docs.cssharp.dev/guides/hello-world-plugin/);
|
- Compile and copy plugin to plugins, [more info here](https://docs.cssharp.dev/guides/hello-world-plugin/)
|
||||||
- Setup **`addons/counterstrikesharp/configs/plugins/WeaponPaints/WeaponPaints.json`** set **`GlobalShare`** to **`true`** for global, or include database credentials;
|
- Setup **`addons/counterstrikesharp/configs/plugins/WeaponPaints/WeaponPaints.json`** set **`GlobalShare`** to **`true`** for global, or include database credentials
|
||||||
- in **`addons/counterstrikesharp/configs/core.json`** set **FollowCS2ServerGuidelines** to **`false`**;
|
- in **`addons/counterstrikesharp/configs/core.json`** set **FollowCS2ServerGuidelines** to **`false`**
|
||||||
|
|
||||||
## Plugin Configuration
|
## Plugin Configuration
|
||||||
<details>
|
<details>
|
||||||
@@ -69,12 +70,17 @@ Unfinished, unoptimized and not fully functional ugly demo weapon paints plugin
|
|||||||
</details>
|
</details>
|
||||||
|
|
||||||
## Web install
|
## Web install
|
||||||
Disregard if the config is **`GlobalShare = true`**;
|
Disregard if the config is **`GlobalShare = true`**
|
||||||
- Requires PHP >= 7.4; ***(Tested on php ver **`8.2.3`** and nginx webserver)***
|
- Requires PHP >= 7.4 ***(Tested on php ver **`8.2.3`** and nginx webserver)***
|
||||||
- Copy website to web server; ***(Folder `img` not needed)***
|
- Copy website to web server ***(Folder `img` not needed)***
|
||||||
- Get [Steam API Key](https://steamcommunity.com/dev/apikey);
|
- Get [Steam API Key](https://steamcommunity.com/dev/apikey)
|
||||||
- Fill in database credentials and api key in `class/config.php`;
|
- Fill in database credentials and api key in `class/config.php`
|
||||||
- Visit website and login via steam;
|
- Visit website and login via steam
|
||||||
|
|
||||||
|
## Web Features
|
||||||
|
- Basic website
|
||||||
|
- Steam login/logout
|
||||||
|
- Change knife, paint, seed and wear
|
||||||
|
|
||||||
## Known issues
|
## Known issues
|
||||||
- Issue on Windows servers, no knives are given.
|
- Issue on Windows servers, no knives are given.
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ define('DB_NAME', '');
|
|||||||
define('DB_USER', '');
|
define('DB_USER', '');
|
||||||
define('DB_PASS', '');
|
define('DB_PASS', '');
|
||||||
|
|
||||||
|
define('WEB_STYLE_DARK', true);
|
||||||
|
|
||||||
define('STEAM_API_KEY', '');
|
define('STEAM_API_KEY', '');
|
||||||
define('STEAM_DOMAIN_NAME', '');
|
define('STEAM_DOMAIN_NAME', '');
|
||||||
define('STEAM_LOGOUT_PAGE', '');
|
define('STEAM_LOGOUT_PAGE', '');
|
||||||
|
|||||||
@@ -4,14 +4,15 @@ require_once 'class/database.php';
|
|||||||
require_once 'steamauth/steamauth.php';
|
require_once 'steamauth/steamauth.php';
|
||||||
require_once 'class/utils.php';
|
require_once 'class/utils.php';
|
||||||
|
|
||||||
|
|
||||||
$db = new DataBase();
|
$db = new DataBase();
|
||||||
if (isset($_SESSION['steamid'])) {
|
if (isset($_SESSION['steamid'])) {
|
||||||
$steamid = $_SESSION['steamid'];
|
|
||||||
|
include('steamauth/userInfo.php');
|
||||||
|
$steamid = $steamprofile['steamid'];
|
||||||
|
|
||||||
$weapons = UtilsClass::getWeaponsFromArray();
|
$weapons = UtilsClass::getWeaponsFromArray();
|
||||||
$skins = UtilsClass::skinsFromJson();
|
$skins = UtilsClass::skinsFromJson();
|
||||||
$querySelected = $query3 = $db->select("SELECT `weapon_defindex`, `weapon_paint_id` FROM `wp_player_skins` WHERE `wp_player_skins`.`steamid` = :steamid", ["steamid" => $steamid]);
|
$querySelected = $query3 = $db->select("SELECT `weapon_defindex`, `weapon_paint_id`, `weapon_wear` FROM `wp_player_skins` WHERE `wp_player_skins`.`steamid` = :steamid", ["steamid" => $steamid]);
|
||||||
$selectedSkins = UtilsClass::getSelectedSkins($querySelected);
|
$selectedSkins = UtilsClass::getSelectedSkins($querySelected);
|
||||||
$selectedKnife = $db->select("SELECT * FROM `wp_player_knife` WHERE `wp_player_knife`.`steamid` = :steamid", ["steamid" => $steamid])[0];
|
$selectedKnife = $db->select("SELECT * FROM `wp_player_knife` WHERE `wp_player_knife`.`steamid` = :steamid", ["steamid" => $steamid])[0];
|
||||||
$knifes = UtilsClass::getKnifeTypes();
|
$knifes = UtilsClass::getKnifeTypes();
|
||||||
@@ -22,31 +23,30 @@ if (isset($_SESSION['steamid'])) {
|
|||||||
if ($ex[0] == "knife") {
|
if ($ex[0] == "knife") {
|
||||||
$db->query("INSERT INTO `wp_player_knife` (`steamid`, `knife`) VALUES(:steamid, :knife) ON DUPLICATE KEY UPDATE `knife` = :knife", ["steamid" => $steamid, "knife" => $knifes[$ex[1]]['weapon_name']]);
|
$db->query("INSERT INTO `wp_player_knife` (`steamid`, `knife`) VALUES(:steamid, :knife) ON DUPLICATE KEY UPDATE `knife` = :knife", ["steamid" => $steamid, "knife" => $knifes[$ex[1]]['weapon_name']]);
|
||||||
} else {
|
} else {
|
||||||
if (!is_int($ex[1]))
|
if (array_key_exists($ex[1], $skins[$ex[0]]) && isset($_POST['wear']) && $_POST['wear'] >= 0.00 && $_POST['wear'] <= 1.00 && isset($_POST['seed'])) {
|
||||||
header("Location: index.php");
|
$wear = floatval($_POST['wear']); // wear
|
||||||
if (array_key_exists($ex[1], $skins[$ex[0]])) {
|
$seed = intval($_POST['seed']); // seed
|
||||||
if (array_key_exists($ex[0], $selectedSkins)) {
|
if (array_key_exists($ex[0], $selectedSkins)) {
|
||||||
$db->query("UPDATE wp_player_skins SET weapon_paint_id = :weapon_paint_id WHERE steamid = :steamid AND weapon_defindex = :weapon_defindex", ["steamid" => $steamid, "weapon_defindex" => $ex[0], "weapon_paint_id" => $ex[1]]);
|
$db->query("UPDATE wp_player_skins SET weapon_paint_id = :weapon_paint_id, weapon_wear = :weapon_wear, weapon_seed = :weapon_seed WHERE steamid = :steamid AND weapon_defindex = :weapon_defindex", ["steamid" => $steamid, "weapon_defindex" => $ex[0], "weapon_paint_id" => $ex[1], "weapon_wear" => $wear, "weapon_seed" => $seed]);
|
||||||
} else {
|
} else {
|
||||||
$db->query("INSERT INTO wp_player_skins (`steamid`, `weapon_defindex`, `weapon_paint_id`) VALUES (:steamid, :weapon_defindex, :weapon_paint_id)", ["steamid" => $steamid, "weapon_defindex" => $ex[0], "weapon_paint_id" => $ex[1]]);
|
$db->query("INSERT INTO wp_player_skins (`steamid`, `weapon_defindex`, `weapon_paint_id`, `weapon_wear`, `weapon_seed`) VALUES (:steamid, :weapon_defindex, :weapon_paint_id, :weapon_wear, :weapon_seed)", ["steamid" => $steamid, "weapon_defindex" => $ex[0], "weapon_paint_id" => $ex[1], "weapon_wear" => $wear, "weapon_seed" => $seed]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
header("Location: index.php");
|
header("Location: {$_SERVER['PHP_SELF']}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en"<?php if(WEB_STYLE_DARK) echo 'data-bs-theme="dark"'?>>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
||||||
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"
|
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
|
||||||
integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL"
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.min.js"></script>
|
||||||
crossorigin="anonymous"></script>
|
|
||||||
<link rel="stylesheet" href="style.css">
|
<link rel="stylesheet" href="style.css">
|
||||||
<title>CS2 Simple Weapon Paints</title>
|
<title>CS2 Simple Weapon Paints</title>
|
||||||
</head>
|
</head>
|
||||||
@@ -59,9 +59,9 @@ if (isset($_SESSION['steamid'])) {
|
|||||||
loginbutton("rectangle");
|
loginbutton("rectangle");
|
||||||
echo "</h2></div>";
|
echo "</h2></div>";
|
||||||
} else {
|
} else {
|
||||||
echo "<div class='bg-primary'>Your current weapon skin loadout<form action='' method='get'><button class='btn btn-secondary' name='logout' type='submit'>Logout</button></form></div>";
|
echo "<div class='bg-primary'><h2>Your current weapon skin loadout <a class='btn btn-danger' href='{$_SERVER['PHP_SELF']}'>Logout</a></h2> </div>";
|
||||||
echo "<div class='card-group mt-2'>";
|
echo "<div class='card-group mt-2'>";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
<div class="card text-center mb-3 border border-primary">
|
<div class="card text-center mb-3 border border-primary">
|
||||||
@@ -132,14 +132,132 @@ if (isset($_SESSION['steamid'])) {
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
</form>
|
<br></br>
|
||||||
|
<?php
|
||||||
|
$selectedSkinInfo = isset($selectedSkins[$defindex]) ? $selectedSkins[$defindex] : null;
|
||||||
|
$steamid = $_SESSION['steamid'];
|
||||||
|
$defindex = $defindex; // get defindex here, correct if not
|
||||||
|
$queryCheck = $db->select("SELECT 1 FROM `wp_player_skins` WHERE `steamid` = :steamid AND `weapon_defindex` = :defindex", ["steamid" => $steamid, "defindex" => $defindex]);
|
||||||
|
$hasSkinData = !empty($queryCheck);
|
||||||
|
|
||||||
|
if ($selectedSkinInfo && $hasSkinData) :
|
||||||
|
?>
|
||||||
|
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#weaponModal<?php echo $defindex ?>">
|
||||||
|
Settings
|
||||||
|
</button>
|
||||||
|
<?php else : ?>
|
||||||
|
<button type="button" class="btn btn-primary" onclick="showSkinSelectionAlert()">
|
||||||
|
Settings
|
||||||
|
</button>
|
||||||
|
<script>
|
||||||
|
function showSkinSelectionAlert() {
|
||||||
|
alert("You need to select a skin first.");
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// wear value
|
||||||
|
$queryWear = $db->select("SELECT `weapon_wear` FROM `wp_player_skins` WHERE `steamid` = :steamid AND `weapon_defindex` = :weapon_defindex", ["steamid" => $steamid, "weapon_defindex" => $defindex]);
|
||||||
|
$selectedSkinInfo = isset($selectedSkins[$defindex]) ? $selectedSkins[$defindex] : null;
|
||||||
|
$initialWearValue = isset($selectedSkinInfo['weapon_wear']) ? $selectedSkinInfo['weapon_wear'] : (isset($queryWear[0]['weapon_wear']) ? $queryWear[0]['weapon_wear'] : 0);
|
||||||
|
|
||||||
|
// seed value
|
||||||
|
$querySeed = $db->select("SELECT `weapon_seed` FROM `wp_player_skins` WHERE `steamid` = :steamid AND `weapon_defindex` = :weapon_defindex", ["steamid" => $steamid, "weapon_defindex" => $defindex]);
|
||||||
|
$selectedSkinInfo = isset($selectedSkins[$defindex]) ? $selectedSkins[$defindex] : null;
|
||||||
|
$initialSeedValue = isset($selectedSkinInfo['weapon_seed']) ? $selectedSkinInfo['weapon_seed'] : (isset($querySeed[0]['weapon_seed']) ? $querySeed[0]['weapon_seed'] : 0);
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="modal fade" id="weaponModal<?php echo $defindex ?>" tabindex="-1" role="dialog" aria-labelledby="weaponModalLabel<?php echo $defindex ?>" aria-hidden="true">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class='card-title item-name'>
|
||||||
|
<?php
|
||||||
|
if (array_key_exists($defindex, $selectedSkins)) {
|
||||||
|
echo "{$skins[$defindex][$selectedSkins[$defindex]]["paint_name"]} Settings";
|
||||||
|
} else {
|
||||||
|
echo "{$default["paint_name"]} Settings";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</h5>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<select class="form-select" id="wearSelect<?php echo $defindex ?>" name="wearSelect" onchange="updateWearValue<?php echo $defindex ?>(this.value)">
|
||||||
|
<option disabled>Select Wear</option>
|
||||||
|
<option value="0.00" <?php echo ($initialWearValue == 0.00) ? 'selected' : ''; ?>>Factory New</option>
|
||||||
|
<option value="0.07" <?php echo ($initialWearValue == 0.07) ? 'selected' : ''; ?>>Minimal Wear</option>
|
||||||
|
<option value="0.15" <?php echo ($initialWearValue == 0.15) ? 'selected' : ''; ?>>Field-Tested</option>
|
||||||
|
<option value="0.38" <?php echo ($initialWearValue == 0.38) ? 'selected' : ''; ?>>Well-Worn</option>
|
||||||
|
<option value="0.45" <?php echo ($initialWearValue == 0.45) ? 'selected' : ''; ?>>Battle-Scarred</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="wear">Wear:</label>
|
||||||
|
<input type="text" value="<?php echo $initialWearValue; ?>" class="form-control" id="wear<?php echo $defindex ?>" name="wear">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="seed">Seed:</label>
|
||||||
|
<input type="text" value="<?php echo $initialSeedValue; ?>" class="form-control" id="seed<?php echo $defindex ?>" name="seed" oninput="validateSeed(this)">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||||
|
<button type="submit" class="btn btn-danger">Use</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
// wear
|
||||||
|
function updateWearValue<?php echo $defindex ?>(selectedValue) {
|
||||||
|
var wearInputElement = document.getElementById("wear<?php echo $defindex ?>");
|
||||||
|
wearInputElement.value = selectedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateWear(inputElement) {
|
||||||
|
inputElement.value = inputElement.value.replace(/[^0-9]/g, '');
|
||||||
|
}
|
||||||
|
// seed
|
||||||
|
function validateSeed(input) {
|
||||||
|
// Check entered value
|
||||||
|
var inputValue = input.value.replace(/[^0-9]/g, ''); // Just get the numbers
|
||||||
|
|
||||||
|
if (inputValue === "") {
|
||||||
|
input.value = 0; // Set to 0 if empty or no numbers
|
||||||
|
} else {
|
||||||
|
var numericValue = parseInt(inputValue);
|
||||||
|
numericValue = Math.min(1000, Math.max(1, numericValue)); // Interval control
|
||||||
|
|
||||||
|
input.value = numericValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="container">
|
||||||
|
<footer class="d-flex flex-wrap justify-content-between align-items-center py-3 my-4 border-top">
|
||||||
|
<div class="col-md-4 d-flex align-items-center">
|
||||||
|
<span class="mb-3 mb-md-0 text-body-secondary">© 2023 <a href="https://github.com/Nereziel/cs2-WeaponPaints">Nereziel/cs2-WeaponPaints</a></span>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 142 KiB After Width: | Height: | Size: 126 KiB |
Reference in New Issue
Block a user