pSDPistol, pDesertEagle, pShotGun, pMP5, pAK47, pM4,
Ко всем переменным:
new iPlayerAmmo[MAX_PLAYERS]; new iNewPlayerAmmo[MAX_PLAYERS]; new Shot[MAX_PLAYERS];
В public OnPlayerRegister и в паблик сохранения:
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 OnPlayerLogin
iniGetInt(File, "SDPistol", PlayerInfo[playerid][pSDPistol]); iniGetInt(File, "DesertEagle", PlayerInfo[playerid][pDesertEagle]); iniGetInt(File, "ShotGun", PlayerInfo[playerid][pShotGun]); iniGetInt(File, "MP5", PlayerInfo[playerid][pMP5]); iniGetInt(File, "AK47", PlayerInfo[playerid][pAK47]); iniGetInt(File, "M4", PlayerInfo[playerid][pM4]);
Добовляем команду /myskill для sscanf_zcmd:
CMD:myskill(playerid, params[]) { if(!GetPVarInt(playerid, "PlayerLogged")) return true; new string[1000]; new points[6]; points[0] = 100 - PlayerInfo[playerid][pSDPistol]; points[1] = 100 - PlayerInfo[playerid][pDesertEagle]; points[2] = 100 - PlayerInfo[playerid][pShotGun]; points[3] = 100 - PlayerInfo[playerid][pMP5]; points[4] = 100 - PlayerInfo[playerid][pAK47]; points[5] = 100 - PlayerInfo[playerid][pM4]; format(string, 1000, "SDPistol:\t[%s]%d%\nDeagle:\t[%s]%d%\nShotGun:\t[%s]%d%\nMP5\t\t[%s]%d%\ nAK47:\t\t[%s]%d%\nM4A1:\t\t[%s]%d%", ToDevelopSkills(PlayerInfo[playerid][pSDPistol], points[0]), PlayerInfo[playerid][pSDPistol], ToDevelopSkills(PlayerInfo[playerid][pDesertEagle], points[1]), PlayerInfo[playerid][pDesertEagle], ToDevelopSkills(PlayerInfo[playerid][pShotGun], points[2]), PlayerInfo[playerid][pShotGun], ToDevelopSkills(PlayerInfo[playerid][pMP5], points[3]), PlayerInfo[playerid][pMP5], ToDevelopSkills(PlayerInfo[playerid][pAK47], points[4]), PlayerInfo[playerid][pAK47], ToDevelopSkills(PlayerInfo[playerid][pM4], points[5]), PlayerInfo[playerid][pM4]); ShowPlayerDialog(playerid, 43, DIALOG_STYLE_MSGBOX, "<< Навыки владения оружием >>", string, "Готово", ""); return true; }
Для обычных команд:
if(strcmp(cmd, "/myskills", true) == 0) { if(!GetPVarInt(playerid, "PlayerLogged")) return true; new string[1024 + 1]; new points[6]; points[0] = 100 - PlayerInfo[playerid][pSDPistol]; points[1] = 100 - PlayerInfo[playerid][pDesertEagle]; points[2] = 100 - PlayerInfo[playerid][pShotGun]; points[3] = 100 - PlayerInfo[playerid][pMP5]; points[4] = 100 - PlayerInfo[playerid][pAK47]; points[5] = 100 - PlayerInfo[playerid][pM4]; format(string, sizeof string, "SDPistol:\t[%s]%d%\nDeagle:\t[%s]%d%\nShotGun:\t[%s]%d%\nMP5\t\t[%s]%d%\ nAK47:\t\t[%s]%d%\nM4A1:\t\t[%s]%d%", ToDevelopSkills(PlayerInfo[playerid][pSDPistol], points[0]), PlayerInfo[playerid][pSDPistol], ToDevelopSkills(PlayerInfo[playerid][pDesertEagle], points[1]), PlayerInfo[playerid][pDesertEagle], ToDevelopSkills(PlayerInfo[playerid][pShotGun], points[2]), PlayerInfo[playerid][pShotGun], ToDevelopSkills(PlayerInfo[playerid][pMP5], points[3]), PlayerInfo[playerid][pMP5], ToDevelopSkills(PlayerInfo[playerid][pAK47], points[4]), PlayerInfo[playerid][pAK47], ToDevelopSkills(PlayerInfo[playerid][pM4], points[5]), PlayerInfo[playerid][pM4]); ShowPlayerDialog(playerid, 43, DIALOG_STYLE_MSGBOX, "<< Навыки владения оружием >>", string, "Готово", ""); return true; }
Ну и сама функция распознавание прокачки скиллов:
stock ToDevelopSkills(Slashes,Points) { new string[256 + 1]; new Slash[2] = "|"; new Point[2] = "."; for(new i = 0; i < Slashes; i++) strcat(string, Slash); for(new i = 0; i < Points; i++) strcat(string, Point); return string; }
В конец мода функцию скиллов игрока
stock SetPlayerSkills(playerid) { if(PlayerInfo[playerid][pSDPistol] >= 100) SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL_SILENCED, 1000); if(PlayerInfo[playerid][pDesertEagle] >= 100) SetPlayerSkillLevel(playerid, WEAPONSKILL_DESERT_EAGLE, 1000); if(PlayerInfo[playerid][pShotGun] >= 100) SetPlayerSkillLevel(playerid, WEAPONSKILL_SHOTGUN, 1000); if(PlayerInfo[playerid][pMP5] >= 100) SetPlayerSkillLevel(playerid, WEAPONSKILL_MP5, 1000); if(PlayerInfo[playerid][pAK47] >= 100) SetPlayerSkillLevel(playerid, WEAPONSKILL_AK47, 1000); if(PlayerInfo[playerid][pM4] >= 100) SetPlayerSkillLevel(playerid, WEAPONSKILL_M4, 1000); return 1; }
В public OnPlayerSpawn добавить в самый конец:
SetPlayerSkills(playerid);
Теперь переменные для отчитывания патронов в public OnPlayerUpdate
iNewPlayerAmmo[playerid] = GetPlayerAmmo(playerid); if(iNewPlayerAmmo[playerid] != iPlayerAmmo[playerid]) { OnPlayerAmmoChange(playerid, iNewPlayerAmmo[playerid], iPlayerAmmo[playerid]); iPlayerAmmo[playerid] = iNewPlayerAmmo[playerid]; }
Ну и сам public куда нить тоже в конец мода
public OnPlayerAmmoChange(playerid, newammo, oldammo) { new weaponid = GetPlayerWeapon(playerid); if(weaponid == 24 && newammo < oldammo) { Shot[playerid]++; if(Shot[playerid] >= 24) { PlayerInfo[playerid][pDesertEagle] ++; Shot[playerid] = 0; SaveAccount(playerid);//Или ваша функция сохранение акаунта } } if(weaponid == 23 && newammo < oldammo) { Shot[playerid]++; if(Shot[playerid] >= 30) { PlayerInfo[playerid][pSDPistol] ++; Shot[playerid] = 0; SaveAccount(playerid);//Или ваша функция сохранение акаунта } } if(weaponid == 25 && newammo < oldammo) { Shot[playerid]++; if(Shot[playerid] >= 15) { PlayerInfo[playerid][pShotGun] ++; Shot[playerid] = 0; SaveAccount(playerid);//Или ваша функция сохранение акаунта } } if(weaponid == 29 && newammo < oldammo) { Shot[playerid]++; if(Shot[playerid] >= 75) { PlayerInfo[playerid][pMP5] ++; Shot[playerid] = 0; SaveAccount(playerid);//Или ваша функция сохранение акаунта } } if(weaponid == 30 && newammo < oldammo) { Shot[playerid]++; if(Shot[playerid] >= 100) { PlayerInfo[playerid][pAK47] ++; Shot[playerid] = 0; SaveAccount(playerid);//Или ваша функция сохранение акаунта } } if(weaponid == 29 && newammo < oldammo) { Shot[playerid]++; if(Shot[playerid] >= 89) { PlayerInfo[playerid][pM4] ++; Shot[playerid] = 0; SaveAccount(playerid);//Или ваша функция сохранение акаунта } } return 1; }
Код if(Shot[playerid] >= кол-во) отвечает за кол-во патронов которые нужно выстрелить для прокачки.
В public OnPlayerLogin:
SetPVarInt(playerid, "PlayerLogged", 1);
Автор: Fresh_Light
Сообщение отредактировал Romzes: 23 апреля 2021 - 02:00