• Страница 1 из 1
  • 1
Форум » PAWNO » Уроки Pawno » Система прокачки скилов оружия по патронам.
Система прокачки скилов оружия по патронам.
Дмитрий Дата: Понедельник, 30.07.2012, 11:55 | Сообщение # 1 | Сообщить о нерабочей теме


Аватар для Дмитрий

Дефайны для регулировки кол - ва патронов, которые надо вытреить чтобы прокачать 1 процент

Code
#define Ammo_SDPISTOL 30 //Кол - во, которые надо выстрелить, чтоы прокачать 1 процент   
#define Ammo_DEAGLE 24 //Кол - во, которые надо выстрелить, чтоы прокачать 1 процент   
#define Ammo_SHOTGUN 15 //Кол - во, которые надо выстрелить, чтоы прокачать 1 процент   
#define Ammo_MP5 75 //Кол - во, которые надо выстрелить, чтоы прокачать 1 процент   
#define Ammo_AK47 100 //Кол - во, которые надо выстрелить, чтоы прокачать 1 процент   
#define Ammo_M4A1 89 //Кол - во, которые надо выстрелить, чтоы прокачать 1 процент  


В енумератор enum pInfo

Code
pGunSkill[6],  


В public OnPlayerRegister

Code
iniSetInt(File,"SDPistol",0);   
iniSetInt(File,"DesertEagle",0);   
iniSetInt(File,"ShotGun",0);   
iniSetInt(File,"MP5",0);   
iniSetInt(File,"AK47",0);   
iniSetInt(File,"M4",0);  


В public OnPlayerUpdate или типо этого(Сохранение переменных в акаунт)

Code
iniSetInt(File,"SDPistol",PlayerInfo[playerid][pGunSkill][0]);   
iniSetInt(File,"DesertEagle",PlayerInfo[playerid][pGunSkill][1]);   
iniSetInt(File,"ShotGun",PlayerInfo[playerid][pGunSkill][2]);   
iniSetInt(File,"MP5",PlayerInfo[playerid][pGunSkill][3]);   
iniSetInt(File,"AK47",PlayerInfo[playerid][pGunSkill][4]);   
iniSetInt(File,"M4",PlayerInfo[playerid][pGunSkill][5]);  


В public OnPlayerLogin

Code
iniGetInt(File,"SDPistol",PlayerInfo[playerid][pGunSkill][0]);   
iniGetInt(File,"DesertEagle",PlayerInfo[playerid][pGunSkill][1]);   
iniGetInt(File,"ShotGun",PlayerInfo[playerid][pGunSkill][2]);   
iniGetInt(File,"MP5",PlayerInfo[playerid][pGunSkill][3]);   
iniGetInt(File,"AK47",PlayerInfo[playerid][pGunSkill][4]);   
iniGetInt(File,"M4",PlayerInfo[playerid][pGunSkill][5]);  


public OnPlayerCommandTExt:

Code
if(strcmp(cmd, "/myskills", true) == 0)   
      {   
              new stringskill[1000];   
          new points[6],percent[2] = "%";   
          points[0] = 100 - PlayerInfo[playerid][pGunSkill][0];   
          points[1] = 100 - PlayerInfo[playerid][pGunSkill][1];   
          points[2] = 100 - PlayerInfo[playerid][pGunSkill][2];   
          points[3] = 100 - PlayerInfo[playerid][pGunSkill][3];   
          points[4] = 100 - PlayerInfo[playerid][pGunSkill][4];   
          points[5] = 100 - PlayerInfo[playerid][pGunSkill][5];   
           format(stringskill,1000,"SDPistol:\t[%s]%d%s\nDeagle:\t[%s]%d%s\nShotGun:\t[%s]%d%s\nMP5\t\t[%s]%d%s\nAK47:\t\t[%s]%d%s\nM4A1:\t\t[%s]%d%s",   
           ToDevelopSkills(PlayerInfo[playerid][pGunSkill][0],points[0]),PlayerInfo[playerid][pGunSkill][0],percent,   
           ToDevelopSkills(PlayerInfo[playerid][pGunSkill][1],points[1]),PlayerInfo[playerid][pGunSkill][1],percent,   
           ToDevelopSkills(PlayerInfo[playerid][pGunSkill][2],points[2]),PlayerInfo[playerid][pGunSkill][2],percent,   
           ToDevelopSkills(PlayerInfo[playerid][pGunSkill][3],points[3]),PlayerInfo[playerid][pGunSkill][3],percent,   
           ToDevelopSkills(PlayerInfo[playerid][pGunSkill][4],points[4]),PlayerInfo[playerid][pGunSkill][4],percent,   
           ToDevelopSkills(PlayerInfo[playerid][pGunSkill][5],points[5]),PlayerInfo[playerid][pGunSkill][5],percent);   
           ShowPlayerDialog(playerid,43,DIALOG_STYLE_MSGBOX,"<< Навыки владением оружием>>",stringskill,"Готово","");   
          return 1;   
}  


Ну и сама функция распознавание прокачки скиллов:

Code
stock ToDevelopSkills(Slashes,Points)   
{   
      new SlashesAndPoints[400];   
      new Slash[2] = "|";   
      new Point[2] = "'";   
      for(new i = 0; i < Slashes; i++) strcat(SlashesAndPoints, Slash);   
      for(new i = 0; i < Points; i++) strcat(SlashesAndPoints, Point);   
      return SlashesAndPoints;   
}  


В конец мода функцию скиллов игрока

