К enum pInfo добавляем:
Код: Выделить всё
pGunSkill[6]
Дальше создадим stock
Код: Выделить всё
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 true;
}
И ещё один stock
Код: Выделить всё
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 && 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);
}
}
}
OnPlayerUpdateAc(playerid);
}
return true;
}
В public OnPlayerConnect(playerid)
Код: Выделить всё
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;
в public OnPlayerRegister(playerid, password[])
Код: Выделить всё
ini_setInteger(File, "SDPistol",PlayerInfo[playerid][pGunSkill][0]);
ini_setInteger(File, "DesertEagle",PlayerInfo[playerid][pGunSkill][1]);
ini_setInteger(File, "ShotGun",PlayerInfo[playerid][pGunSkill][2]);
ini_setInteger(File, "MP5",PlayerInfo[playerid][pGunSkill][3]);
ini_setInteger(File, "AK47",PlayerInfo[playerid][pGunSkill][4]);
ini_setInteger(File, "M4",PlayerInfo[playerid][pGunSkill][5]);
в public OnPlayerLogin(playerid,password[])
Код: Выделить всё
ini_getInteger(File, "SDPistol",PlayerInfo[playerid][pGunSkill][0]);
ini_getInteger(File, "DesertEagle",PlayerInfo[playerid][pGunSkill][1]);
ini_getInteger(File, "ShotGun",PlayerInfo[playerid][pGunSkill][2]);
ini_getInteger(File, "MP5",PlayerInfo[playerid][pGunSkill][3]);
ini_getInteger(File, "AK47",PlayerInfo[playerid][pGunSkill][4]);
ini_getInteger(File, "M4",PlayerInfo[playerid][pGunSkill][5]);
Ко всем командам
Код: Выделить всё
if(strcmp(cmd, "/myskill", true) == 0)
{
new stringskill[700];
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,sizeof(stringskill), "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 true;
}
if(strcmp(cmd, "/setskill", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "Ââåäèòå: /setskill [playerid/÷àñòü íèêà] [íîìåð] [êîëè÷åñòâî]");
SendClientMessage(playerid, COLOR_GRAD4, "[1] Slinced Pistol |[2] Desert Eagle |[3] MP5 |[4] AK47 |[5] M4A1 |[6] ShotGun");
return true;
}
giveplayerid = strval(tmp);
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "Ââåäèòå: /setskill [playerid/÷àñòü íèêà] [íîìåð] [êîëè÷åñòâî]");
SendClientMessage(playerid, COLOR_GRAD4, "[1] Slinced Pistol |[2] Desert Eagle |[3] MP5 |[4] AK47 |[5] M4A1 |[6] ShotGun");
return true;
}
new stat;
stat = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "Ââåäèòå: /setskill [playerid/÷àñòü íèêà] [íîìåð] [êîëè÷åñòâî]");
SendClientMessage(playerid, COLOR_GRAD4, "[1] Slinced Pistol |[2] Desert Eagle |[3] MP5 |[4] AK47 |[5] M4A1 |[6] ShotGun");
return true;
}
new amount;
amount = strval(tmp);
if (PlayerInfo[playerid][pAdmin] >= 6)
{
switch (stat)
{
case 1:
{
PlayerInfo[giveplayerid][pGunSkill][0] = amount;
format(string, sizeof(string), "Ñêèëë îðóæèÿ SDPistol ó íåãî òåïåðü ðàâåí %d.", amount);
}
case 2:
{
PlayerInfo[giveplayerid][pGunSkill][1] = amount;
format(string, sizeof(string), "Ñêèëë îðóæèÿ Desert Eagle ó íåãî òåïåðü ðàâåí %d.", amount);
}
case 3:
{
PlayerInfo[giveplayerid][pGunSkill][3] = amount;
format(string, sizeof(string), "Ñêèëë îðóæèÿ MP5 ó íåãî òåïåðü ðàâåí %d.", amount);
}
case 4:
{
PlayerInfo[giveplayerid][pGunSkill][4] = amount;
format(string, sizeof(string), "Ñêèëë îðóæèÿ AK47 ó íåãî òåïåðü ðàâåí %d.", amount);
}
case 5:
{
PlayerInfo[giveplayerid][pGunSkill][5] = amount;
format(string, sizeof(string), "Ñêèëë îðóæèÿ M4A1 ó íåãî òåïåðü ðàâåí %d.", amount);
}
case 6:
{
PlayerInfo[giveplayerid][pGunSkill][2] = amount;
format(string, sizeof(string), "Ñêèëë îðóæèÿ ShotGun ó íåãî òåïåðü ðàâåí %d.", amount);
}
default:
{
format(string, sizeof(string), "Íåèçâåñòíîå çíà÷åíèå", amount);
}
}
SendClientMessage(playerid, COLOR_GRAD1, string);
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "Âû íå óïîëíîìî÷åíû èñïîëüçîâàòü ýòó êîìàíäó!");
}
}
}
}
return true;
}