SA-MP Forums Archive
Weapon Skill System [ REP + ] - 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: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Weapon Skill System [ REP + ] (/showthread.php?tid=574127)



Weapon Skill System [ REP + ] - _GHT_MarK445 - 13.05.2015

Hey guys!

I am doing little system, i will explain you how it SHOULD work.

If player kills player he will gain the skill level to weapon, from which he killed the player.

But, i need.. How can i Get the weapon, and set it to SetPlayerSkillLevel? I mean i cant use GetPlayerWeapon, couse SetPlayerSkillLevel have its certain weapon list (https://sampwiki.blast.hk/wiki/Weapon_Skills) so.. like.. how can i do it?

Whole system explanation how i need it is here:

Player 1 kills Player 2
Player 1 will receive message that +10 skills was added to weapon from which he killed Player 2
It will add +10 skills to Players 1 weapon from which he killed Player 2
and for example if Player 1 writes /weaponskills it will show him all avalible weapon skills weapons and show current values how much skill he have in them.

Thanks guys, the guy who helps me will receive reputation point from me.


Re: Weapon Skill System [ REP + ] - _GHT_MarK445 - 14.05.2015

BUMP


Re: Weapon Skill System [ REP + ] - Youssef221 - 14.05.2015

Do you mean that you want to increase the skill level of the weapon that you used to kill the other player?


Re: Weapon Skill System [ REP + ] - bigtigerbeee - 14.05.2015

too ez


Re: Weapon Skill System [ REP + ] - AnnaSB - 14.05.2015

Create a global array, like WepSkillTrans[],
Inside it, in each index, put that index's weapon's skill id, and those which don't accept skills, put -1.
For example:
PHP код:
new WepSkillTrans[45] = {
-
1// 0: Fist - No Skill
-1// 1: Knuckles - No Skill
...
8// 30: AK47 - AK47 Skill
9// 31: M4 - M4 Skill
...
}; 
and to get the skill id, you just put the weapon ID as the index,
For example you want to get the Shotgun's skill id, just write WepSkillTrans[WEAPON_SHOTGUN] and it will return you WEAPONSKILL_SHOTGUN (it's 3).

Edit: Just letting you know, there is a non-memorizing method too, as weapon IDs starting from the 9mm Pistol are mostly equivalent to weponid - 22, but it needs some IFs and it's a bit complicated:
PHP код:
stock GetWeaponSkillID(weaponid)
{
if (
weaponid 22 || weaponid 34) return -1;
if (
weaponid == 32) return 6;
if (
weaponid 32) return 10;
return 
weaponid 22;

Hope it helped. ^^


Re: Weapon Skill System [ REP + ] - Gammix - 14.05.2015

Its easy if you use this include(it already have this function: GetPlayerSkillLevel(playerid, skill);)
Download "playerfuncs.inc" (link: https://sampforum.blast.hk/showthread.php?tid=573961).

So you can increase the player skill level on every kill with getting the old skill level +
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID)
    {
        new skill = 0;
        switch(GetPlayerWeapon(killerid))
        {
            case 22: skill = WEAPONSKILL_PISTOL;
            case 23: skill = WEAPONSKILL_PISTOL_SILENCED;
            //... add all other types you want
        }
        SetPlayerSkillLevel(killerid, skill, GetPlayerSkillLevel(killerid, skill) + 10);
    }
    return 1;
}
For command part, if you are using zcmd:
pawn Код:
CMD:weaponskills(playerid)
{
    new string[144];
    format(string, sizeof(string) "Pistol: %i/1000", GetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL));//this is for pistol, it will show the pistol skills in client message form
    SendClientMessage(playerid, -1, string);
    //...add more if you want
    return 1;
}



Re: Weapon Skill System [ REP + ] - SoFahim - 14.05.2015

SetWeaponSkills(playerid) {
if(PlayerInfo[playerid][p9mmSkill] == 1) SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 999);
else SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 400);
if(PlayerInfo[playerid][pSilencedSkill] == 1) SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL_SILENCED, 999);
else SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL_SILENCED, 400);
if(PlayerInfo[playerid][pDeagleSkill] == 1) SetPlayerSkillLevel(playerid, WEAPONSKILL_DESERT_EAGLE, 999);
else SetPlayerSkillLevel(playerid, WEAPONSKILL_DESERT_EAGLE, 400);
if(PlayerInfo[playerid][pShotgunSkill] == 1) SetPlayerSkillLevel(playerid, WEAPONSKILL_SHOTGUN, 999);
else SetPlayerSkillLevel(playerid, WEAPONSKILL_SHOTGUN, 400);
if(PlayerInfo[playerid][pSawnoffSkill] == 1) SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 999);
else SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 400);
if(PlayerInfo[playerid][pSpasSkill] == 1) SetPlayerSkillLevel(playerid, WEAPONSKILL_SPAS12_SHOTGUN, 999);
else SetPlayerSkillLevel(playerid, WEAPONSKILL_SPAS12_SHOTGUN, 400);
if(PlayerInfo[playerid][pUziSkill] == 1) SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 999);
else SetPlayerSkillLevel(playerid, WEAPONSKILL_MICRO_UZI, 400);
if(PlayerInfo[playerid][pMp5Skill] == 1) SetPlayerSkillLevel(playerid, WEAPONSKILL_MP5, 999);
else SetPlayerSkillLevel(playerid, WEAPONSKILL_MP5, 400);
if(PlayerInfo[playerid][pAKSkill] == 1) SetPlayerSkillLevel(playerid, WEAPONSKILL_AK47, 999);
else SetPlayerSkillLevel(playerid, WEAPONSKILL_AK47, 400);
if(PlayerInfo[playerid][pM4Skill] == 1) SetPlayerSkillLevel(playerid, WEAPONSKILL_M4, 999);
else SetPlayerSkillLevel(playerid, WEAPONSKILL_M4, 400);
}

It can be helpful for you