Code
stock SetPlayerSkills(playerid)   
{   
      SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL_SILENCED, PlayerInfo[playerid][pGunSkill][0]*10);   
      SetPlayerSkillLevel(playerid, WEAPONSKILL_DESERT_EAGLE, PlayerInfo[playerid][pGunSkill][1]*10);   
      SetPlayerSkillLevel(playerid, WEAPONSKILL_SHOTGUN, PlayerInfo[playerid][pGunSkill][2]*10);   
      SetPlayerSkillLevel(playerid, WEAPONSKILL_MP5, PlayerInfo[playerid][pGunSkill][3]*10);   
      SetPlayerSkillLevel(playerid, WEAPONSKILL_AK47, PlayerInfo[playerid][pGunSkill][4]*10);   
      SetPlayerSkillLevel(playerid, WEAPONSKILL_M4, PlayerInfo[playerid][pGunSkill][5]*10);   
      return 1;   
}  


[admin]В public OnPlayerSpawn в самый конец[/admin]

Code
SetPlayerSkills(playerid);  


Теперь переменные для отчитывания патронов в самое начало public OnPlayerUpdate

Code
SetPVarInt(playerid, "NewPlayerAmmo", GetPlayerAmmo(playerid));   
if(GetPVarInt(playerid, "NewPlayerAmmo") != GetPVarInt(playerid, "PlayerAmmo"))   
{   
          OnPlayerAmmoChange(playerid, GetPVarInt(playerid, "NewPlayerAmmo"), GetPVarInt(playerid, "PlayerAmmo"));   
          SetPVarInt(playerid, "PlayerAmmo", GetPVarInt(playerid, "NewPlayerAmmo"));   
   }  


Ну и сам public куда нить тоже в конец мода

Code
stock OnPlayerAmmoChange(playerid, newammo, oldammo)   
{   
      if(newammo < oldammo)   
      {   
          switch(GetPlayerWeapon(playerid))   
          {   
              case 24:   
              {   
                  SetPVarInt(playerid, "SkillD",GetPVarInt(playerid,"SkillD") +1);   
                  if(GetPVarInt(playerid,"SkillD") >= Ammo_DEAGLE && PlayerInfo[playerid][pGunSkill][1] < 100)   
                  {   
                      PlayerInfo[playerid][pGunSkill][1]++;   
                      SetPVarInt(playerid, "SkillD",0);   
                  }   
              }   
              case 23:   
              {   
                  SetPVarInt(playerid, "SkillSD",GetPVarInt(playerid,"SkillSD") +1);   
                  if(GetPVarInt(playerid,"SkillSD")>= Ammo_SDPISTOL && PlayerInfo[playerid][pGunSkill][0] < 100)   
                  {   
                       PlayerInfo[playerid][pGunSkill][0]++;   
                       SetPVarInt(playerid, "SkillSD",0);   
                  }   
              }   
              case 25:   
              {   
                  SetPVarInt(playerid, "SkillShot",GetPVarInt(playerid,"SkillShot") +1);   
                  if(GetPVarInt(playerid,"SkillShot") >= Ammo_SHOTGUN && PlayerInfo[playerid][pGunSkill][2] < 100)   
                  {   
                      PlayerInfo[playerid][pGunSkill][2]++;   
                      SetPVarInt(playerid, "SkillShot",0);   
                  }   
              }   
              case 29:   
              {   
                  SetPVarInt(playerid, "SkillMP5",GetPVarInt(playerid,"SkillMP5") +1);   
                  if(GetPVarInt(playerid,"SkillMP5") >= Ammo_MP5 75 && PlayerInfo[playerid][pGunSkill][3] < 100)   
                  {   
                      PlayerInfo[playerid][pGunSkill][3]++;   
                      SetPVarInt(playerid, "SkillMP5",0);   
                  }   
              }   
              case 30:   
              {   
                  SetPVarInt(playerid, "SkillAk47",GetPVarInt(playerid,"SkillAk47") +1);   
                  if(GetPVarInt(playerid,"SkillAk47") >= Ammo_AK47 && PlayerInfo[playerid][pGunSkill][4] < 100)   
                  {   
                      PlayerInfo[playerid][pGunSkill][4]++;   
                      SetPVarInt(playerid, "SkillAk47",0);   
                  }   
              }   
              case 31:   
              {   
                  SetPVarInt(playerid, "SkillM4",GetPVarInt(playerid,"SkillM4") +1);   
                  if(GetPVarInt(playerid,"SkillM4") >= Ammo_M4A1 && PlayerInfo[playerid][pGunSkill][5] < 100)   
                  {   
                      PlayerInfo[playerid][pGunSkill][5]++;   
                      SetPVarInt(playerid, "SkillM4",0);   
                  }   
              }   
          }   
          SavePlayer(playerid);//замените на свою функцию сохранения   
      }   
      return 1;


В public OnPlayerConnect:

Code
PlayerInfo[playerid][pGunSkill][0] = 0;   
PlayerInfo[playerid][pGunSkill][1] = 0;   
PlayerInfo[playerid][pGunSkill][2] = 0;   
PlayerInfo[playerid][pGunSkill][3] = 0;   
PlayerInfo[playerid][pGunSkill][4] = 0;   
PlayerInfo[playerid][pGunSkill][5] = 0;  


Вот и всё.. Автор: Fresh_Light || Barni
Вот примерно так будет:


Чтобы проверить роботоспособность системы сделайте себе дигл, выстрелите 24 и более патронов и введите /myskill
if(Shot[playerid] >= кол -во) это сколько надо выстрелить патронов,чтобы прокачать 1% скил оружия


Обновлено, убран баг с прокачкой оружия(Если выстрелить 23 патрона с АК47 и 1 с дигла то дигл качнётся на 1 процент), убраны лишние переменные. Тестируем.


From Russia With Love!
Форум » PAWNO » Уроки Pawno » Система прокачки скилов оружия по патронам.
  • Страница 1 из 1
  • 1
Поиск: