Делаем спортзал как на Samp-Rp

Уроки по скриптингу

Модератор: SJplayer

Аватара
Автор темы
May
Ефрейтор
Ефрейтор
Сообщения: 22
Репутация: 2
С нами: 5 лет 6 месяцев

Делаем спортзал как на Samp-Rp

Сообщение #1 May » 12 мая 2013, 14:32

Здравствуйте уважаемые пользователи
Сегодня я выкладываю урок по созданию спортзала как на Samp-Rp
И так начнём!

Ко всем new:

Код: Выделить всё

new winner[MAX_PLAYERS];
new 
sporthelp;
new 
boxform;
new 
boxforma[MAX_PLAYERS];
new 
InRing 0;
new 
RoundStarted 0;
new 
BoxDelay 0;
new 
Boxer1 255;
new 
Boxer2 255;
new 
TBoxer 255;
new 
PlayerBoxing[MAX_PLAYERS];
new 
BoxOffer[MAX_PLAYERS];
new 
BoxWaitTime[MAX_PLAYERS];
new 
sportMSG[12][] = {
/*0*/            {"{FFFFFF}Здесь вы можете выучить новый стиль боя\n"},
/*1*/            {"и немного подзаработать\n"},
/*2*/            {"Для начало занятия в зале переоденьтесь.\n"},
/*3*/            {"Если хотите участвовать в спарринге найдите тренера\n\n"},
/*4*/            {"И попросите устроить вам бой\n"},
/*5*/            {"Для изучения нового стиля боя вам надо:\n"},
/*6*/            {"1.Отрабатывать удары на груше\n"},
                {
"Использовать разные приёмы для большего эффекта\n"},
/*7*/            {"\n"},
/*8*/            {"2.Победить несколько раз на ринге\n"},
/*9*/            {"\n"},
/*10*/            {"\n"}
};   

Дальше в public OnPlayerDisconnect(playerid, reason) добавим

Код: Выделить всё

   if(PlayerBoxing[playerid] > 0){
        if(
Boxer1 == playerid){
         if(
IsPlayerConnected(Boxer2)){
             
PlayerBoxing[Boxer2] = 0;
         
SetPlayerPos(Boxer2765.8433,3.2924,1000.7186);
         
SetPlayerInterior(Boxer25);
         
GameTextForPlayer(Boxer2"~r~BREAK"50001);}}
         else if(
Boxer2 == playerid){
         if(
IsPlayerConnected(Boxer1)){
             
PlayerBoxing[Boxer1] = 0;
         
SetPlayerPos(Boxer1765.8433,3.2924,1000.7186);
         
SetPlayerInterior(Boxer15);
         
GameTextForPlayer(Boxer1"~r~BREAK"50001);}}
         
InRing 0;
             
RoundStarted 0;
         
Boxer1 255;
         
Boxer2 255;
         
TBoxer 255;}   

Ищем /accept или /use добавим

Код: Выделить всё

                    else if(strcmp(x_job,"fight",true) == 0)
            {
                if(
BoxOffer[playerid] < 999)
                {
                    if(
IsPlayerConnected(BoxOffer[playerid]))
                    {
                        
GetPlayerName(BoxOffer[playerid], giveplayersizeof(giveplayer));
                        
GetPlayerName(playeridsendernamesizeof(sendername));
                        
format(stringsizeof(string), "Вы приняли вызов на бой от %s",giveplayer);
                        
SendClientMessage(playeridCOLOR_LIGHTBLUEstring);
                        
format(stringsizeof(string), "%s принял ваш вызов на бой",sendername);
                        
SendClientMessage(BoxOffer[playerid], COLOR_LIGHTBLUEstring);
                        
SetPlayerHealthNoCheat(playerid100);
                        
SetPlayerHealthNoCheat(BoxOffer[playerid], 100);
                        
SetPlayerInterior(playerid5); SetPlayerInterior(BoxOffer[playerid], 5);
                        
SetPlayerPos(playerid762.9852,2.4439,1001.5942); SetPlayerFacingAngle(playerid131.8632);
                        
SetPlayerPos(BoxOffer[playerid], 758.7064,-1.8038,1001.5942); SetPlayerFacingAngle(BoxOffer[playerid], 313.1165);
                        
TogglePlayerControllable(playerid0); TogglePlayerControllable(BoxOffer[playerid], 0);
                        
GameTextForPlayer(playerid"~r~Waiting"30001); GameTextForPlayer(BoxOffer[playerid], "~r~Waiting"30001);
                        new 
name[MAX_PLAYER_NAME];
                        new 
dstring[MAX_PLAYER_NAME];
                        new 
wstring[MAX_PLAYER_NAME];
                        
GetPlayerName(playeridnamesizeof(name));
                        
format(dstringsizeof(dstring), "%s"name);
                        
strmid(wstringdstring0strlen(dstring), 255);
                        
BoxWaitTime[playerid] = 1BoxWaitTime[BoxOffer[playerid]] = 1;
                        if(
BoxDelay 1) { BoxDelay 5; }
                        
InRing 1;
                        
Boxer1 BoxOffer[playerid];
                        
Boxer2 playerid;
                                                
PlayerBoxing[playerid] = 1;
                        
PlayerBoxing[BoxOffer[playerid]] = 1;
                        
BoxOffer[playerid] = 999;
                        return 
1;
                    }
                    return 
1;
                }
                else return 
SendClientMessage(playeridCOLOR_GREY"Вам ни кто не предлагал бой!");
            }   

