|
Оффлайн
Пятница, 18.07.2014, 20:38 | Сообщение # 1
|
|
"Здравствуйте, уважаемые форумчане! В этой теме я научу Вас, как... " - создать Систему Бизнесов Специально для игрового портала isamp.3dn.ru. Автор: ARTEM_SKOROBAGACH
В enum pInfo
pPbiskey, pJob, pLocal,
В Начале мода
Код enum bInfo{ bOwned, bOwner[64], bMessage[128], bExtortion[24], Float:bEntranceX, Float:bEntranceY, Float:bEntranceZ, Float:bExitX, Float:bExitY, Float:bExitZ, bBuyPrice, bEntranceCost, bTill, bLocked, bInterior, bProducts, bMaxProducts, bPriceProd, Text3D: bLabel, b2Till, bCena, Float:bBarX, Float:bBarY, Float:bBarZ, bMafia, bZahvat}; new BizzInfo[19][bInfo];
В public OnGameModeInit()
Туда же ниже
Код //========================================================================== for(new h = 0; h < sizeof(BizzInfo); h++){ new pickups; new string2[128]; if(BizzInfo [h][bOwned]== 0){ AddStaticPickup(19132, 23, BizzInfo[h][bEntranceX], BizzInfo[h][bEntranceY], BizzInfo[h][bEntranceZ]); pickups++; format(string2, sizeof(string2), "{00b0ff}%s\n{ffffff}Продаётся\nЦена: {faff00}%d$",BizzInfo[h][bMessage],BizzInfo[h][bBuyPrice]); BizzInfo [h][bLocked]= 1; BizzInfo [h][bLabel]= Create3DTextLabel("Используте команду\nв данном месте",COLOR_YELLOW,BizzInfo[h][bBarX],BizzInfo[h][bBarY],BizzInfo[h][bBarZ],20.0,0,1); BizzInfo [h][bLabel]= Create3DTextLabel(string2,COLOR_YELLOW,BizzInfo[h][bEntranceX], BizzInfo[h][bEntranceY], BizzInfo[h][bEntranceZ],20.0,0,1);} if(BizzInfo [h][bOwned]== 1){ AddStaticPickup(19132, 23, BizzInfo[h][bEntranceX], BizzInfo[h][bEntranceY], BizzInfo[h][bEntranceZ]); pickups++; format(string2,sizeof(string2), "{00b0ff}%s\n{ffffff}Владелец:{5aff00}%s", BizzInfo[h][bMessage], BizzInfo[h][bOwner]); BizzInfo [h][bLabel]= Create3DTextLabel(string2,-1,BizzInfo[h][bEntranceX], BizzInfo[h][bEntranceY], BizzInfo[h][bEntranceZ],20.0,0,1);}} for(new h = 0; h < sizeof(SBizzInfo); h++){ if(SBizzInfo [h][sbOwned]== 0){ new string2[128];format(string2, sizeof(string2), "{00b0ff}%s\n{ffffff}Продаётся\nЦена: {faff00}%d$", SBizzInfo[h][sbMessage],SBizzInfo[h][sbBuyPrice]); SBizzInfo [h][sbLocked]= 1; SBizzInfo [h][sbLabel]= Create3DTextLabel(string2,COLOR_YELLOW,SBizzInfo[h][sbEntranceX], SBizzInfo[h][sbEntranceY], SBizzInfo[h][sbEntranceZ],20.0,0,1);} if(SBizzInfo [h][sbOwned]== 1){ new string2[128];format(string2,sizeof(string2), "{00b0ff}%s\n {ffffff}Владелец:{5aff00}%s\n{ffffff}Цена бензина: {faff00}%d$", SBizzInfo[h][sbMessage], SBizzInfo[h][sbOwner],SBizzInfo[h][sbPriceProd]); SBizzInfo [h][sbLabel]= Create3DTextLabel(string2,-1,SBizzInfo[h][sbEntranceX], SBizzInfo[h][sbEntranceY], SBizzInfo[h][sbEntranceZ],5.0,0,1);} CreateDynamicMapIcon(SBizzInfo[h][sbEntranceX], SBizzInfo[h][sbEntranceY], SBizzInfo[h][sbEntranceZ],56,0);} //==========================================================================
В public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
Код case 9898: { if(response) { for(new i = 0; i < sizeof(BizzInfo); i++) { if (PlayerToPoint(3, playerid,BizzInfo[i][bEntranceX], BizzInfo[bEntranceY], BizzInfo[bEntranceZ])) [i]{ [i]if(PlayerInfo [playerid][pCash]< BizzInfo[bEntranceCost]) [i]{ [i]SendClientMessage(playerid, COLOR_GRAD1,"У вас нет столько денег"); [i]return true; [i]} [i]PlayerInfo [playerid][pCash]-=BizzInfo[bEntranceCost]; [i]BizzInfo[b2Till] += BizzInfo[bEntranceCost]; [i]SetPlayerInterior(playerid,BizzInfo[bInterior]); [i]SetPlayerPos(playerid,BizzInfo[bExitX],BizzInfo[bExitY],BizzInfo[bExitZ]); [i]PlayerInfo [playerid][pInt]= BizzInfo[bInterior]; [i]SetPlayerVirtualWorld(playerid,0); [i]enterbiz [playerid]= 1; [i]return true; [i]} [i]} [i]} [i]else [i]{ [i]return true; [i]} [i]} [i]case 9828: [i]{ [i]if(response) [i]{ [i]new string[256]; [i]new playername[MAX_PLAYER_NAME]; [i]new sendername[MAX_PLAYER_NAME]; [i]new Float:oldposx, Float:oldposy, Float:oldposz; [i]GetPlayerName(playerid, playername, sizeof(playername)); [i]GetPlayerPos(playerid, oldposx, oldposy, oldposz); [i]if(PlayerInfo [playerid][pPbiskey]!= 255) return SendClientMessage(playerid, COLOR_WHITE, "У вас уже есть бизнес, введите /sellbiz чтобы его продать."); [i]for(new b = 0; b < sizeof(BizzInfo); b++) [i]{ [i]if(PlayerToPoint(2.0, playerid, BizzInfo[b][bEntranceX], BizzInfo[bEntranceY], BizzInfo[bEntranceZ]) && BizzInfo [bOwned]== 0) [b]{ [b]if(PlayerInfo [playerid][pCash]> BizzInfo[bBuyPrice]) [b]{ [b]PlayerInfo [playerid][pPbiskey]= b; [b]BizzInfo [bOwned]= 1; [b]BizzInfo [bLocked]= 0; [b]BizzInfo [bCena]= 100; [b]BizzInfo [bTill]= 0; [b]BizzInfo[b2Till] = 0; [b]PlayerInfo [playerid][pJob]= 0; [b]BizzInfo [bProducts]= 50; [b]BizzInfo [bEntranceCost]= 100; [b]GetPlayerName(playerid, sendername, sizeof(sendername)); [b]strmid(BizzInfo[bOwner], sendername, 0, strlen(sendername), 255); [b]PlayerInfo [playerid][pCash]-=BizzInfo[bBuyPrice]; [b]SetPlayerInterior(playerid,BizzInfo[bInterior]); [b]PlayerInfo [playerid][pInt]= BizzInfo[bInterior]; [b]SetPlayerPos(playerid,BizzInfo[bExitX],BizzInfo[bExitY],BizzInfo[bExitZ]); [b]SetPlayerVirtualWorld(playerid, 0); [b]PlayerInfo [playerid][pInt]= BizzInfo[bInterior]; [b]PlayerInfo [playerid][pLocal]= b+99; [b]SendClientMessage(playerid, COLOR_GREEN, " Бизнес приобретён"); [b]SendClientMessage(playerid, COLOR_WHITE, "Помощь по бизнесу: /help - Команды сервера - Бизнес"); [b]format(string,sizeof(string), "{00b0ff}%s\n{ffffff}Владелец:{5aff00}%s", BizzInfo[bMessage], BizzInfo[bOwner]); [b]Update3DTextLabelText(BizzInfo[bLabel], -1, string); [b]return true;} [b]else{ [b]SendClientMessage(playerid, COLOR_WHITE, "На Вашем счету нет столько денег!"); [b]return true;}}}} [b]else{ [b]return true;}}
в конце мода
Код stock LoadBizz() { new arrCoords[24][64]; new strFromFile2[256]; new File: file = fopen("bizz.cfg", io_read); if (file) { new idx; while (idx < sizeof(BizzInfo)) { fread(file, strFromFile2); split(strFromFile2, arrCoords, '|'); BizzInfo [idx][bOwned]= strval(arrCoords[0]); strmid(BizzInfo[idx][bOwner], arrCoords[1], 0, strlen(arrCoords[1]), 255); strmid(BizzInfo[idx][bMessage], arrCoords[2], 0, strlen(arrCoords[2]), 255); strmid(BizzInfo[idx][bExtortion], arrCoords[3], 0, strlen(arrCoords[3]), 255); BizzInfo [idx][bEntranceX]= floatstr(arrCoords[4]); BizzInfo [idx][bEntranceY]= floatstr(arrCoords[5]); BizzInfo [idx][bEntranceZ]= floatstr(arrCoords[6]); BizzInfo [idx][bExitX]= floatstr(arrCoords[7]); BizzInfo [idx][bExitY]= floatstr(arrCoords[8]); BizzInfo [idx][bExitZ]= floatstr(arrCoords[9]); BizzInfo [idx][bBuyPrice]= strval(arrCoords[10]); BizzInfo [idx][bEntranceCost]= strval(arrCoords[11]); BizzInfo [idx][bTill]= strval(arrCoords[12]); BizzInfo [idx][bLocked]= strval(arrCoords[13]); BizzInfo [idx][bInterior]= strval(arrCoords[14]); BizzInfo [idx][bProducts]= strval(arrCoords[15]); BizzInfo [idx][bMaxProducts]= strval(arrCoords[16]); BizzInfo [idx][bPriceProd]= strval(arrCoords[17]); BizzInfo[idx][b2Till] = strval(arrCoords[18]); BizzInfo [idx][bCena]= strval(arrCoords[19]); BizzInfo [idx][bBarX]= floatstr(arrCoords[20]); BizzInfo [idx][bBarY]= floatstr(arrCoords[21]); BizzInfo [idx][bBarZ]= floatstr(arrCoords[22]); BizzInfo [idx][bMafia]= strval(arrCoords[23]); //BizzInfo [idx][bWorld]= strval(arrCoords[19]); idx++; } fclose(file); } return true; } stock SaveHomeSbizz() { new idx; new File: file2; while (idx < sizeof(BizzInfo)) { new coordsstring[256]; format(coordsstring, sizeof(coordsstring), "%d|%s|%s|%s|%f|%f|%f|%f|%f|%f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%f|%f|%f|%d\n", BizzInfo[idx][bOwned], BizzInfo[idx][bOwner], BizzInfo[idx][bMessage], BizzInfo[idx][bExtortion], BizzInfo[idx][bEntranceX], BizzInfo[idx][bEntranceY], BizzInfo[idx][bEntranceZ], BizzInfo[idx][bExitX], BizzInfo[idx][bExitY], BizzInfo[idx][bExitZ], BizzInfo[idx][bBuyPrice], BizzInfo[idx][bEntranceCost], BizzInfo[idx][bTill], BizzInfo[idx][bLocked], BizzInfo[idx][bInterior], BizzInfo[idx][bProducts], BizzInfo[idx][bMaxProducts], BizzInfo[idx][bPriceProd], BizzInfo[idx][b2Till], BizzInfo[idx][bCena], BizzInfo[idx][bBarX], BizzInfo[idx][bBarY], BizzInfo[idx][bBarZ], BizzInfo[idx][bMafia]); if(idx == 0) { file2 = fopen("bizz.cfg", io_write); } else { file2 = fopen("bizz.cfg", io_append); } fwrite(file2, coordsstring); idx++; fclose(file2); } return true; } После Создаём forward
Код forward CustomPickups();
и в конце мода создаём Паблик
Код public CustomPickups() { new Float:oldposx, Float:oldposy, Float:oldposz; new enters[256]; for(new i = 0; i < MAX_PLAYERS; i++){ if(IsPlayerConnected(i)){ GetPlayerPos(i, oldposx, oldposy, oldposz); if(oldposx!=0.0 && oldposy!=0.0 && oldposz!=0.0){ for(new b = 0; b < sizeof(BizzInfo); b++){ if (PlayerToPoint(1, i,BizzInfo[b][bEntranceX], BizzInfo[bEntranceY], BizzInfo[bEntranceZ])){ [b]if(BizzInfo [bOwned]== 0){ [b]format(enters,sizeof(enters), "{FFFFFF}Вы действительно хотите приобрести этот бизнес?"); [b]ShowPlayerDialog(i,9828,DIALOG_STYLE_MSGBOX,"Бизнес", enters, "Да", "Нет"); [b]return true;} [b]if(PlayerInfo [i][pPbiskey]== 255){} [i]if(b == 0 || b == 1 || b == 2|| b == 3 ||b == 4 || b == 5 || b == 6){ [i]if(enterbiz == 0){ [i]if(BizzInfo [bLocked]== 1) return SendClientMessage(i, COLOR_GRAD1, "Бизнес закрыт!"); [i]format(enters,sizeof(enters), "{FFFFFF}Желаете войти за $%d?",BizzInfo[bEntranceCost]); [i]ShowPlayerDialog(i,9898,DIALOG_STYLE_MSGBOX,"Вход", enters, "Да", "Нет"); [i]return true;} [i]else{ [i]SetPlayerInterior(i,BizzInfo[bInterior]); [i]SetPlayerPos(i,BizzInfo[bExitX],BizzInfo[bExitY],BizzInfo[bExitZ]); [i]PlayerInfo [pInt]= BizzInfo[bInterior]; [i]SetPlayerVirtualWorld(i,0);} [i]if(PlayerInfo [pPbiskey]== b){ [i]if(BizzInfo [bLocked]== 1) return SendClientMessage(i, COLOR_GRAD1, "Бизнес закрыт!"); [i]SetPlayerInterior(i,BizzInfo[bInterior]); [i]SetPlayerPos(i,BizzInfo[bExitX],BizzInfo[bExitY],BizzInfo[bExitZ]); [i]PlayerInfo [pInt]= BizzInfo[bInterior]; [i]SetPlayerVirtualWorld(i,0); [i]return true;}} [i]else{ [i]SetPlayerInterior(i,BizzInfo[bInterior]); [i]SetPlayerPos(i,BizzInfo[bExitX],BizzInfo[bExitY],BizzInfo[bExitZ]); [i]PlayerInfo [pInt]= BizzInfo[bInterior]; [i]SetPlayerVirtualWorld(i,0); [i]} [i]} [i]} [i]} [i]} [i]} [i]return true; [i]} Если будит проблема с NameTimer();
и к new добавим
Код new enterbiz[MAX_PLAYERS]; |
|