SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 09/06/2013, 04:30 PM   #1
Lordzy
High-roller
 
Lordzy's Avatar
 
Join Date: Mar 2012
Location: NetherRealm
Posts: 2,707
Reputation: 1176
Default [Updated]L-Skills - Server sided weapon skill system! -Now with Anti-Skill Cheat protection.

(I no longer provide any support for this include, neither fixing any bugs if there are any.)
L_Skills
Server sided Weapon Skill system
v1.2 released.
v2 in progress


Introduction

Hey all,
It's been a while since I've released something so I thought of working into some scripts today as I was bored and was also thinking to code something. I and my friend was thinking something to code and he suggested me something like skills would be good. So I thought of creating an include which supports most of the weapons. This include contains several natives, 1 callback and I've hooked "SetPlayerSkillLevel" function to make it compatible with "GetPlayerSkillLevel" function and other callbacks.

How does it works?

Well it's simple - It damages the player whom we damage twice than we do. The damage goes on according to the skill rates. According to the default settings, if you shoot a person with pistol and if you do have 200 skill on pistol, it damages the default pistol's damage -8 + the damage from the skill (ie: 200/10 = 20) = 28. It reduces 28.0 armour/hp from the player.

On the release of the version 1.2 of it, it provides Anti-Skill cheats. Which means, player cannot change the values of weapons skills once if L_Skills is being processed. The coder of the server must itself set the skill to perform it. Also change the ar_stats.dat in the datas folder also will be prevented by L_Skills. You must include L_skills on every scripts which uses skill value changes or it might not work well.

Functions & Callback
pawn Code:
/*Fake natives (Functions) of L_Skills.inc

native GetPlayerSkillLevel(playerid);
native SetPlayerWeaponSkill(playerid, weaponid, skill);
native GetPlayerWeaponSkill(playerid, weaponid);
native GetWeaponDamageRate(weaponid);
native IsPlayerWeaponSkillEnabled(playerid);
native TogglePlayerWeaponSkill(playerid, bool:weapon_skill);
native DamagePlayer(playerid, Float:damage);
native EnablePlayerWeaponSkill(playerid);
native DisablePlayerWeaponSkill(playerid);

Callbacks:
OnWeaponSkillLevelSet(playerid, weaponid, skill);
*/

Function : GetPlayerSkillLevel
Parameters:
playerid
= the player in which the function is being performed.
Returns : -1 if player isn't connected, -2 if the weapon type is not valid(Weapon types which are able to be used in "SetPlayerSkillLevel" are only allowed in this function), the value of the skill if it returns well.

This function get's the player's weapon skill which is set on "SetPlayerSkillLevel".

Function : SetPlayerWeaponSkill
Parameters:
playerid
= the player in which the function is being performed.
weaponid = the player's weapon in which the server sided skill must be set.
skill = skill value which must be applied to a player's weapon.
Returns : -1 if player isn't connected, 0 if the weaponid isn't supported for this function, 1 if it's done well.

This function sets the server sided weapon skill for a player.

Function: GetPlayerWeaponSkill
Parameters:
playerid
= the player in which the function is being performed.
weaponid = the weaponid of the player in which you want to get it's skill value.
Returns : -1 if player isn't connected, -2 if weapon isn't supported for "SetPlayerWeaponSkill", the value if it's done well.

This function gets the server sided weapon skill of a player.

Function : GetWeaponDamageRate
Parameters:
weaponid
= the weaponid in which you want to know it's damage rate.
Returns : -1 if weaponid isn't supported for the server sided weapon skill, skill value if it's done well.

This function gets the damage accuracy caused by a weapon. It's not the exact value, as the exact value is as Float. Here, it gets the accuracy as integers only. And for some weapons which cause explosion, it depends on the area range too.

Function : IsPlayerWeaponSkillEnabled
Parameters:
playerid
= the player in which the function is being performed.
Returns : 0 if disabled, 1 if enabled.

This function declares if a player's server sided weapon skill is enabled or not.

Function : TogglePlayerWeaponSkill
Parameters:
playerid
= the player in which the function is being performed.
bool:weapon_skill = bool case to be set to declare whether the player must have server sided weapon skill or not.
Returns : No specified values.

This function toggles the player's weapon skill. Set it to true to enable, false to disable.

