[Updated]L-Skills - Server sided weapon skill system! -Now with Anti-Skill Cheat protection. -
Lordzy - 09.06.2013
(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 Код:
/*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 Код:
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 Код:
#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
Код:
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™
Re: L-Skills - Server sided weapon skill system! - Astralis - 09.06.2013
nice release, very useful, +rep awesome work !
edit: already tested, works epicly!
Re: L-Skills - Server sided weapon skill system! -
Kaperstone - 09.06.2013
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
Re: L-Skills - Server sided weapon skill system! -
DaRk_RaiN - 09.06.2013
Quote:
Originally Posted by xkirill
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.
Re: L-Skills - Server sided weapon skill system! -
Pottus - 09.06.2013
Just a couple of questions.
1.) This line is on OnPlayerGiveDamage()
pawn Код:
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 Код:
if(!IsPlayerConnected(playerid)) return 0;
It's not needed.
I think you have some serious issues to work out with this include.
Re: L-Skills - Server sided weapon skill system! -
Kaperstone - 09.06.2013
Quote:
Originally Posted by DaRk_RaiN
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.
Re: L-Skills - Server sided weapon skill system! -
Lordzy - 10.06.2013
Quote:
Originally Posted by xkirill
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
Just a couple of questions.
1.) This line is on OnPlayerGiveDamage()
pawn Код:
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 Код:
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.
Re: L-Skills - Server sided weapon skill system! -
SuperViper - 10.06.2013
If a player standing still gets shot, both
OnPlayerTakeDamage and
OnPlayerGiveDamage are called.
Re: L-Skills - Server sided weapon skill system! -
Pottus - 10.06.2013
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.
Re: L-Skills - Server sided weapon skill system! -
Lordzy - 11.06.2013
Quote:
Originally Posted by SuperViper
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
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.
Re: L-Skills - Server sided weapon skill system! -
Odedara - 13.06.2013
Awesome Job
Re: L-Skills - Server sided weapon skill system! -
Lordzy - 14.06.2013
Quote:
Originally Posted by Odedara
Awesome Job
|
Thank you.
Re: L-Skills - Server sided weapon skill system! -
gogokickup - 16.06.2013
A useful include
Re: L-Skills - Server sided weapon skill system! -
Lordzy - 19.06.2013
Quote:
Originally Posted by gogokickup
A useful include
|
Thank you.
L_Skills v1.2 BETA on progress
Re: L-Skills - Server sided weapon skill system! -
Inverse - 24.06.2013
An awesome include! One can produce wonderful systems with this thing. Just one question. What's the difference between client sided SA-MP skill system and yours? I mean of course it's server sided and all. But does the client sided skill also give more damage to other players as it increases?
Re: L-Skills - Server sided weapon skill system! -
Lorenc_ - 24.06.2013
Great release. Make sure you add anti-cheat to this, because weapon skills can unfortunately be changed with a CLEO ... AFAIK.
Just like server-sided money, detect it like that!
Re: L-Skills - Server sided weapon skill system! -
Lordzy - 24.06.2013
Quote:
Originally Posted by Inverse
An awesome include! One can produce wonderful systems with this thing. Just one question. What's the difference between client sided SA-MP skill system and yours? I mean of course it's server sided and all. But does the client sided skill also give more damage to other players as it increases?
|
The SA-MP skill system increases the skill rate so as to add some more features to it. Just like you get dual weapons in some cases where as in some weapons, you can move+aim and shoot (Weapons like deagle, M4, AK-47 and all). And what this does is add more damage for every weapons except a few like molotov and others. Also, enabling APPLY_DEFAULT_SKILL define in the script enables the SA-MP skill provided weapons too, so as if you set the skill of a weapon, if it's being skilled by SA-MP skills too, it gives it's own feature + L_Skills's feature. And, thanks for your feedback.
Quote:
Originally Posted by Lorenc_
Great release. Make sure you add anti-cheat to this, because weapon skills can unfortunately be changed with a CLEO ... AFAIK.
Just like server-sided money, detect it like that!
|
Didn't ever noticed that there was a cleo mod for weapon skills too.
Thanks for the info, I'll do that in the coming update version of this include. Thanks for your feedback too.
Re: L-Skills - Server sided weapon skill system! -
Inverse - 24.06.2013
Quote:
Originally Posted by Lordz™
The SA-MP skill system increases the skill rate so as to add some more features to it. Just like you get dual weapons in some cases where as in some weapons, you can move+aim and shoot (Weapons like deagle, M4, AK-47 and all). And what this does is add more damage for every weapons except a few like molotov and others. Also, enabling APPLY_DEFAULT_SKILL define in the script enables the SA-MP skill provided weapons too, so as if you set the skill of a weapon, if it's being skilled by SA-MP skills too, it gives it's own feature + L_Skills's feature. And, thanks for your feedback.
|
All right I get that. I'm going to use this to create an XP system. Looking forward to the next release.
Re: L-Skills - Server sided weapon skill system! -
Lordzy - 24.06.2013
Quote:
Originally Posted by Inverse
All right I get that. I'm going to use this to create an XP system. Looking forward to the next release.
|
Yeah, that's good if it's being used for XP system. It was mainly created for such scripts too.
OT:
I see that Pastebin won't work well for some countries. As a fact, I've added solidfiles mirror too.
Re: L-Skills - Server sided weapon skill system! -
Lordzy - 25.06.2013
As I've told earlier that v2 is in progress, it's very near to get updated. Though, I'm trying to release it as the final version of L_skills. Only a few features are added for the v2, which is:
- Anti-Skill cheat. Thanks to Lorenc_ for the suggestion.
- OnPlayerGiveDamage executes even though if a player is AFK, that's prevented in the v2 version. (L_skills won't damage player if he/she is paused.) <Thanks to SuperViper for noting me that.>
These are the current stuffs which I've coded in the 2nd version. Just like I said, I'm trying to make this as final so I'm looking forward for good suggestions and if there's any bugs, that too could be reported.