• Страница 1 из 1
  • 1
[Мануал] Хитманы
Дмитрий Дата: Понедельник, 27.08.2012, 13:52 | Сообщение # 1 | Сообщить о нерабочей теме


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

Всем добрый день. Пиступим делать хитманов!

для начало создаем переменные

Code
new PlayerHit[MAX_PLAYERS] = INVALID_PLAYER_ID;  
new HitPlayer[MAX_PLAYERS] = INVALID_PLAYER_ID;  
new GotHit[MAX_PLAYERS];  
new GoChase[MAX_PLAYERS];  
new GetChased[MAX_PLAYERS];  
new ConnectPC[MAX_PLAYERS];  
new hitfound = 0;  
new hitid = 999;  
new PlayerValue[MAX_PLAYERS];  


далее идем в enum pinfo и добовляем

Code
pHeadValue,  


Теперь добавляем в public OnPlayerRegister(playerid, password[])

Code
ini_setInteger(iniFile,"HeadValue",PlayerInfo[playerid][pHeadValue]);  


public OnPlayerLogin(playerid, password[])

Code
ini_getInteger(iniFile,"HeadValue",PlayerInfo[playerid][pHeadValue]);  


и сохраняем у меня stock SavePlayer(playerid)

Code
ini_setInteger(iniFile,"HeadValue",PlayerInfo[playerid][pHeadValue]);  


Идем в public onplayerConnect

Code
ConnectPC[playerid] = 0;GoChase[playerid] = 999; GetChased[playerid] = 999;GotHit[playerid] = 0;  
и PlayerInfo[playerid][pHeadValue] = 0;  


Теперь создаем саму фракцию вот по этому уроку >>тык<<
Теперь создаем команду /portable и /contract

Code
if(strcmp(cmd, "/contract", true) == 0)  
     {  
         if(IsPlayerConnected(playerid))  
            {  
             tmp = strtok(cmdtext, idx);  
             if(!strlen(tmp)) return   SendClientMessage(playerid, COLOR_GRAD1, " * Использование: /contract [playerid/PartOfName] [amount]");  
             giveplayerid = ReturnUser(tmp);  
             tmp = strtok(cmdtext, idx);  
             if(!strlen(tmp)) return  SendClientMessage(playerid, COLOR_GRAD1, " * Использование: /contract [playerid/PartOfName] [amount]");  
             moneys = strvalEx(tmp);  
             if(moneys < 1000 || moneys > 100000) { SendClientMessage(playerid, COLOR_GREY, "   Сумма котрактов должна быть минимум $1000, и максимум $100000!"); return 1; }  
             if (IsPlayerConnected(giveplayerid))  
             {  
                 if(giveplayerid != INVALID_PLAYER_ID)  
                 {  
                     if(PlayerInfo[giveplayerid][pMember] == 29 && PlayerInfo[playerid][pMember] == 29) return  SendClientMessage(playerid, COLOR_GREY, " * Нельзя заказать контракт на члена вашего агенства!");  
                     else if(PlayerInfo[giveplayerid][pLeader] == 29 && PlayerInfo[playerid][pMember] == 29)   return   SendClientMessage(playerid, COLOR_GREY, " * Нельзя заказать контракт на члена вашего агенства!");  
                     else if(PlayerInfo[giveplayerid][pMember] == 29||PlayerInfo[giveplayerid][pLeader] == 29) return  SendClientMessage(playerid, COLOR_GREY, " * Вы неможете заказать этого человека!");  
                     else if(PlayerInfo[playerid][pMember] == 29) return  SendClientMessage(playerid, COLOR_GREY, "Вы не хитман");  
                     if(IsACop(giveplayerid) && moneys >= 3000)  
                     {  
                         SendClientMessage(playerid, COLOR_GREY, " * Только контракты больше $3000 могут быть положены на копов!");  
                         return 1;  
                     }  
                     if(giveplayerid == playerid) { SendClientMessage(playerid, COLOR_GREY, " * Вы не можете заказать себя!"); return 1; }  
                     GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));  
                     GetPlayerName(playerid, sendername, sizeof(sendername));  
                     playermoney = PlayerInfo[playerid][pCash];  
                     if (moneys > 0 && playermoney >= moneys)  
                     {  
                         PlayerInfo[playerid][pCash] -= moneys;  
                         PlayerInfo[playerid][pCash] -= moneys;  
                         GiveMoney(playerid, (0 - moneys));  
                         PlayerInfo[giveplayerid][pHeadValue]+=moneys;  
                         format(string, sizeof(string), " * %s заказал %s на сумму $%d.",sendername, giveplayer, moneys);  
                         SendFamilyMessage(29, COLOR_YELLOW, string);  
                         format(string, sizeof(string), " * Вы сделали контракт на %s за $%d.",giveplayer, moneys);  
                         SendClientMessage(playerid, COLOR_LIGHTBLUE, string);  
                         PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);  
                     }  
                     else  
                     {  
                         SendClientMessage(playerid, COLOR_GRAD1, " * У вас не хватает денег!");  
                     }  
                 }  
             }  
             else  
             {  
                 format(string, sizeof(string), "   %d не активный игрок.", giveplayerid);  
                 SendClientMessage(playerid, COLOR_GRAD1, string);  
             }  
         }  
         return true;  
     }  
if(strcmp(cmd,"/portable",true)==0)  
     {  
         if(IsPlayerConnected(playerid))  
         {  
             if(PlayerInfo[playerid][pMember] == 29 || PlayerInfo[playerid][pLeader] == 29)//меняем на свой  
             {  
                 if(ConnectPC[playerid] == 255)  
                 {  
                     SendClientMessage(playerid, COLOR_LIGHTBLUE, "• {FFFFFF}Ноутбук разъединен с агенством");  
                     ConnectedToPC[playerid] = 0;  
                     return true;  
                 }  
                 GetPlayerName(playerid, sendername, sizeof(sendername));  
                 SendClientMessage(playerid, COLOR_LIGHTBLUE, "• {FFFFFF}Вы загрузили ноутбук и подключились к агенству");  
                 SendClientMessage(playerid, COLOR_LIGHTBLUE, "• {FFFFFF}Чтобы открыть меню введите 'Hitmenu'");  
               ConnectPC[playerid] = 255;  
             }  
         }  
         return 1;  
     }  


Дальше идем в Public onplayertext

Code
if(ConnectPC[playerid] == 255)  
     {  
         new idx;  
         tmp = strtok(text, idx);  
         if ((strcmp("hitmenu", tmp, true, strlen(tmp)) == 0) && (strlen(tmp) == strlen("hitmenu")))  
         {  
             ShowPlayerDialog(playerid,7763,DIALOG_STYLE_LIST,"Хитман Menu","Доступные контракты\nПодписать контракт\nПриобрести оружие\nОтказаться от заказа\nНайти цель\nРазъедениться","Далее","Отмена");  
             return false;  
         }  
     }  


From Russia With Love!
Дмитрий Дата: Понедельник, 27.08.2012, 13:55 | Сообщение # 2 | Сообщить о нерабочей теме


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

Теперь добавляем диалоги

