A
Amfy
Гость
Гость
Ввиду того, что нынешняя сфера CR вообще не соображает что творит, решил выложить команду /invite с приглашением. То есть, лидер приглашает и игрок может согласиться (/yinv) или отказаться (/ninv). Команда опирается на пабликовские моды, то есть OnPlayerCommandText, strtok, ReturnUser и прочая белиберда.
В public OnPlayerCommandText вставляем:
if(strcmp(cmd,"/invite",true) == 0){ if(!IsPlayerConnected(playerid)) return 1; if(PlayerInfo[playerid][pLeader] <= 0) return SendClientMessage(playerid,-1,"Вы никто!"); tmp = strtok(cmdtext, idx); if(!strlen(tmp)) return SendClientMessage(playerid,-1,"/invite [ид игрока]"); new player,frac[30]; player = ReturnUser(tmp); if(!IsPlayerConnected(player)) return SendClientMessage(playerid,-1,"Этот игрок оффлайн!"); switch(PlayerInfo[playerid][pLeader]) { case 1: frac = "полицию"; case 2: frac = "ещё куда-нибудь"; } GetPlayerName(player,giveplayer,sizeof(giveplayer)); GetPlayerName(playerid,sendername,sizeof(sendername)); format(string,sizeof(string),"Вы пригласили %s к себе в фракцию",giveplayer); SendClientMessage(playerid,COLOR_LIGHTBLUE,string); format(string,sizeof(string),"%s приглашает вас в %s",sendername,frac); SendClientMessage(player,COLOR_LIGHTBLUE,string); SetPVarInt(player,"invfrac",PlayerInfo[playerid][pLeader]); SetPVarInt(player,"invid",playerid); return 1;}if(strcmp(cmd,"/yinv",true) == 0)//Согласиться{ if(!IsPlayerConnected(playerid)) return 1; if(GetPVarInt(playerid,"invfrac") == 0) return SendClientMessage(playerid,-1,"Вас никто никуда не приглашал!"); new leaid = GetPVarInt(playerid,"invid"),frac = GetPVarInt(playerid,"invfrac"); GetPlayerName(playerid,sendername,sizeof(sendername)); GetPlayerName(leaid,giveplayer,sizeof(giveplayer)); format(string,sizeof(string),"Вы приняли предложение от %s",giveplayer); SendClientMessage(playerid,COLOR_LIGHTBLUE,string); format(string,sizeof(string),"%s принял ваше предложение",sendername); SendClientMessage(leaid,COLOR_LIGHTBLUE,string); PlayerInfo[playerid][pMember] = frac;//Приняли в фракцию PlayerInfo[playerid][pRank] = 1;//Дали первый ранг DeletePVar(playerid,"invfrac"); DeletePVar(playerid,"invid"); return 1;}if(strcmp(cmd,"/ninv",true) == 0)//Отказаться{ if(!IsPlayerConnected(playerid)) return 1; if(GetPVarInt(playerid,"invfrac") == 0) return SendClientMessage(playerid,-1,"Вас никто никуда не приглашал!"); new leaid = GetPVarInt(playerid,"invid"); GetPlayerName(playerid,sendername,sizeof(sendername)); GetPlayerName(leaid,giveplayer,sizeof(giveplayer)); format(string,sizeof(string),"Вы отказались от предложения %s",giveplayer); SendClientMessage(playerid,COLOR_LIGHTBLUE,string); format(string,sizeof(string),"%s отказался от вашего приглашения",sendername); SendClientMessage(leaid,COLOR_LIGHTBLUE,string); DeletePVar(playerid,"invfrac"); DeletePVar(playerid,"invid"); return 1;}
Всё. Код рабочий. Если вы хотите видеть в нем какие-то свои заморочки, то делайте это уже сами.
В public OnPlayerCommandText вставляем:
if(strcmp(cmd,"/invite",true) == 0){ if(!IsPlayerConnected(playerid)) return 1; if(PlayerInfo[playerid][pLeader] <= 0) return SendClientMessage(playerid,-1,"Вы никто!"); tmp = strtok(cmdtext, idx); if(!strlen(tmp)) return SendClientMessage(playerid,-1,"/invite [ид игрока]"); new player,frac[30]; player = ReturnUser(tmp); if(!IsPlayerConnected(player)) return SendClientMessage(playerid,-1,"Этот игрок оффлайн!"); switch(PlayerInfo[playerid][pLeader]) { case 1: frac = "полицию"; case 2: frac = "ещё куда-нибудь"; } GetPlayerName(player,giveplayer,sizeof(giveplayer)); GetPlayerName(playerid,sendername,sizeof(sendername)); format(string,sizeof(string),"Вы пригласили %s к себе в фракцию",giveplayer); SendClientMessage(playerid,COLOR_LIGHTBLUE,string); format(string,sizeof(string),"%s приглашает вас в %s",sendername,frac); SendClientMessage(player,COLOR_LIGHTBLUE,string); SetPVarInt(player,"invfrac",PlayerInfo[playerid][pLeader]); SetPVarInt(player,"invid",playerid); return 1;}if(strcmp(cmd,"/yinv",true) == 0)//Согласиться{ if(!IsPlayerConnected(playerid)) return 1; if(GetPVarInt(playerid,"invfrac") == 0) return SendClientMessage(playerid,-1,"Вас никто никуда не приглашал!"); new leaid = GetPVarInt(playerid,"invid"),frac = GetPVarInt(playerid,"invfrac"); GetPlayerName(playerid,sendername,sizeof(sendername)); GetPlayerName(leaid,giveplayer,sizeof(giveplayer)); format(string,sizeof(string),"Вы приняли предложение от %s",giveplayer); SendClientMessage(playerid,COLOR_LIGHTBLUE,string); format(string,sizeof(string),"%s принял ваше предложение",sendername); SendClientMessage(leaid,COLOR_LIGHTBLUE,string); PlayerInfo[playerid][pMember] = frac;//Приняли в фракцию PlayerInfo[playerid][pRank] = 1;//Дали первый ранг DeletePVar(playerid,"invfrac"); DeletePVar(playerid,"invid"); return 1;}if(strcmp(cmd,"/ninv",true) == 0)//Отказаться{ if(!IsPlayerConnected(playerid)) return 1; if(GetPVarInt(playerid,"invfrac") == 0) return SendClientMessage(playerid,-1,"Вас никто никуда не приглашал!"); new leaid = GetPVarInt(playerid,"invid"); GetPlayerName(playerid,sendername,sizeof(sendername)); GetPlayerName(leaid,giveplayer,sizeof(giveplayer)); format(string,sizeof(string),"Вы отказались от предложения %s",giveplayer); SendClientMessage(playerid,COLOR_LIGHTBLUE,string); format(string,sizeof(string),"%s отказался от вашего приглашения",sendername); SendClientMessage(leaid,COLOR_LIGHTBLUE,string); DeletePVar(playerid,"invfrac"); DeletePVar(playerid,"invid"); return 1;}
Всё. Код рабочий. Если вы хотите видеть в нем какие-то свои заморочки, то делайте это уже сами.
Последнее редактирование: