Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
//Weapons on body system by GoldenLion //Credits to BlueG & Pain123 & maddinat0r for MySQL #define FILTERSCRIPT #include <a_samp> #include <a_mysql> #undef MAX_PLAYERS #define MAX_PLAYERS 100 #define DIALOG_EDIT_BONE 5000 #define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1])))) #define MYSQL_HOST "localhost" #define MYSQL_USER "root" #define MYSQL_PASSWORD "" #define MYSQL_DATABASE "database" new MySQL:database; enum weaponSettings { Float:Position[6], Bone, Hidden } new WeaponSettings[MAX_PLAYERS][17][weaponSettings], WeaponTick[MAX_PLAYERS], EditingWeapon[MAX_PLAYERS]; GetWeaponObjectSlot(weaponid) { new objectslot; switch (weaponid) { case 22..24: objectslot = 0; case 25..27: objectslot = 1; case 28, 29, 32: objectslot = 2; case 30, 31: objectslot = 3; case 33, 34: objectslot = 4; case 35..38: objectslot = 5; } return objectslot; } GetWeaponModel(weaponid) //Will only return the model of wearable weapons (22-38) { new model; switch(weaponid) { case 22..29: model = 324 + weaponid; case 30: model = 355; case 31: model = 356; case 32: model = 372; case 33..38: model = 324 + weaponid; } return model; } PlayerHasWeapon(playerid, weaponid) { new weapon, ammo; for (new i; i < 13; i++) { GetPlayerWeaponData(playerid, i, weapon, ammo); if (weapon == weaponid && ammo) return 1; } return 0; } IsWeaponWearable(weaponid) return (weaponid >= 22 && weaponid <= 38); IsWeaponHideable(weaponid) return (weaponid >= 22 && weaponid <= 24 || weaponid == 28 || weaponid == 32); forward OnWeaponsLoaded(playerid); public OnWeaponsLoaded(playerid) { new rows, weaponid, index; cache_get_row_count(rows); for (new i; i < rows; i++) { cache_get_value_name_int(i, "WeaponID", weaponid); index = weaponid - 22; cache_get_value_name_float(i, "PosX", WeaponSettings[playerid][index][Position][0]); cache_get_value_name_float(i, "PosY", WeaponSettings[playerid][index][Position][1]); cache_get_value_name_float(i, "PosZ", WeaponSettings[playerid][index][Position][2]); cache_get_value_name_float(i, "RotX", WeaponSettings[playerid][index][Position][3]); cache_get_value_name_float(i, "RotY", WeaponSettings[playerid][index][Position][4]); cache_get_value_name_float(i, "RotZ", WeaponSettings[playerid][index][Position][5]); cache_get_value_name_int(i, "Bone", WeaponSettings[playerid][index][Bone]); cache_get_value_name_int(i, "Hidden", WeaponSettings[playerid][index][Hidden]); } } public OnFilterScriptInit() { new MySQLOpt:options = mysql_init_options(); mysql_set_option(options, POOL_SIZE, 0); database = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE, options); if (mysql_errno()) printf("Failed to connect to %s.", MYSQL_HOST); else printf("Successfully connected to %s.", MYSQL_HOST); return 1; } public OnFilterScriptExit() { mysql_close(database); return 1; } public OnPlayerUpdate(playerid) { if (NetStats_GetConnectedTime(playerid) - WeaponTick[playerid] >= 250) { new weaponid, ammo, objectslot, count, index; for (new i = 2; i <= 7; i++) //Loop only through the slots that may contain the wearable weapons { GetPlayerWeaponData(playerid, i, weaponid, ammo); index = weaponid - 22; if (weaponid && ammo && !WeaponSettings[playerid][index][Hidden] && IsWeaponWearable(weaponid) && EditingWeapon[playerid] != weaponid) { objectslot = GetWeaponObjectSlot(weaponid); if (GetPlayerWeapon(playerid) != weaponid) SetPlayerAttachedObject(playerid, objectslot, GetWeaponModel(weaponid), WeaponSettings[playerid][index][Bone], WeaponSettings[playerid][index][Position][0], WeaponSettings[playerid][index][Position][1], WeaponSettings[playerid][index][Position][2], WeaponSettings[playerid][index][Position][3], WeaponSettings[playerid][index][Position][4], WeaponSettings[playerid][index][Position][5], 1.0, 1.0, 1.0); else if (IsPlayerAttachedObjectSlotUsed(playerid, objectslot)) RemovePlayerAttachedObject(playerid, objectslot); } } for (new i; i <= 5; i++) if (IsPlayerAttachedObjectSlotUsed(playerid, i)) { count = 0; for (new j = 22; j <= 38; j++) if (PlayerHasWeapon(playerid, j) && GetWeaponObjectSlot(j) == i) count++; if (!count) RemovePlayerAttachedObject(playerid, i); } WeaponTick[playerid] = NetStats_GetConnectedTime(playerid); } return 1; } public OnPlayerConnect(playerid) { new string[70], name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, MAX_PLAYER_NAME); for (new i; i < 17; i++) { WeaponSettings[playerid][i][Position][0] = -0.116; WeaponSettings[playerid][i][Position][1] = 0.189; WeaponSettings[playerid][i][Position][2] = 0.088; WeaponSettings[playerid][i][Position][3] = 0.0; WeaponSettings[playerid][i][Position][4] = 44.5; WeaponSettings[playerid][i][Position][5] = 0.0; WeaponSettings[playerid][i][Bone] = 1; WeaponSettings[playerid][i][Hidden] = false; } WeaponTick[playerid] = 0; EditingWeapon[playerid] = 0; mysql_format(database, string, sizeof(string), "SELECT * FROM weaponsettings WHERE Name = '%s'", name); mysql_tquery(database, string, "OnWeaponsLoaded", "d", playerid); return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if (dialogid == DIALOG_EDIT_BONE) { if (response) { new weaponid = EditingWeapon[playerid], weaponname[18], name[MAX_PLAYER_NAME], string[150]; GetWeaponName(weaponid, weaponname, sizeof(weaponname)); GetPlayerName(playerid, name, MAX_PLAYER_NAME); WeaponSettings[playerid][weaponid - 22][Bone] = listitem + 1; format(string, sizeof(string), "You have successfully changed the bone of your %s.", weaponname); SendClientMessage(playerid, -1, string); mysql_format(database, string, sizeof(string), "INSERT INTO weaponsettings (Name, WeaponID, Bone) VALUES ('%s', %d, %d) ON DUPLICATE KEY UPDATE Bone = VALUES(Bone)", name, weaponid, listitem + 1); mysql_tquery(database, string); } EditingWeapon[playerid] = 0; return 1; } return 0; } public OnPlayerEditAttachedObject(playerid, response, index, modelid, boneid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:fRotZ, Float:fScaleX, Float:fScaleY, Float:fScaleZ) { new weaponid = EditingWeapon[playerid]; if (weaponid) { if (response) { new enum_index = weaponid - 22, weaponname[18], name[MAX_PLAYER_NAME], string[340]; GetWeaponName(weaponid, weaponname, sizeof(weaponname)); GetPlayerName(playerid, name, MAX_PLAYER_NAME); WeaponSettings[playerid][enum_index][Position][0] = fOffsetX; WeaponSettings[playerid][enum_index][Position][1] = fOffsetY; WeaponSettings[playerid][enum_index][Position][2] = fOffsetZ; WeaponSettings[playerid][enum_index][Position][3] = fRotX; WeaponSettings[playerid][enum_index][Position][4] = fRotY; WeaponSettings[playerid][enum_index][Position][5] = fRotZ; RemovePlayerAttachedObject(playerid, GetWeaponObjectSlot(weaponid)); SetPlayerAttachedObject(playerid, GetWeaponObjectSlot(weaponid), GetWeaponModel(weaponid), WeaponSettings[playerid][enum_index][Bone], fOffsetX, fOffsetY, fOffsetZ, fRotX, fRotY, fRotZ, 1.0, 1.0, 1.0); format(string, sizeof(string), "You have successfully adjusted the position of your %s.", weaponname); SendClientMessage(playerid, -1, string); mysql_format(database, string, sizeof(string), "INSERT INTO weaponsettings (Name, WeaponID, PosX, PosY, PosZ, RotX, RotY, RotZ) VALUES ('%s', %d, %.3f, %.3f, %.3f, %.3f, %.3f, %.3f) ON DUPLICATE KEY UPDATE PosX = VALUES(PosX), PosY = VALUES(PosY), PosZ = VALUES(PosZ), RotX = VALUES(RotX), RotY = VALUES(RotY), RotZ = VALUES(RotZ)", name, weaponid, fOffsetX, fOffsetY, fOffsetZ, fRotX, fRotY, fRotZ); mysql_tquery(database, string); } EditingWeapon[playerid] = 0; } return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { new cmd[24], params[64], len = strlen(cmdtext); for (new i; i < len; i++) if (cmdtext[i] == ' ') { strmid(cmd, cmdtext, 0, i); strcat(params, cmdtext[i + 1]); break; } if (isnull(cmd)) strcat(cmd, cmdtext); if (!strcmp(cmd, "/weapon", true)) { new weaponid = GetPlayerWeapon(playerid); if (!weaponid) return SendClientMessage(playerid, -1, "You are not holding a weapon."); if (!IsWeaponWearable(weaponid)) return SendClientMessage(playerid, -1, "This weapon cannot be edited."); if (isnull(params)) return SendClientMessage(playerid, -1, "USAGE: /weapon [adjustpos/bone/hide]"); if (!strcmp(params, "adjustpos", true)) { if (EditingWeapon[playerid]) return SendClientMessage(playerid, -1, "You are already editing a weapon."); if (WeaponSettings[playerid][weaponid - 22][Hidden]) return SendClientMessage(playerid, -1, "You cannot adjust a hidden weapon."); new index = weaponid - 22; SetPlayerArmedWeapon(playerid, 0); SetPlayerAttachedObject(playerid, GetWeaponObjectSlot(weaponid), GetWeaponModel(weaponid), WeaponSettings[playerid][index][Bone], WeaponSettings[playerid][index][Position][0], WeaponSettings[playerid][index][Position][1], WeaponSettings[playerid][index][Position][2], WeaponSettings[playerid][index][Position][3], WeaponSettings[playerid][index][Position][4], WeaponSettings[playerid][index][Position][5], 1.0, 1.0, 1.0); EditAttachedObject(playerid, GetWeaponObjectSlot(weaponid)); EditingWeapon[playerid] = weaponid; } else if (!strcmp(params, "bone", true)) { if (EditingWeapon[playerid]) return SendClientMessage(playerid, -1, "You are already editing a weapon."); ShowPlayerDialog(playerid, DIALOG_EDIT_BONE, DIALOG_STYLE_LIST, "Bone", "Spine\nHead\nLeft upper arm\nRight upper arm\nLeft hand\nRight hand\nLeft thigh\nRight thigh\nLeft foot\nRight foot\nRight calf\nLeft calf\nLeft forearm\nRight forearm\nLeft shoulder\nRight shoulder\nNeck\nJaw", "Choose", "Cancel"); EditingWeapon[playerid] = weaponid; } else if (!strcmp(params, "hide", true)) { if (EditingWeapon[playerid]) return SendClientMessage(playerid, -1, "You cannot hide a weapon while you are editing it."); if (!IsWeaponHideable(weaponid)) return SendClientMessage(playerid, -1, "This weapon cannot be hidden."); new index = weaponid - 22, weaponname[18], name[MAX_PLAYER_NAME], string[150]; GetWeaponName(weaponid, weaponname, sizeof(weaponname)); GetPlayerName(playerid, name, MAX_PLAYER_NAME); if (WeaponSettings[playerid][index][Hidden]) { format(string, sizeof(string), "You have set your %s to show.", weaponname); WeaponSettings[playerid][index][Hidden] = false; } else { if (IsPlayerAttachedObjectSlotUsed(playerid, GetWeaponObjectSlot(weaponid))) RemovePlayerAttachedObject(playerid, GetWeaponObjectSlot(weaponid)); format(string, sizeof(string), "You have set your %s not to show.", weaponname); WeaponSettings[playerid][index][Hidden] = true; } SendClientMessage(playerid, -1, string); mysql_format(database, string, sizeof(string), "INSERT INTO weaponsettings (Name, WeaponID, Hidden) VALUES ('%s', %d, %d) ON DUPLICATE KEY UPDATE Hidden = VALUES(Hidden)", name, weaponid, WeaponSettings[playerid][index][Hidden]); mysql_tquery(database, string); } else SendClientMessage(playerid, -1, "You have specified an invalid option."); return 1; } return 0; }
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
Backend advantage
CSS | 2 min ago | 0.23 KB
VNC SCRIPT 2/2: autoinput.vbs
VBScript | 3 hours ago | 0.23 KB
VNC SCRIPT 1/2: vncauto.bat
Batch | 3 hours ago | 0.72 KB
Metroid Mission Rescue state condition list f...
ASM (NASM) | 3 hours ago | 1.49 KB
videoscheomedia
XML | 5 hours ago | 1.00 KB
Untitled
10 hours ago | 14.91 KB
autconnectVNC.bat
Batch | 10 hours ago | 0.93 KB
Helpful Windows commands
10 hours ago | 0.75 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!