Function: DamagePlayer
Parameters:
playerid
= the player in which the function is being performed.
Float:damage = The damage to be done on the player.
Returns : No specified values.

This function damages the player according to player's armour/hp and the damage specified. If the damage is greater than player's armour, it reduces player's hp too. Just like the SA-MP or GTA SA damage occurs.

Function: EnablePlayerWeaponSkill
Parameters:
playerid
= the player in which the function is being performed.
Returns : No specified values.

This function enables server sided weapon skill for player.

Function: DisablePlayerWeaponSkill
Parameters:
playerid
= the player in which the function is being performed.
Returns : No specified values.

This function disables server sided weapon skill for player.

Callback: OnWeaponSkillLevelSet
Parameters:
playerid
= the player in which the callback has been performed.
weaponid = the weapon skill which have been set.
skill = The skill which have been set.

This callback is being called when "SetPlayerWeaponSkill" is being performed.


Notes

1)Here "LS" used means L_Skill, not Los Santos or anything else!
2) Don't set the skill less than 10! As the skill is being divided by 10 to damage, it might not work well if it's reduced than 10.
3) As skills increase, if player's server sided skill is enabled, while giving damage to other player, it damages more than the default one does.
4) How damage works is like it divides the skill by 10, and then it damages. So if your weapon skill is 10, it does 1 damage. I
If it's 100, it does 10% damage. If it's 999, it does 99.9% of damage. MAX damage value is 999.
5) You can also automatically turn on the normal SA-MP Skill according to the server sided skill just by doing:
#define APPLY_DEFAULT_SKILL

6) This include doesn't support some weapons for the skill( Molotovs, Remote Explosives, Heat seaker..)
7) This is a kind of plug 'n' play system, so you must do:
pawn Code:
public OnPlayerConnect(playerid)
{
 TogglePlayerWeaponSkill(playerid, true); //If you wish the server sided weapon skill to be applied on this player.
 return 1;
}
8) If you're using any script as filterscript, please don't forget to define FILTERSCRIPT before includes.
(#define FILTERSCRIPT) must be done in case if you're including this in a filterscript.
9) You must include L_Skills2.inc in every scripts which uses Skill value changes or the include might not perform the Anticheat works well.
10) If you're using the v1.2 of L_Skills, you can disable Anti-Skill cheat by commenting OUT USE_LSKILLS_ANTICHEAT and for enabling, just define it.

Installation

First of all, download this include from the download link which I've mentioned below.
Paste it into your pawno/include/ folder.
Open your script, and under the include a_samp, include this include.
pawn Code:
#include <a_samp>
#include <L_skills> //In case if using v2, #include <L_skills2>
If you're using v2 of L_Skills, please include L_Skills on every script which uses skill value functions.


Thanks to
[WH]Marcos - For suggesting me some ideas.
Odedara - For testing the weapon damage rates with me.
Lorenc_ - For Anti-Skill cheat suggestion.
[uL]Pottus & SuperViper - For bug reports.

Bugs
Bug under OnPlayerGiveDamage - Damages the attacker - Stats: Fixed!

Fixed the bug which damages player if player's in AFK. However, it's not so perfectly fixed, depends on the pause sync.

The sync on the callback OnPlayerGiveDamage is being tested so if that's a problem will be solved and will optimize the codes.

Change Logs
Code:
10-06-2013
- Fixed the bug under OnPlayerGiveDamage callback. (Thanks to [uL]Pottus for the bug report of it.)

v1.2 in progress:
 Currently Added:
  Anti-Skill cheat/hack. (Thanks to Lorenc_ for suggesting it.)
  Prevents damaging player if L_Skills are executed while a player is paused. (Thanks to SuperViper for noting me that.)

06-07-2013
v1.2 released.

31-01-2014
- Fixed hooking at 'OnPlayerGiveDamage' callback.
- This include is now compatible with 0.3z

v2 in progress (Final version)
Download
[Pastebin]L_Skills2.inc (Recommended) - Fixed the hooking part and the include is now compatible for both 0.3x and 0.3z.

[Soldfiles]L_Skills2.inc
[Pastebin]L_Skills.inc
[SoldFiles]L_Skills.inc


-Lordz™
__________________
Currently inactive - I don't play at any SA-MP servers nor work on anything in PAWN for now. The projects that I've done so far in PAWN, which requires updates will be taking some time.

Last edited by Lordzy; 22/01/2017 at 11:28 AM. Reason: Support for this include has been over!
Lordzy is offline   Reply With Quote
Old 09/06/2013, 04:39 PM   #2
Astralis
Guest
 
Posts: n/a
Default Re: L-Skills - Server sided weapon skill system!

nice release, very useful, +rep awesome work !

edit: already tested, works epicly!
  Reply With Quote
Old 09/06/2013, 06:35 PM   #3
Kaperstone
Banned
 
Join Date: May 2011
Location: Russia
Posts: 3,024
Reputation: 824
Default Re: L-Skills - Server sided weapon skill system!

What this for ?
Quote:
Function: DamagePlayer
Parameters:
playerid = the player in which the function is being performed.
Float:damage = The damage to be done on the player.
Returns : No specified values.
I mean,doesn't it effect almost the same as SetPlayerHealth ?
And last question,for what this include?

However,looks like another nice release from you
Kaperstone is offline   Reply With Quote
Old 09/06/2013, 06:48 PM   #4
DaRk_RaiN
Gangsta
 
DaRk_RaiN's Avatar
 
Join Date: Sep 2012
Posts: 974
Reputation: 207
Default Re: L-Skills - Server sided weapon skill system!

Quote:
Originally Posted by xkirill View Post
What this for ?

I mean,doesn't it effect almost the same as SetPlayerHealth ?
And last question,for what this include?

However,looks like another nice release from you
That function damages a specific player, usually used when player has armour + health, so it calculates the damage and takes it from armour primarily, then health.
BTW, nice release Lordz.
DaRk_RaiN is offline   Reply With Quote
Old 09/06/2013, 07:04 PM   #5
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,856
Reputation: 1292
Default Re: L-Skills - Server sided weapon skill system!

Just a couple of questions.

1.) This line is on OnPlayerGiveDamage()

pawn Code:
DamagePlayer(playerid, float(final)); //Damages player more!

Why are you damaging the player who gave the damage but not the person who received the damage?

2.) What happens when a shot is synced but also OnPlayerGiveDamage() is called the player will receive a more damage.

3.) When setting a players health to zero it will case a lot a problems with who killed who.

4.) Why do this in DamagePlayer()?

pawn Code:
if(!IsPlayerConnected(playerid)) return 0;

It's not needed.

I think you have some serious issues to work out with this include.
Pottus is offline   Reply With Quote
Old 09/06/2013, 07:14 PM   #6
Kaperstone
Banned
 
Join Date: May 2011
Location: Russia
Posts: 3,024
Reputation: 824
Default Re: L-Skills - Server sided weapon skill system!

Quote:
Originally Posted by DaRk_RaiN View Post
That function damages a specific player, usually used when player has armour + health, so it calculates the damage and takes it from armour primarily, then health.
BTW, nice release Lordz.
Thanks,but that's not what I asked.
Kaperstone is offline   Reply With Quote
Old 10/06/2013, 02:38 PM   #7
Lordzy
High-roller
 
Lordzy's Avatar
 
Join Date: Mar 2012
Location: NetherRealm
Posts: 2,707
Reputation: 1176
Default Re: L-Skills - Server sided weapon skill system!

Quote:
Originally Posted by xkirill View Post
What this for ?

I mean,doesn't it effect almost the same as SetPlayerHealth ?
And last question,for what this include?

However,looks like another nice release from you
DamagePlayer is a function which reduces player's hp/armour based on the damage given. If a player has 100% armour and the damage done is higher than player's armour, it reduces the armour and the remaining damage occurs on player's health. And this include, it's a server sided weapon skill system. As the skill of a player's weapon increase, the damage goes more better. Can be good for some kind of DMs or experience system.

Quote:
Originally Posted by [uL]Pottus View Post
Just a couple of questions.

1.) This line is on OnPlayerGiveDamage()

pawn Code:
DamagePlayer(playerid, float(final)); //Damages player more!

Why are you damaging the player who gave the damage but not the person who received the damage?

2.) What happens when a shot is synced but also OnPlayerGiveDamage() is called the player will receive a more damage.

3.) When setting a players health to zero it will case a lot a problems with who killed who.

4.) Why do this in DamagePlayer()?

pawn Code:
if(!IsPlayerConnected(playerid)) return 0;

It's not needed.

