Создаем /en в диалоге [SVL]

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

Moderator: SJplayer

Avatar
Topic author
Aleksandr M
Модератор
Модератор
Posts: 55
With us: 7 years 3 months

Создаем /en в диалоге [SVL]

Post #1by Aleksandr » 23 Oct 2013, 20:39

Создаем /en в диалоге [SVL]

Image

Image

Image


Ко всем new

Code: Select all

new Boo[MAX_VEHICLES], Bonne[MAX_VEHICLES];  


Займемся созданием заправки, которая будет продавать канистры и рем.комплекты
в pInfo

Code: Select all

pRepka


в public OnPlayerRegister(playerid, password[])
добавляем строку с значением pRepka.
в public SavePlayer или SaveAccounts
так же добавляем строку со значением pRepk
В public OnPlayerCommandText

Code: Select all

СMD:getrepka(playeridparams[])
 {
 if(
PlayerToPoint(10.0playeridSBizzInfo[b][sbEntranceX], SBizzInfo[b][sbEntranceY], SBizzInfo[b][sbEntranceZ]))
 {
 if(
PlayerInfo[playerid][pRepka] == 10) return SCM(playeridCOLOR_GRAD1"У вас уже есть рем.комлекты");
 if(
PlayerInfo[playerid][pCash] < SBizzInfo[b][sbPriceProd]/3) return SCM(playerid,COLOR_GRAD1"Не достаточно денег!");
 
SBizzInfo[b][sbTill] += SBizzInfo[b][sbPriceProd]/3;
 
PlayerInfo[playerid][pCash] -= SBizzInfo[b][sbPriceProd]/3;
 
SBizzInfo[b][sbProducts] -= 20;
 
format(stringsizeof(string), "Вы купили рем.комплект за %d вирт",SBizzInfo[b][sbPriceProd]/3);
 
SCM(playerid0x6495EDFFstring);
 
PlayerInfo[playerid][pRepka] += 1;
 
PlayerInfo[playerid][pCash] -= SBizzInfo[b][sbPriceProd]/3;
 return 
true;
 }
CMD:en(playeridparams[]) 

   new 
text[64]; 
   new 
ftext[64]; 
   new 
b1text[64]; 
   new 
b2text[64]; 
   new 
ttext[512]; 
   new 
vehicle GetPlayerVehicleID(playerid); 
   if(
IsPlayerInVehicle(playerid,vehicle)) 
   { 
      if(
zavodis[vehicle] == 0) { text "[OFF] {00ff00}Завести {FFFFFF}двигатель"; } 
      else if(
zavodis[vehicle] == 1) { text "[ON] {ff0000}Выключить {FFFFFF}двигатель"; } 
      if(
Light[vehicle] == 0) { ftext "[OFF] {00ff00}Включить {FFFFFF}фары"; } 
      else if(
Light[vehicle] == 1) { ftext "[ON] {ff0000}Выключить {FFFFFF}фары"; } 
      if(
Bonne[vehicle] == 0) { b1text "[OFF] {00ff00}Открыть {FFFFFF}капот"; } 
      else if(
Bonne[vehicle] == 1) { b1text "[ON] {ff0000}Закрыть {FFFFFF}капот"; } 
      if(
Boo[vehicle] == 0) { b2text "[OFF] {00ff00}Открыть {FFFFFF}багажник"; } 
      else if(
Boo[vehicle] == 1) { b2text "[ON] {ff0000}Закрыть {FFFFFF}багажник"; } 
      
format(ttext,sizeof(ttext), "[1] >> %s\n[2] >> %s\n[3] >> %s\n[4] >> %s\n[5] >> Использовать канистру[количество - %d]\n[6] >> Использовать рем.комплект[количество - %d]\n[7] >> Информация о транспорте"
      
text,ftext,b1text,b2text,PlayerInfo[playerid][pFuel],PlayerInfo[playerid][pRepka]); 
      
SPD(playerid,8050,DIALOG_STYLE_LIST,"Меню автомобиля",ttext"Выбрать","Отмена"); 
   } 
   return 
true
}  


В public OnDialogResponse

Code: Select all

