SA-MP Forums Archive
[Include] C-Guns || Everything you'll ever need for weapons! [Exclusive] [Ultimate weapon synchronization] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] C-Guns || Everything you'll ever need for weapons! [Exclusive] [Ultimate weapon synchronization] (/showthread.php?tid=441775)



C-Guns || Everything you'll ever need for weapons! [Exclusive] [Ultimate weapon synchronization] - CreativityLacker - 04.06.2013

C-Guns
Anything and everything for guns
[BETA]



pawn Код:
forward OnPlayerWeaponHack(playerid, weaponid, allowed_ammo, owned_ammo);
 
/*
native SetDangerHealth(Float:danger); // if the player's health is less than this, it'll do PlayerBulletCheck
native GetDangerHealth();
 
native GetPlayerBulletsShot(playerid); //Returns the amount of bullets shot
native GetPlayerBulletsHit(playerid); // Returns the amount of bullets HIT
native Float:GetBulletsHitAccuracy(playerid); //Returns accuracy in % PERCENTAGE
native GivePlayerWeaponEx(playerid, weaponid, ammo);
native ResetPlayerWeaponsEx(playerid);
native SetPlayerAmmoEx(playerid, weaponid, ammo);
 
native GetPlayerAllowedAmmo(playerid, weaponid); //returns the player's ALLOWED ammo
native GetPlayerActualAmmo(playerid, weaponid);  //returns the ammo the player POSSESSES
 
//only use these func's if you know them
native GetWeaponSlot(weaponid);
native IsWeaponGun(weaponid); //Returns if the weapon ID is a gun
native WeaponHackCheck(playerid);   // Checking for player weapon hacks
native GiveValidWeapons(playerid);  // DO NOT USE
native PlayerBulletCheck(playerid); //DO NOT USE
*/

How does it work?
This include basically synchronizes each player's weapon data (no timer) with the server.
In addition to that, it counts the BULLETS SHOT and BULLETS HIT of each player for you.

It includes -

Bullets shot/hit + accuracy
Player's weapon and ammo synchronization
Weapon hack check

Note that this include is currently in BETA, I have tested all the existing features but there may or may not be unknown bugs. If there are any such bugs, you can immediately report here/PM me regarding such bugs.



Installation
In order to install -
Include C-guns and that's it (Thanks to Lordz™ for hooking )

Note that the WeaponHackCheck stock can be used anywhere, but preferably do not use it anywhere as it has been inbuilt in the script already!


Thanks to -

CreativityLacker - the idea/implementation/scripting
MarcObeles20 - testing the include and giving me more idea's
Lordz™ - for hooking OnPlayerTakeDamage and OnPlayerConnect and also all the stocks
To whoever who made the GetWeaponSlot function

Download -

BETA -
LATEST PASTEBIN- http://pastebin.com/fg462S2i

Mediafire [V0.25] - http://www.mediafire.com/download/p2...5BV0.25%5D.inc
Mediafire [BETA]- http://www.mediafire.com/download/tx...e%5DC-guns.inc

NOTE- pastebin will always be updated, but mediafire link MAY or MAY NOT be outdated.


Re: C-Guns || Everything you'll ever need for weapons! [Exclusive] [Ultimate weapon synchronization] - Lordzy - 04.06.2013

Quote:
Originally Posted by CreativityLacker
Посмотреть сообщение
Installation
In order to install -
Include C-guns
Replace -

pawn Код:
GivePlayerWeapon with GivePlayerWeaponEx
ResetPlayerWeapons with ResetPlayerWeaponsEx
SetPlayerAmmo with SetPlayerAmmoEx
GetPlayerAmmo with GetPlayerActualAmmo
Note that the WeaponHackCheck stock can be used anywhere, but preferably do not use it anywhere as it has been inbuilt in the script already!
You could HOOK those functions so that the include could be added in every script and doesn't need to change the function's name.


Re: C-Guns || Everything you'll ever need for weapons! [Exclusive] [Ultimate weapon synchronization] - CreativityLacker - 04.06.2013

Quote:
Originally Posted by Lordz™
Посмотреть сообщение
You could HOOK those functions so that the include could be added in every script and doesn't need to change the function's name.
I would've done that but I'm a noob at hooking, I've never understood it properly at all.
If you can hook those 4 functions and send them to me, it'll be much appreciated. I'll give it a try myself right now too.


Re: C-Guns || Everything you'll ever need for weapons! [Exclusive] [Ultimate weapon synchronization] - Lordzy - 04.06.2013

I've Vm'd you the hooked functions.


Re: C-Guns || Everything you'll ever need for weapons! [Exclusive] [Ultimate weapon synchronization] - CreativityLacker - 04.06.2013

Quote:
Originally Posted by Lordz™
Посмотреть сообщение
I've Vm'd you the hooked functions.
Updated the pastebin and mediafire with the hooked stocks, thanks


AW: C-Guns || Everything you'll ever need for weapons! [Exclusive] [Ultimate weapon synchronization] - BigETI - 04.06.2013

The GetWeaponSlot stock looks almost exactly the same I've released once for an old include I made once, also some people requested a function to get the weapon slot of a weapon, probably this is where you got the GetWeaponSlot function.
https://sampforum.blast.hk/showthread.php?tid=268441
http://forum.sa-mp.com/showthread.ph...ot#post1338171


Re: C-Guns || Everything you'll ever need for weapons! [Exclusive] [Ultimate weapon synchronization] - MP2 - 04.06.2013

Suggestion: RemovePlayerWeapon (remove a single weapon). Loop through weapon slots and use GetPlayerWeaponData and store them, reset their weapons, then give all the weapons back, minus the one that wants to be removed.


Re: C-Guns || Everything you'll ever need for weapons! [Exclusive] [Ultimate weapon synchronization] - CreativityLacker - 04.06.2013

Quote:
Originally Posted by MP2
Посмотреть сообщение
Suggestion: RemovePlayerWeapon (remove a single weapon). Loop through weapon slots and use GetPlayerWeaponData and store them, reset their weapons, then give all the weapons back, minus the one that wants to be removed.
Added on the to-do list, will be updated with next version ASAP.


Re: C-Guns || Everything you'll ever need for weapons! [Exclusive] [Ultimate weapon synchronization] - SuperViper - 04.06.2013

Quote:
Originally Posted by MP2
Посмотреть сообщение
Suggestion: RemovePlayerWeapon (remove a single weapon). Loop through weapon slots and use GetPlayerWeaponData and store them, reset their weapons, then give all the weapons back, minus the one that wants to be removed.
You can also just set the ammo to 0 - https://sampwiki.blast.hk/wiki/SetPlayerAmmo.


Re: C-Guns || Everything you'll ever need for weapons! [Exclusive] [Ultimate weapon synchronization] - Pottus - 04.06.2013

I wouldn't trust this, what happens when the server bogs out a player gets packetloss but keeps shooting on their screen? The script will likely lose track of how much ammo a player should have if it's not able to detect changes due to lag.