В public CustomPickups() добавим

Код: Выделить всё

            if(BoxWaitTime[i] > 0)
            {
                if(
BoxWaitTime[i] >= BoxDelay)
                {
                    
BoxDelay 0;
                    
BoxWaitTime[i] = 0;
                    
PlayerPlaySound(i10570.00.00.0);
                    
GameTextForPlayer(i"~g~Match Started"50001);
                    
TogglePlayerControllable(i1);
                    
RoundStarted 1;
                }
                else
                {
                    
format(stringsizeof(string), "%d"BoxDelay BoxWaitTime[i]);
                    
GameTextForPlayer(istring15006);
                    
BoxWaitTime[i] += 1;
                }
            }
            if(
RoundStarted 0)
            {
                if(
PlayerBoxing[i] > 0)
                {
                    new 
trigger 0;
                    new 
Lost 0;
                    new 
Float:angle;
                    new 
Float:health;
                    
GetPlayerHealth(ihealth);
                    if(
health 12)
                    {
                        if(
== Boxer1) { Lost 1trigger 1; }
                        else if(
== Boxer2) { Lost 2trigger 1; }
                    }
                    if(
health 28) { GetPlayerFacingAngle(iangle); SetPlayerFacingAngle(iangle 85); }
                    if(
trigger)
                    {
                        new 
loser[MAX_PLAYER_NAME];
                        new 
titel[MAX_PLAYER_NAME];
                        if(
Lost == 1)
                        {
                            if(
IsPlayerConnected(Boxer1) && IsPlayerConnected(Boxer2))
                            {
                                
SetPlayerPos(Boxer1765.8433,3.2924,1000.7186);
                                
SetPlayerPos(Boxer2765.8433,3.2924,1000.7186);
                                
SetPlayerInterior(Boxer15); SetPlayerInterior(Boxer25);
                                
GetPlayerName(Boxer1losersizeof(loser));
                                
GetPlayerName(Boxer2winnersizeof(winner));
                                if(
PlayerInfo[Boxer1][pJob] == 12) { PlayerInfo[Boxer1][pLoses] += 1; }
                                if(
PlayerInfo[Boxer2][pJob] == 12) { PlayerInfo[Boxer2][pWins] += 1; }
                                if(
TBoxer 255)
                                {
                                    if(
IsPlayerConnected(TBoxer))
                                    {
                                        if(
TBoxer != Boxer2)
                                        {
                                            if(
PlayerInfo[Boxer2][pJob] == 10)
                                            {
                                                
TBoxer Boxer2;
                                                
GetPlayerName(TBoxertitelsizeof(titel));
                                                new 
nstring[MAX_PLAYER_NAME];
                                                
format(nstringsizeof(nstring), "%s"titel);
                                                
strmid(Titel[TitelName], nstring0strlen(nstring), 255);
                                                
Titel[TitelWins] = PlayerInfo[TBoxer][pWins];
                                                
Titel[TitelLoses] = PlayerInfo[TBoxer][pLoses];
                                                
SaveBoxer();
                                            }
                                        }
                                        else
                                        {
                                            
GetPlayerName(TBoxertitelsizeof(titel));
                                            
Titel[TitelWins] = PlayerInfo[TBoxer][pWins];
                                            
Titel[TitelLoses] = PlayerInfo[Boxer2][pLoses];
                                            
SaveBoxer();
                                        }
                                    }
                                }
//TBoxer
                                
format(stringsizeof(string), "Вы проиграли борьбу против %s."winner);
                                
SendClientMessage(Boxer1COLOR_LIGHTBLUEstring);
                                
GameTextForPlayer(Boxer1"~r~You lost"35001);
                                
format(stringsizeof(string), "Вы выиграли борьбу против %s."loser);
                                
SendClientMessage(Boxer2COLOR_LIGHTBLUEstring);
                                
GameTextForPlayer(Boxer2"~r~You won"35001);
                                
GameTextForPlayer(Boxer1"~g~Match Over"50001); GameTextForPlayer(Boxer2"~g~Match Over"50001);
                                
PlayerBoxing[Boxer1] = 0;
                                
PlayerBoxing[Boxer2] = 0;
                            }
                        }
                        else if(
Lost == 2)
                        {
                            if(
IsPlayerConnected(Boxer1) && IsPlayerConnected(Boxer2))
                            {
                                
SetPlayerPos(Boxer1765.8433,3.2924,1000.7186); SetPlayerPos(Boxer2765.8433,3.2924,1000.7186);
                                
SetPlayerInterior(Boxer15); SetPlayerInterior(Boxer25);
                                
GetPlayerName(Boxer1winnersizeof(winner));
                                
GetPlayerName(Boxer2losersizeof(loser));
                                if(
TBoxer 255)
                                {
                                    if(
IsPlayerConnected(TBoxer))
                                    {
                                        if(
TBoxer != Boxer1)
                                        {
                                            if(
PlayerInfo[Boxer1][pJob] == 10)
                                            {
                                                
TBoxer Boxer1;
                                                
GetPlayerName(TBoxertitelsizeof(titel));
                                                new 
nstring[MAX_PLAYER_NAME];
                                                
format(nstringsizeof(nstring), "%s"titel);
                                                
strmid(Titel[TitelName], nstring0strlen(nstring), 255);
                                                
Titel[TitelWins] = PlayerInfo[TBoxer][pWins];
                                                
Titel[TitelLoses] = PlayerInfo[TBoxer][pLoses];
                                                
SaveBoxer();
                                            }
                                        }
                                        else
                                        {
                                            
GetPlayerName(TBoxertitelsizeof(titel));
                                            
Titel[TitelWins] = PlayerInfo[TBoxer][pWins];
                                            
Titel[TitelLoses] = PlayerInfo[Boxer1][pLoses];
                                            
SaveBoxer();
                                        }
                                    }
                                }
//TBoxer
                                
format(stringsizeof(string), "Вы проиграли борьбу против %s."winner);
                                
SendClientMessage(Boxer1COLOR_LIGHTBLUEstring);
                                
GameTextForPlayer(Boxer1"~r~You lost"35001);
                                
format(stringsizeof(string), "Вы выиграли борьбу против %s."loser);
                                
SendClientMessage(Boxer2COLOR_LIGHTBLUEstring);
                                
GameTextForPlayer(Boxer2"~r~You won"35001);
                                
GameTextForPlayer(Boxer1"~g~Match Over"50001); GameTextForPlayer(Boxer2"~g~Match Over"50001);
                                
PlayerBoxing[Boxer1] = 0;
                                
PlayerBoxing[Boxer2] = 0;
                            }
                        }
                        
InRing 0;
                        
RoundStarted 0;
                        
Boxer1 255;
                        
Boxer2 255;
                        
TBoxer 255;
                        
trigger 0;
                    }
                }
            }   