Code
case 7763:  
   {  
        if(response)  
         {  
              if(listitem == 0)  
              {  
                 SearchingHit(playerid);  
              }  
              if(listitem == 1)  
              {  
                 if(hitfound == 0)  
                 {  
                     SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "• {FFFFFF}Нет доступных контрактов!");  
                     return false;  
                 }  
                  ShowPlayerDialog(playerid,7764,DIALOG_STYLE_INPUT,"{b3f9b0}","{FFFFFF}Введите ID игрока кому хотите поручить контракт и нажмите {b3f9b0}'Принять'","Принять","");  
              }  
              if(listitem == 2)  
              {  
                  ShowPlayerDialog(playerid,7765,DIALOG_STYLE_INPUT,"{b3f9b0}Покупка","{FFFFFF}Впишите номер комплекта оружия и нажмите {b3f9b0}'Купить'\n\tКомплект оружия № 1 (5.000)\n\tКомплект оружия № 2 (6.000)\n\tКомплект оружия № 3 (7.000)\n\tКомплект оружия № 4 (8.000)\n\tКомплект оружия № 5 (9.000)\n\tКомплект оружия № 6 (10.000)\n\tКомплект оружия № 7 (11.000)\n","Купить","Отмена");  
              }  
              if(listitem == 3)  
              {  
              new giver[MAX_PLAYER_NAME];  
              new giveplayer[MAX_PLAYER_NAME];  
              new giveplayerid;  
             if(IsPlayerConnected(hitid))  
                 {  
                     new sendername[MAX_PLAYER_NAME];  
                     GetPlayerName(playerid,sendername,sizeof(sendername));  
                     GetPlayerName(playerid, sendername, sizeof(sendername));  
                     GetPlayerName(giveplayerid, giver, sizeof(giver));  
                     GetPlayerName(hitid, giveplayer, sizeof(giveplayer));  
                     format(string,sizeof(string),"• {FFFFFF}Хитман {b3f9b0}%s {FFFFFF}отказался от выполнения заказа на {b3f9b0}(ID:%d)",sendername,GoChase[playerid]);  
                     SendFamilyMessage(29,0xb3f9b0FF,string);  
                     GoChase[playerid] = hitid;  
                     GetChased[hitid] = giveplayerid;  
                       GotHit[hitid] = 1;  
                       hitid = 0;  
                       hitfound = 0;  
                     return false;  
                 }  
                 else  
                 {  
                     SendClientMessage(playerid,COLOR_WHITE,"{f9b0b0}x {FFFFFF}У Вас нет заказа");  
                     return false;  
                 }  
              }  
              if(listitem == 4)  
              {  
                 if(GoChase[playerid]!=999)  
                 {  
                     new giver[MAX_PLAYER_NAME];  
                     GetPlayerName(GoChase[playerid],giver,sizeof(giver));  
                     format(string,sizeof(string),"Цель {b3f9b0}%s[ID: %d] {FFFFFF}отмечена у Вас на карте, следуйте за ней",giver,GoChase[playerid]);  
                     SendClientMessage(playerid,COLOR_WHITE,string);  
                     new Float:X,Float:Y,Float:Z;  
                     GetPlayerPos(GoChase[playerid], X,Y,Z);  
                     SetPlayerCheckpoint(playerid, X,Y,Z, 6);  
                     return false;  
                 }  
                 else  
                 {  
                     SendClientMessage(playerid,COLOR_WHITE,"{f9b0b0}x {FFFFFF}Вы не за кем не охотитесь");  
                     return false;  
                 }  
              }  
              if(listitem == 5)  
              {  
                 SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "• {FFFFFF}Вы отключились от агенства и выключили ноутбук");  
                   ConnectPC[playerid] = 0;  
                 return false;  
              }  
       }  
   }  
   case 7764:  
   {  
        if(response)  
         {  
                new giveplayerid = strval(inputtext);  
             if(IsPlayerConnected(giveplayerid))  
             {  
                 if(giveplayerid != INVALID_PLAYER_ID)  
                 {  
                     if(PlayerInfo[giveplayerid][pMember] == 29 || PlayerInfo[giveplayerid][pLeader] == 29)  
                     {  
                         if(GoChase[giveplayerid] < 999)  
                         {  
                             SendClientMessage(playerid, COLOR_GREY, "• Тот хитман уже занят");  
                             return false;  
                         }  
                         if(IsPlayerConnected(hitid))  
                         {  
                             new giver[MAX_PLAYER_NAME];  
                             new sendername[MAX_PLAYER_NAME];  
                             new giveplayer[MAX_PLAYER_NAME];  
                             GetPlayerName(playerid, sendername, sizeof(sendername));  
                             GetPlayerName(giveplayerid, giver, sizeof(giver));  
                             GetPlayerName(hitid, giveplayer, sizeof(giveplayer));  
                             format(string, sizeof(string), "« %s[%d] заключил контракт с %s[%d] на убийство %s[%d] »", sendername,playerid, giver,giveplayerid, giveplayer, hitid);  
                             SendFamilyMessage(29, TEAM_AZTECAS_COLOR, string);  
                             GoChase[giveplayerid] = hitid;  
                             GetChased[hitid] = giveplayerid;  
                             GotHit[hitid] = 1;  
                             hitid = 0;  
                             hitfound = 0;  
                             return false;  
                         }  
                         else  
                         {  
                             SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "• {FFFFFF}Человек на которого контракт сейчас нет в игре!");  
                             return false;  
                         }  
                     }  
                     else  
                     {  
                         SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "• {FFFFFF}Тот игрок не хитман");  
                         return false;  
                     }  
                 }  
                 return false;  
             }  
             else  
             {  
                 SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "• {FFFFFF}Нет такого игрока!");  
                 return false;  
             }  
         }  
   }  
   case 7765:  
   {  
        if(response)  
         {  
                 new i = playerid;  
             if(!strcmp(inputtext, "1",true))  
             {  
                 if(GetPlayerMoney(i) > 5000)  
                 {  
                       GiveRichGun(i, 24, 50); GiveRichGun(i, 29, 500); GiveRichGun(i, 25, 50); GiveRichGun(i, 4, 1);  
                     PlayerInfo[playerid][pCash] -= 5000;  
                      SendClientMessage(i, COLOR_LIGHTBLUE, "• {FFFFFF}Вы приобрели комплект оружия № 1.");  
                  }  
                 else  
                 {  
                     SendClientMessage(i, COLOR_LIGHTBLUE, "• {FFFFFF}У Вас недостаточно денег.");  
                 }  
             }  
             if(!strcmp(inputtext, "2",true))  
             {  
                 if(GetPlayerMoney(i) > 6000)  
                 {  
                     GiveRichGun(i, 24, 50); GiveRichGun(i, 29, 500); GiveRichGun(i, 25, 50); GiveRichGun(i, 31, 500); GiveRichGun(i, 4, 1);  
                     PlayerInfo[playerid][pCash] -=6000;  
                      SendClientMessage(i, COLOR_LIGHTBLUE, "• {FFFFFF}Вы приобрели комплект оружия № 2.");  
                  }  
                 else  
                 {  
                     SendClientMessage(i, COLOR_LIGHTBLUE, "• {FFFFFF}У Вас недостаточно денег.");  
                 }  
             }  
             if(!strcmp(inputtext, "3",true))  
             {  
                 if(GetPlayerMoney(i) > 7000)  
                 {  
                     GiveRichGun(i, 24, 50); GiveRichGun(i, 29, 500); GiveRichGun(i, 25, 50); GiveRichGun(i, 30, 500); GiveRichGun(i, 4, 1);  
                     PlayerInfo[playerid][pCash] -=7000;  
                      SendClientMessage(i, COLOR_LIGHTBLUE, "• {FFFFFF}Вы приобрели комплект оружия № 3.");  
                  }  
                 else  
                 {  
                     SendClientMessage(i, COLOR_LIGHTBLUE, "• {FFFFFF}У Вас недостаточно денег.");  
                 }  
             }  
             if(!strcmp(inputtext, "4",true))  
             {  
                 if(GetPlayerMoney(i) > 8000)  
                 {  
                     GiveRichGun(i, 24, 50); GiveRichGun(i, 29, 500); GiveRichGun(i, 25, 50); GiveRichGun(i, 31, 500); GiveRichGun(i, 4, 1); GiveRichGun(i, 34, 20);  
                     PlayerInfo[playerid][pCash] -= 8000;  
                      SendClientMessage(i, COLOR_LIGHTBLUE, "• {FFFFFF}Вы приобрели комплект оружия № 4.");  
                  }  
                 else  
                 {  
                     SendClientMessage(i, COLOR_LIGHTBLUE, "• {FFFFFF}У Вас недостаточно денег.");  
                 }  
             }  
             if(!strcmp(inputtext, "5",true))  
             {  
                 if(GetPlayerMoney(i) > 10000)  
                 {  
                     GiveRichGun(i, 24, 50); GiveRichGun(i, 29, 500); GiveRichGun(i, 25, 50); GiveRichGun(i, 30, 500); GiveRichGun(i, 4, 1); GiveRichGun(i, 34, 20);  
                     PlayerInfo[playerid][pCash] -= 10000;  
                      SendClientMessage(i, COLOR_LIGHTBLUE, "• {FFFFFF}Вы приобрели комплект оружия № 5.");  
                  }  
                 else  
                 {  
                     SendClientMessage(i, COLOR_LIGHTBLUE, "• {FFFFFF}У Вас недостаточно денег.");  
                 }  
             }  
             if(!strcmp(inputtext, "6",true))  
             {  
                 if(GetPlayerMoney(i) > 11000)  
                 {  
                     GiveRichGun(i, 24, 50); GiveRichGun(i, 29, 500); GiveRichGun(i, 25, 50); GiveRichGun(i, 31, 500); GiveRichGun(i, 4, 1); GiveRichGun(i, 34, 20);  
                     PlayerInfo[playerid][pCash] -= 11000;  
                      SendClientMessage(i, COLOR_LIGHTBLUE, "• {FFFFFF}Вы приобрели комплект оружия № 6.");  
                 }  
                 else  
                 {  
                     SendClientMessage(i, COLOR_LIGHTBLUE, "• {FFFFFF}У Вас недостаточно денег.");  
                 }  
             }  
             if(!strcmp(inputtext, "7",true))  
             {  
                 if(GetPlayerMoney(i) > 12000)  
                 {  
                     GiveRichGun(i, 24, 50); GiveRichGun(i, 29, 500); GiveRichGun(i, 25, 50); GiveRichGun(i, 30, 500); GiveRichGun(i, 4, 1); GiveRichGun(i, 34, 20);  
                     PlayerInfo[playerid][pCash] -= 12000;  
                      SendClientMessage(i, COLOR_LIGHTBLUE, "• {FFFFFF}Вы приобрели комплект оружия № 7.");  
                  }  
                 else  
                 {  
                     SendClientMessage(i, COLOR_LIGHTBLUE, "• {FFFFFF}У Вас недостаточно денег.");  
                 }  
             }  
       }  
   }  