I think you have some serious issues to work out with this include.
1) Thanks for noting it, I was thinking of using 'OnPlayerTakeDamage' callback at first, so the parameters was set according to it. I've changed it now.

2) I too had some doubts regarding it so I tested the callbacks being called on some intervals and noticed that OnPlayerGiveDamage is being called when the attacker damages the player and the damage must reach well. Else, OnPlayerGiveDamage won't get called very well. However, there's a chance where OnPlayerTakeDamage being called twice due to the sync occurs in cases like lag, lag shots etc. Depends on the player's ping rate too. Though, I'm having a bit doubts regarding the sync occuring on OnPlayerGiveDamage too. I'll be developing better way and will be testing more about this.

3) I really don't think so because I checked the cases if there's any problem while the health is being set to 0 and creates any corruption, but it doesn't.

4) I was thinking of doing something, unfortunately I added that there too. Although, that really doesn't matter.

Thanks for the 3rd one, really appreciate it. +rep.

Edit :
You must spread some Reputation around before giving it to [uL]Pottus again.
#fu** this.
__________________
Currently inactive - I don't play at any SA-MP servers nor work on anything in PAWN for now. The projects that I've done so far in PAWN, which requires updates will be taking some time.
Lordzy is offline   Reply With Quote
Old 10/06/2013, 03:51 PM   #8
SuperViper
High-roller
 
SuperViper's Avatar
 
Join Date: Sep 2011
Posts: 1,178
Reputation: 315
Default Re: L-Skills - Server sided weapon skill system!

If a player standing still gets shot, both OnPlayerTakeDamage and OnPlayerGiveDamage are called.
__________________
Release NameUse
FairPlayKeep the cheaters out of your server
Object Model ArrayArray of every single object model in the game
RCON PanelControl any server as you like with RCON controls
SlopeClimb up a steep hill against other players with cars falling down

I do not play on any SAMP server. Anyone with the name Ricky Phelps in-game is an imposter.
SuperViper is offline   Reply With Quote
Old 10/06/2013, 05:57 PM   #9
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,856
Reputation: 1292
Default Re: L-Skills - Server sided weapon skill system!

Thanks for hearing me out, some people are just too headstrong to listen I'm sure this include can still be improved a lot. Just one more thing, if your using OnPlayerTakeDamage() you won't be able to give less HP than the maximum that weapon can do this applies when health is >= the maximum.
Pottus is offline   Reply With Quote
Old 11/06/2013, 12:38 AM   #10
Lordzy
High-roller
 
Lordzy's Avatar
 
Join Date: Mar 2012
Location: NetherRealm
Posts: 2,707
Reputation: 1176
Default Re: L-Skills - Server sided weapon skill system!

Quote:
Originally Posted by SuperViper View Post
If a player standing still gets shot, both OnPlayerTakeDamage and OnPlayerGiveDamage are called.
Hmm that's right, I'll try getting a way to avoid that to integrate it with the skill functioning. Thanks.

Quote:
Originally Posted by [uL]Pottus View Post
Thanks for hearing me out, some people are just too headstrong to listen I'm sure this include can still be improved a lot. Just one more thing, if your using OnPlayerTakeDamage() you won't be able to give less HP than the maximum that weapon can do this applies when health is >= the maximum.
The include is still using OnPlayerGiveDamage because OnPlayerTakeDamage gets sync most of the times due to lag shots or higher ping. Due to that, I haven't used it. Although, I'll be testing the sync well and will be trying to balance things between these two callbacks.
__________________
Currently inactive - I don't play at any SA-MP servers nor work on anything in PAWN for now. The projects that I've done so far in PAWN, which requires updates will be taking some time.
Lordzy is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Weapon Skill System 1.0... Mandrack_FreeZe Lançamentos/Releases 19 30/10/2014 08:08 PM
[FilterScript] Weapon Skill System + save rumen98 Filterscripts 11 14/02/2014 04:22 AM
server sided weapon system + anti cheat PaulDinam Scripting Help 5 14/10/2012 02:42 PM
[Tutorial] How to Hook Filterscript Money System with Server-Sided Money System IceMeteor Tutorials 0 19/08/2012 08:05 AM
IRC pm system need some help server sided kin Help Archive 2 22/01/2011 05:28 AM


All times are GMT. The time now is 06:18 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.