В конце мода добавим public

Код: Выделить всё

public SaveBoxer()
{
    new 
coordsstring[256];
    
format(coordsstringsizeof(coordsstring), "%d,%s,%d"Titel[TitelWins],Titel[TitelName],Titel[TitelLoses]);
    new 
Filefile2 fopen("boxer.ini"io_write);
    
fwrite(file2coordsstring);
    
fclose(file2);
    return 
1;
}   

Добавим в public OnPlayerCommandText(playerid, cmdtext[])

Код: Выделить всё

   if(strcmp(cmd"/fight"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            if(
InRing 0)return SendClientMessage(playeridCOLOR_GREY"Вы уже приняли бой!");
            if(
PlayerBoxing[playerid] > 0)return SendClientMessage(playeridCOLOR_GREY"Вы уже боритесь");
            if(!
PlayerToPoint(20.0,playerid,765.9343,0.2761,1000.7173))return SendClientMessage(playeridCOLOR_GREY"Вы не в спортзале!");
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp)) {
                
SendClientMessage(playeridCOLOR_WHITE"{DDA0DD} >> Введите{FFFFFF}: /fight [id]");
                return 
1;
            }
            
giveplayerid ReturnUser(tmp);
            if(
IsPlayerConnected(giveplayerid))
            {
                if(
giveplayerid != INVALID_PLAYER_ID)
                {
                    if (
ProxDetectorS(8.0playeridgiveplayerid))
                    {
                        if(
giveplayerid == playerid) { SendClientMessage(playeridCOLOR_GREY"Вы не можете вызвать на бой самого себя!"); return 1; }
                        
GetPlayerName(giveplayeridgiveplayersizeof(giveplayer));
                        
GetPlayerName(playeridsendernamesizeof(sendername));
                        
format(stringsizeof(string), "Вы предложили бой %s."giveplayer);
                        
SendClientMessage(playeridCOLOR_LIGHTBLUEstring);
                        
format(stringsizeof(string), " %s предлагает вам бой ((/accept fight)) чтобы принять."sendername);
                        
SendClientMessage(giveplayeridCOLOR_LIGHTBLUEstring);
                        
BoxOffer[giveplayerid] = playerid;
                    }
                    else return 
SendClientMessage(playeridCOLOR_GREY"Игрок не возле вас!");
                }
            }
            else return 