case 8050
        { 
            if(
response
            { 
                if(
listitem == 0
                { 
                    if(
GetVehicleModel(GetPlayerVehicleID(playerid)) == 481 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 509 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 510) return SCM(playerid,-1,"Недопустимый транспорт"); 
                    if(
GetPlayerVehicleID(playerid) == INVALID_VEHICLE_ID) return true
                    if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return true
                    if(
zavodis[GetPlayerVehicleID(playerid)] == 0
                    { 
                        
GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective); 
                        
SetVehicleParamsEx(GetPlayerVehicleID(playerid) ,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective); 
                        
zavodis[GetPlayerVehicleID(playerid)] = 1
                    } 
                    else if(
zavodis[GetPlayerVehicleID(playerid)] == 1
                    { 
                        
GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective); 
                        
SetVehicleParamsEx(GetPlayerVehicleID(playerid),VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective); 
                        
zavodis[GetPlayerVehicleID(playerid)] = 0
                    } 
                    return 
true
                } 
                if(
listitem == 1
                { 
                    if(
GetPlayerVehicleID(playerid) == INVALID_VEHICLE_ID) return true
                    if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return true
                    if(
Light[GetPlayerVehicleID(playerid)] == 0
                    { 
                       
GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective); 
                       
SetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot,objective); 
                       
Light[GetPlayerVehicleID(playerid)] = 1
                    } 
                    else 
                    { 
                       
GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective); 
                       
SetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective); 
                       
Light[GetPlayerVehicleID(playerid)] = 0
                    } 
                    return 
true
                } 
                if(
listitem == 2
                { 
                    if(
GetPlayerVehicleID(playerid) == INVALID_VEHICLE_ID) return true
                    if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return true
                    if(
Bonne[GetPlayerVehicleID(playerid)] == 0
                    { 
                       
GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective); 
                       
SetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,VEHICLE_PARAMS_ON,boot,objective); 
                       
Bonne[GetPlayerVehicleID(playerid)] = 1
                    } 
                    else 
                    { 
                       
GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective); 
                       
SetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,VEHICLE_PARAMS_OFF,boot,objective); 
                       
Bonne[GetPlayerVehicleID(playerid)] = 0
                    } 
                    return 
true
                } 
                if(
listitem == 3
                { 
                    if(
GetPlayerVehicleID(playerid) == INVALID_VEHICLE_ID) return true
                    if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return true
                    if(
Boo[GetPlayerVehicleID(playerid)] == 0
                    { 
                       
GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective); 
                       
SetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,VEHICLE_PARAMS_ON,objective); 
                       
Boo[GetPlayerVehicleID(playerid)] = 1
                    } 
                    else 
                    { 
                       
GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective); 
                       
SetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,VEHICLE_PARAMS_OFF,objective); 
                       
Boo[GetPlayerVehicleID(playerid)] = 0
                    } 
                    return 
true
                } 
                if(
listitem == 4
                { 
                    if(!
IsPlayerConnected(playerid)) return true
                    new 
car GetPlayerVehicleID(playerid); 
                    if(
PlayerInfo[playerid][pFuel] < 1) return SCM(playeridCOLOR_GREY"У Вас нет канистр!"); 
                    if(!
IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetVehicleModel(car) == 481 || GetVehicleModel(car) == 509 || GetVehicleModel(car) == 510) return SCM(playerid,COLOR_YELLOW"Вы не в автомобиле или этот транспорт нельзя заправить."); 
                    
SCM(playerid0x6495EDFF"Вы заправили ваш автомобиль 50 литрами бензина"); 
                    
Fuell[car] += 50
                    
PlayerInfo[playerid][pFuel] -= 1
                    return 
true
                } 
                if(
listitem == 5
                { 
                    if(!
IsPlayerConnected(playerid)) return true
                    new 
car GetPlayerVehicleID(playerid); 
                    if(
PlayerInfo[playerid][pRepka] < 1) return SCM(playeridCOLOR_GREY"У Вас нет рем.комлектов!"); 
                    
SCM(playerid0x6495EDFF"Вы починили Ваш автомобиль"); 
                    
AnRepairVehicle(car); 
                    
PlayerInfo[playerid][pRepka] -= 1
                    return 
true
                } 
                if(
listitem == 6
                { 
                    new 
ttext[256]; 
                    new 
gtext[256]; 
                    new 
hom PlayerInfo[playerid][pPhousekey]; 
                    if(
GetPlayerVehicleID(playerid) == caridhouse[playerid]) 
                    { 
                        
format(ttext,sizeof(ttext), "{FFFFFF}Регистрационный знак: {00ff00}%d{FFFFFF}\nМарка: {00ff00}%s{FFFFFF}\nСостояние: {00ff00}%d{ffffff}\nДата покупки: {00ff00}%d{ffffff}\nВладелец: {00ff00}%s"
                        
hom,VehicleNames[GetVehicleModel(GetPlayerVehicleID(playerid))-400],PlayerInfo[VehiclePlayer(GetPlayerVehicleID(playerid))][pProcents],PlayerInfo[playerid][pCarData],Name(VehiclePlayer(GetPlayerVehicleID(playerid)))); 
                        
SPD(playerid,8051,DIALOG_STYLE_MSGBOX,"Информация о автомобиле",ttext"Закрыть",""); 
                        return 
true
                    } 
                    else 
                    { 
                         
format(gtext,sizeof(gtext), "{FFFFFF}Регистрационный знак: {00ff00}Неизвестно{FFFFFF}\nМарка: {00ff00}%s{FFFFFF}\nСостояние: {00ff00}99{ffffff}\nВладелец: {00ff00}Нету"
                         
VehicleNames[GetVehicleModel(GetPlayerVehicleID(playerid))-400]); 
                         
SPD(playerid,8051,DIALOG_STYLE_MSGBOX,"Информация о автомобиле",gtext"Закрыть",""); 
                         return 
true
                    } 
                 } 
             } 
         }  

! ! !


  • Similar Topics
    Replies
    Views
    Last post

Return to “Уроки”

Who is online

Users browsing this forum: 1 guest