From Russia With Love!
Дмитрий Дата: Понедельник, 27.08.2012, 13:55 | Сообщение # 3 | Сообщить о нерабочей теме


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

Теперь в конец мода добавляем паблик

Code
forward  SearchingHit(playerid);  
public SearchingHit(playerid)  
{  
     new string[150];  
     new giveplayer[MAX_PLAYER_NAME];  
     new searchhit = 0;  
     for(new i=0; i<GetMaxPlayers(); i++)  
     {  
         if(IsPlayerConnected(i))  
         {  
             if(searchhit == 0)  
             {  
                 if(PlayerInfo[i][pHeadValue] > 0 && GotHit[i] == 0 && PlayerInfo[i][pMember] != 29)  
                 {  
                     GetPlayerName(i, giveplayer, sizeof(giveplayer));  
                     searchhit = 1;  
                     hitfound = 1;  
                     hitid = i;  
                     for(new k=0; k<GetMaxPlayers(); k++)  
                     {  
                         if(IsPlayerConnected(k))  
                         {  
                             if(PlayerInfo[k][pMember] == 29 || PlayerInfo[k][pLeader] == 29)//меняем на свое  
                             {  
                    format(string, sizeof(string), "Цель: %s[%d] Цена: $%d", giveplayer, i, PlayerInfo[i][pHeadValue]);  
                    SendClientMessage(k, COLOR_GREEN, string);  
                    SendClientMessage(k, COLOR_GREEN, "Откройте меню и выберите пункт 'Подписать контракт'");  
                    }  
                         }  
                     }  
                     return false;  
                 }  
             }  
         }  
     }  
     if(searchhit == 0)  
     {  
         SendClientMessage(playerid, COLOR_WHITE, "{f9b0b0}x {FFFFFF}Нет доступных контрактов.");  
     }  
     return false;  
}  