SendClientMessage(playeridCOLOR_GREY"Игрок не в сети!");
        }
        return 
1;
    }  

Теперь добавим в public OnPlayerPickUpPickup(playerid, pickupid)

Код: Выделить всё

if(pickupid == sporthelp)
    {
            new 
rabotadialog[2148];
                
format(rabotadialog,sizeof(rabotadialog), "%s%s%s%s%s%s%s%s%s%s%s%s",
            
sportMSG[0],sportMSG[1],sportMSG[2],sportMSG[3],sportMSG[4],sportMSG[5],sportMSG[6],sportMSG[7],sportMSG[8],sportMSG[9],sportMSG[10],sportMSG[11]);
            
ShowPlayerDialog(playerid,133,DIALOG_STYLE_MSGBOX,"Информация"rabotadialog"Ок""");
    }
    if(
pickupid == boxform)
    {
       
ShowPlayerDialog(playerid,408,DIALOG_STYLE_MSGBOX,"Выбор","В какую одежду вы хотите переодеться?","Спорт","Обычный");
    }   

Теперь в public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) добавим

Код: Выделить всё

        case 408:
        {
        if(
response)
        {
               if(
boxforma[playerid] == 1)return SendClientMessage(playerid,0xFFFFFFFF,"Вы уже в спортивной форме");
            
OldSkin[playerid] = GetPlayerSkin(playerid);
            
boxforma[playerid] = 1;
            
SetPlayerSkin(playerid,80);
            if(
PlayerInfo[playerid][pSex] == 2)
            {
            
SetPlayerSkin(playerid,41);
            }
           return 
1;
        }
        else
        {
        if(
boxforma[playerid] == 0)return SendClientMessage(playerid,0xFFFFFFFF,"Вы в своей одежде");
            
boxforma[playerid] = 0;
            
SetPlayerSkin(playeridOldSkin[playerid]);
        return 
1;
        }
    }   

Добавим пикапы и 3D текст

Код: Выделить всё

sporthelp CreatePickup(1239,23,773.8960,5.2577,1000.7802);
    
boxform CreatePickup(1275,23,756.4088,6.0036,1000.6992);
    
CreatePickup(1314,23,765.3245,10.8755,1000.7081);
    
Create3DTextLabel("/fight чтобы начать бой",COLOR_BLUE,765.3245,10.8755,1000.7081,25.0,0,1);   

Автор - Не знаю

! ! !


  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Уроки»

Кто сейчас на форуме

Сейчас этот раздел просматривают: 1 гость