09.06.2013, 16:30
(
Последний раз редактировалось Lordzy; 22.01.2017 в 11:28.
Причина: Support for this include has been over!
)
(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
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);
*/
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;
}
(#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>
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)
[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™