Теперь идем в public OnPlayerDeath(playerid, killerid, reason)

Code
if(PlayerInfo[playerid][pHeadValue] > 0)  
     {  
         if(IsPlayerConnected(killerid))  
         {  
             if(PlayerInfo[killerid][pLeader] == 29 || PlayerInfo[killerid][pMember] == 29)  
             {  
                 if(GoChase[killerid] == playerid)  
                 {  
                     new killer[MAX_PLAYER_NAME];  
                     GetPlayerName(killerid, killer, sizeof(killer));  
                     PlayerInfo[killerid][pCash] += PlayerInfo[playerid][pHeadValue];  
                     format(string,128,"<< Хитман %s выполнил контракт на %s и получил $%d >>",killer,name,PlayerInfo[playerid][pHeadValue]);  
                     SendFamilyMessage(29, COLOR_YELLOW, string);  
                     SendClientMessage(playerid, COLOR_LIGHTRED," * Вы были убиты хитманом по заказу!");  
                     PlayerInfo[playerid][pHeadValue] = 0;  
                     GotHit[playerid] = 0;  
                     GetChased[playerid] = 999;  
                     GoChase[killerid] = 999;  
                 }  
             }  
         }  
     }  
     if(killerid == PlayerHit[playerid])  
     {  
         if(playerid == HitPlayer[killerid])  
         {  
             //GivePlayerMoney(killerid,PlayerValue[playerid]);  
             PlayerInfo[killerid][pCash] += PlayerValue[playerid];  
             HitPlayer[killerid] = INVALID_PLAYER_ID;  
             PlayerHit[playerid] = INVALID_PLAYER_ID;  
         }  
     }  


Автор : Неизвестен


From Russia With Love!
  • Страница 1 из 1
  • 1
Поиск: