Joker_Fox
Специалист
Всем привет. Представляю Вашему вниманию систему закусочных(Burger Shot, Pizza Stuck, Ponchik...).
Для начала создадим переменные и enum массив:
Теперь функции загрузки и сохранения:
В public OnGameModeInit
И последнее - вход/выход. В public OnPlayerKeyStateChange
Вот и все! Осталось создать файл fastfoods.cfg
Как добавить свою закусочную?
Все просто! В файле fastfoods.cfg добавляем ещё одну строку и пишем:
0|The State|НАЗВАНИЕ|X|Y|Z|2|50000|СМ.НИЖЕ |10000
Где СМ.НИЖЕ это тип закусочной.
0 - Cluckin Bell
1- Burger Shot
2 - Pizza Stuck
3 - Ponchik
И не забудь увеличить new FFInfo[31][ffInfo];
Автор? Осетин
Для начала создадим переменные и enum массив:
PHP:
enum ffInfo
{
ffOwned, ffOwner[24], ffMessage[15], Float:ffEntranceX, Float:ffEntranceY, Float:ffEntranceZ,
ffBuyPrice, ffType, ffProds,ffLevelNeeded
};
new FFInfo[31][ffInfo];//тут 31 - сколько всего закусочных
new Text3D:fastfood_text[sizeof(FFInfo)];
new enterfastfood[MAX_PLAYERS];
PHP:
stock LoadFastFoods()
{
new arrCoords[10][64];
new strFromFile2[256];
new File: file = fopen("fastfoods.cfg", io_read);
if (file)
{
new idx;
while (idx < sizeof(FFInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, '|');
FFInfo[idx][ffOwned] = strval(arrCoords[0]);
strmid(FFInfo[idx][ffOwner], arrCoords[1], 0, strlen(arrCoords[1]), 255);
strmid(FFInfo[idx][ffMessage], arrCoords[2], 0, strlen(arrCoords[2]), 255);
FFInfo[idx][ffEntranceX] = floatstr(arrCoords[3]);
FFInfo[idx][ffEntranceY] = floatstr(arrCoords[4]);
FFInfo[idx][ffEntranceZ] = floatstr(arrCoords[5]);
FFInfo[idx][ffLevelNeeded] = strval(arrCoords[6]);
FFInfo[idx][ffBuyPrice] = strval(arrCoords[7]);
FFInfo[idx][ffType] = strval(arrCoords[8]);
FFInfo[idx][ffProds] = strval(arrCoords[9]);
idx++;
}
fclose(file);
}
}
stock SaveFastFoods()
{
new idx = 0;
new File: file2;
while (idx < sizeof(FFInfo))
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%d|%s|%s|%f|%f|%f|%d|%d|%d|%d\n",
FFInfo[idx][ffOwned],
FFInfo[idx][ffOwner],
FFInfo[idx][ffMessage],
FFInfo[idx][ffEntranceX],
FFInfo[idx][ffEntranceY],
FFInfo[idx][ffEntranceZ],
FFInfo[idx][ffLevelNeeded],
FFInfo[idx][ffBuyPrice],
FFInfo[idx][ffType],
FFInfo[idx][ffProds]);
if(!idx) file2 = fopen("fastfoods.cfg", io_write);
else file2 = fopen("fastfoods.cfg", io_append);
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
}
PHP:
LoadFastFoods();
for(new h = 0; h < sizeof(FFInfo); h++)
{
format(string,sizeof(string), "{FFFF00}%s\n\n*Нажмите {FFFFFF}ALT{FFFF00}, чтобы войти", FFInfo[h][ffMessage]);
fastfood_text[h] = CreateDynamic3DTextLabel(string,-1,FFInfo[h][ffEntranceX], FFInfo[h][ffEntranceY],FFInfo[h][ffEntranceZ],30.0);
AddStaticPickup(19132, 1, FFInfo[h][ffEntranceX], FFInfo[h][ffEntranceY], FFInfo[h][ffEntranceZ]);
switch(FFInfo[h][ffType])
{
case 0: CreateDynamicMapIcon(FFInfo[h][ffEntranceX],FFInfo[h][ffEntranceY],FFInfo[h][ffEntranceZ],14,0);//Clukin Bell
case 1: CreateDynamicMapIcon(FFInfo[h][ffEntranceX],FFInfo[h][ffEntranceY],FFInfo[h][ffEntranceZ],10,0);//Burger Shot
case 2: CreateDynamicMapIcon(FFInfo[h][ffEntranceX],FFInfo[h][ffEntranceY],FFInfo[h][ffEntranceZ],29,0);//Pizza Stuck
}
}
PHP:
if(newkeys == 1024)//ATL
{
if(enterfastfood[playerid] < 0)
{
for(new i = 0; i < sizeof(FFInfo); i++)
{
if(!PlayerToPoint(4.0, playerid,FFInfo[i][ffEntranceX], FFInfo[i][ffEntranceY], FFInfo[i][ffEntranceZ])) continue;
switch(FFInfo[i][ffType])
{
case 0:
{
SetPlayerPos(playerid,365.6,-10.7,1001.8); SetPlayerInterior(playerid,9); SetPlayerVirtualWorld(playerid,i);
enterfastfood[playerid] = i;
}
case 1:
{
SetPlayerPos(playerid,363.4,-74.5,1001.5); SetPlayerInterior(playerid,10); SetPlayerVirtualWorld(playerid,i);
enterfastfood[playerid] = i;
}
case 2:
{
SetPlayerPos(playerid,372.2551,-132.9653,1001.4922); SetPlayerInterior(playerid,5); SetPlayerVirtualWorld(playerid,i);
enterfastfood[playerid] = i;
}
case 3:
{
SetPlayerPos(playerid,377.1016,-192.8593,1000.6401); SetPlayerInterior(playerid,17); SetPlayerVirtualWorld(playerid,i);
enterfastfood[playerid] = i;
}
}
}
}
else if(enterfastfood[playerid] >= 0)
{
if(PlayerToPoint(4.0,playerid, 365.6,-10.7,1001.8) || PlayerToPoint(4.0,playerid, 363.4,-74.5,1001.5) || PlayerToPoint(4.0,playerid, 372.2551,-132.9653,1001.4922) || PlayerToPoint(4.0,playerid, 377.1016,-192.8593,1000.6401))
{
SetPlayerInterior(playerid,0); SetPlayerVirtualWorld(playerid,0);
SetPlayerPos(playerid,FFInfo[enterfastfood[playerid]][ffEntranceX], FFInfo[enterfastfood[playerid]][ffEntranceY], FFInfo[enterfastfood[playerid]][ffEntranceZ]);
enterfastfood[playerid] = -1;
}
}
}
Как добавить свою закусочную?
Все просто! В файле fastfoods.cfg добавляем ещё одну строку и пишем:
0|The State|НАЗВАНИЕ|X|Y|Z|2|50000|СМ.НИЖЕ |10000
Где СМ.НИЖЕ это тип закусочной.
0 - Cluckin Bell
1- Burger Shot
2 - Pizza Stuck
3 - Ponchik
И не забудь увеличить new FFInfo[31][ffInfo];
Автор? Осетин
Последнее редактирование:
