Код: Выделить всё
enum squestinfo
{
sqValid,
sqStartUserID,
sqQuestID,
sqNpcID,
sqNpcName[MAX_PLAYER_NAME],
sqNpcSkinID,
Float:sqNpcX,
Float:sqNpcY,
Float:sqNpcZ,
Float:sqNpcRot,
sqPrice,
sqStartItem,// 0/1
sqStartItemID,
sqSteeps,
sqName[64],
sqText[2048],
sqAnimUse,
sqAnimLib[32],
sqAnimName[32],
sqRewardItem,
sqRewardItemID,
sqUseCheckpoints
}
new StartQuestInfo[8][squestinfo];
new Text3D:StartQuestLabel[sizeof(StartQuestInfo)];
enum metaquestinfo
{
mqValid,
mqQuestID,
mqSteepID,//0-7
mqNpcID,
mqNpcName[MAX_PLAYER_NAME],
mqNpcSkinID,
Float:mqNpcX,
Float:mqNpcY,
Float:mqNpcZ,
Float:mqNpcRot,
mqTakeItem,// 0/1
mqTakeItemID,
mqGiveItem,// 0/1
mqGiveItemID,
mqEndQuest,// 0/1
mqText[2048],
mqAnimUse,
mqAnimLib[32],
mqAnimName[32]
}
new MetaQuestInfo[sizeof(StartQuestInfo)][8][metaquestinfo];
new Text3D:MetaQuestLabel[sizeof(StartQuestInfo)][8];
new Quest[MAX_PLAYERS]=-1;//0-9
new Steep[MAX_PLAYERS]=-1;//0-7
stock QuestNPCConnect(p)
{
new playername[32];
GetPlayerName(p,playername,32);
for(new n = 0; n < sizeof(StartQuestInfo); n++)
{
if(StartQuestInfo[n][sqValid])
{
if(!strcmp(StartQuestInfo[n][sqNpcName],playername,true))
{
StartQuestInfo[n][sqNpcID]=p;
return 1;
}
for(new i = 0; i < StartQuestInfo[n][sqSteeps]; i++)
{
if(MetaQuestInfo[n][i][mqValid])
{
if(!strcmp(MetaQuestInfo[n][i][mqNpcName],playername,true))
{
MetaQuestInfo[n][i][mqNpcID]=p;
return 1;
}
}
}
}
}
return 1;
}
stock QuestNPCSetSpawn(p)
{
for(new n = 0; n < sizeof(StartQuestInfo); n++)
{
if(StartQuestInfo[n][sqValid])
{
if(p==StartQuestInfo[n][sqNpcID])
{
SetSpawnInfo(StartQuestInfo[n][sqNpcID], 0, StartQuestInfo[n][sqNpcSkinID],StartQuestInfo[n][sqNpcX], StartQuestInfo[n][sqNpcY], StartQuestInfo[n][sqNpcZ], StartQuestInfo[n][sqNpcRot], 0, 0, 0, 0, 0, 0 );
return 1;
}
for(new i = 0; i < StartQuestInfo[n][sqSteeps]; i++)
{
if(MetaQuestInfo[n][i][mqValid])
{
if(p==MetaQuestInfo[n][i][mqNpcID])
{
SetSpawnInfo(MetaQuestInfo[n][i][mqNpcID], 0, MetaQuestInfo[n][i][mqNpcSkinID], MetaQuestInfo[n][i][mqNpcX], MetaQuestInfo[n][i][mqNpcY], MetaQuestInfo[n][i][mqNpcZ], MetaQuestInfo[n][i][mqNpcRot], 0, 0, 0, 0, 0, 0 );
return 1;
}
}
}
}
}
return 1;
}
stock LoadRandomQuests()
{
new str[255];
samp_mysql_query("SELECT id FROM quest");
samp_mysql_store_result();
new quests=samp_mysql_num_rows();
if(quests==0)
{
print("Error, not quest");
return 1;
}
else if(quests<=sizeof(StartQuestInfo))
{
for(new i = 0; i < quests; i++)
{
if(!LoadQuest(i,i))continue;
//загрузка данных из бд по указанному иду.
StartQuestInfo[i][sqNpcID]=FindValidID();//свободный ид с конца
#if defined CBOTS
CreateNPC(StartQuestInfo[i][sqNpcID],StartQuestInfo[i][sqNpcName]);
SetSpawnInfo(StartQuestInfo[i][sqNpcID], 0, StartQuestInfo[i][sqNpcSkinID],StartQuestInfo[i][sqNpcX], StartQuestInfo[i][sqNpcY], StartQuestInfo[i][sqNpcZ], StartQuestInfo[i][sqNpcRot], 0, 0, 0, 0, 0, 0 );
SpawnNPC(StartQuestInfo[i][sqNpcID]);
SetNPCFacingAngle(StartQuestInfo[i][sqNpcID], StartQuestInfo[i][sqNpcRot]);
SetNPCImpregnable(StartQuestInfo[i][sqNpcID],1);
#else
ConnectNPC(StartQuestInfo[i][sqNpcName],"stand");
#endif
format(str,sizeof(str),"%s[/say для разговора]",StartQuestInfo[i][sqNpcName]);
StartQuestLabel[i] = CreateDynamic3DTextLabel(str,COLOR_WHITE,StartQuestInfo[i][sqNpcX], StartQuestInfo[i][sqNpcY], StartQuestInfo[i][sqNpcZ]+1.0,15.0,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,1);
if(StartQuestInfo[i][sqAnimUse])
{
ApplyAnimation(StartQuestInfo[i][sqNpcID],StartQuestInfo[i][sqAnimLib],StartQuestInfo[i][sqAnimName],4.1,0,0,0,1,0);
}
for(new b = 0; b < StartQuestInfo[i][sqSteeps]; b++)
{
if(!LoadSteep(StartQuestInfo[i][sqQuestID],b)) continue;
MetaQuestInfo[i][b][mqNpcID]=FindValidID();
#if defined CBOTS
CreateNPC(MetaQuestInfo[i][b][mqNpcID],MetaQuestInfo[i][b][mqNpcName]);
SetSpawnInfo(MetaQuestInfo[i][b][mqNpcID], 0, MetaQuestInfo[i][b][mqNpcSkinID], MetaQuestInfo[i][b][mqNpcX], MetaQuestInfo[i][b][mqNpcY], MetaQuestInfo[i][b][mqNpcZ], MetaQuestInfo[i][b][mqNpcRot], 0, 0, 0, 0, 0, 0 );
SpawnNPC(MetaQuestInfo[i][b][mqNpcID]);
SetNPCImpregnable(MetaQuestInfo[i][b][mqNpcID],1);
SetNPCFacingAngle(MetaQuestInfo[i][b][mqNpcID],MetaQuestInfo[i][b][mqNpcRot]);
#else
ConnectNPC(MetaQuestInfo[i][b][mqNpcName],"stand");
#endif
format(str,sizeof(str),"%s[/say для разговора]",MetaQuestInfo[i][b][mqNpcName]);
MetaQuestLabel[i][b] = CreateDynamic3DTextLabel(str,COLOR_WHITE,MetaQuestInfo[i][b][mqNpcX], MetaQuestInfo[i][b][mqNpcY], MetaQuestInfo[i][b][mqNpcZ]+1.0,15.0,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,1);
if(MetaQuestInfo[i][b][mqAnimUse])
{
ApplyAnimation(MetaQuestInfo[i][b][mqNpcID],MetaQuestInfo[i][b][mqAnimLib],MetaQuestInfo[i][b][mqAnimName],4.1,0,0,0,1,0);
}
}
}
}
else
{
for(new i = 0; i < sizeof(StartQuestInfo); i++)
{
new bit1,bit2;
new rand;
while (bit1==1)
{
bit2=0;
rand=random(quests);
for(new n = 0; n < i; n++)
{
if(StartQuestInfo[n][sqQuestID]==rand)bit2=1;
}
if(bit2==0)bit1=1;
}
if(!LoadQuest(rand,i))continue;
//загрузка данных из бд по указанному иду.
StartQuestInfo[i][sqNpcID]=FindValidID();//свободный ид с конца
#if defined CBOTS
CreateNPC(StartQuestInfo[i][sqNpcID],StartQuestInfo[i][sqNpcName]);
SetSpawnInfo(StartQuestInfo[i][sqNpcID], 0, StartQuestInfo[i][sqNpcSkinID],StartQuestInfo[i][sqNpcX], StartQuestInfo[i][sqNpcY], StartQuestInfo[i][sqNpcZ], StartQuestInfo[i][sqNpcRot], 0, 0, 0, 0, 0, 0 );
SpawnNPC(StartQuestInfo[i][sqNpcID]);
SetNPCFacingAngle(StartQuestInfo[i][sqNpcID], StartQuestInfo[i][sqNpcRot]);
SetNPCImpregnable(StartQuestInfo[i][sqNpcID],1);
#else
ConnectNPC(StartQuestInfo[i][sqNpcName],"stand");
#endif
format(str,sizeof(str),"%s[/say для разговора]",StartQuestInfo[i][sqNpcName]);
StartQuestLabel[i] = CreateDynamic3DTextLabel(str,COLOR_WHITE,StartQuestInfo[i][sqNpcX], StartQuestInfo[i][sqNpcY], StartQuestInfo[i][sqNpcZ]+1.0,15.0,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,1);
if(StartQuestInfo[i][sqAnimUse])
{
ApplyAnimation(StartQuestInfo[i][sqNpcID],StartQuestInfo[i][sqAnimLib],StartQuestInfo[i][sqAnimName],4.1,0,0,0,1,0);
}
for(new b = 0; b < StartQuestInfo[i][sqSteeps]; b++)
{
if(!LoadSteep(StartQuestInfo[i][sqQuestID],b)) continue;
MetaQuestInfo[i][b][mqNpcID]=FindValidID();
#if defined CBOTS
CreateNPC(MetaQuestInfo[i][b][mqNpcID],MetaQuestInfo[i][b][mqNpcName]);
SetSpawnInfo(MetaQuestInfo[i][b][mqNpcID], 0, MetaQuestInfo[i][b][mqNpcSkinID], MetaQuestInfo[i][b][mqNpcX], MetaQuestInfo[i][b][mqNpcY], MetaQuestInfo[i][b][mqNpcZ], MetaQuestInfo[i][b][mqNpcRot], 0, 0, 0, 0, 0, 0 );
SpawnNPC(MetaQuestInfo[i][b][mqNpcID]);
SetNPCFacingAngle(MetaQuestInfo[i][b][mqNpcID],MetaQuestInfo[i][b][mqNpcRot]);
SetNPCImpregnable(MetaQuestInfo[i][b][mqNpcID],1);
#else
ConnectNPC(MetaQuestInfo[i][b][mqNpcName],"stand");
#endif
format(str,sizeof(str),"%s[/say для разговора]",MetaQuestInfo[i][b][mqNpcName]);
MetaQuestLabel[i][b] = CreateDynamic3DTextLabel(str,COLOR_WHITE,MetaQuestInfo[i][b][mqNpcX], MetaQuestInfo[i][b][mqNpcY], MetaQuestInfo[i][b][mqNpcZ]+1.0,15.0,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,1);
if(MetaQuestInfo[i][b][mqAnimUse])
{
ApplyAnimation(MetaQuestInfo[i][b][mqNpcID],MetaQuestInfo[i][b][mqAnimLib],MetaQuestInfo[i][b][mqAnimName],4.1,0,0,0,1,0);
}
}
}
}
return 1;
}
stock LoadQuest(qid,idto)
{
new query[255],Field[2048];
format(query, sizeof(query), "SELECT * FROM quest WHERE id = %d LIMIT 1", qid);
samp_mysql_query(query);
samp_mysql_store_result();
if(samp_mysql_num_rows() != 0)
{
samp_mysql_fetch_result();
// samp_mysql_fetch_next(Field);
new rcnt=0;
StartQuestInfo[idto][sqValid]=1;
StartQuestInfo[idto][sqQuestID]=qid;
while (samp_mysql_fetch_next(Field)==1)
{
switch(rcnt)
{
case 1: strmid(StartQuestInfo[idto][sqNpcName], Field, 0, strlen(Field), 255);
case 2: StartQuestInfo[idto][sqNpcSkinID] = strval(Field);
case 3: StartQuestInfo[idto][sqNpcX] = floatstr(Field);
case 4: StartQuestInfo[idto][sqNpcY] = floatstr(Field);
case 5: StartQuestInfo[idto][sqNpcZ] = floatstr(Field);
case 6: StartQuestInfo[idto][sqNpcRot] = floatstr(Field);
case 7: strmid(StartQuestInfo[idto][sqName], Field, 0, strlen(Field), 255);
case 8: strmid(StartQuestInfo[idto][sqText], Field, 0, strlen(Field), 2048);
case 9: StartQuestInfo[idto][sqPrice] = strval(Field);
case 10: StartQuestInfo[idto][sqStartItem] = strval(Field);
case 11: StartQuestInfo[idto][sqStartItemID] = strval(Field);
case 12: StartQuestInfo[idto][sqSteeps] = strval(Field);
case 13: StartQuestInfo[idto][sqAnimUse] = strval(Field);
case 14: strmid(StartQuestInfo[idto][sqAnimLib], Field, 0, strlen(Field), 255);
case 15: strmid(StartQuestInfo[idto][sqAnimName], Field, 0, strlen(Field), 255);
case 16: StartQuestInfo[idto][sqRewardItem] = strval(Field);
case 17: StartQuestInfo[idto][sqRewardItemID] = strval(Field);
case 18: StartQuestInfo[idto][sqUseCheckpoints] = strval(Field);
}
rcnt++;
}
return 1;
}
printf("Error, quest %d - not loaded",qid);
return 0;
}
stock LoadSteep(questid,steep)
{
new query[255],Field[2048];
format(query, sizeof(query), "SELECT * FROM questmeta WHERE QuestID=%d AND SteepID=%d LIMIT 1", questid,steep);
samp_mysql_query(query);
samp_mysql_store_result();
if(samp_mysql_num_rows() != 0)
{
samp_mysql_fetch_result();
// samp_mysql_fetch_next(Field);
new rcnt=0;
MetaQuestInfo[questid][steep][mqValid]=1;
while (samp_mysql_fetch_next(Field)==1)
{
switch(rcnt)
{
case 1: MetaQuestInfo[questid][steep][mqQuestID]= strval(Field);
case 2: MetaQuestInfo[questid][steep][mqSteepID]= strval(Field);
case 3: strmid(MetaQuestInfo[questid][steep][mqNpcName], Field, 0, strlen(Field), 255);
case 4: MetaQuestInfo[questid][steep][mqNpcSkinID] = strval(Field);
case 5: MetaQuestInfo[questid][steep][mqNpcX] = floatstr(Field);
case 6: MetaQuestInfo[questid][steep][mqNpcY] = floatstr(Field);
case 7: MetaQuestInfo[questid][steep][mqNpcZ] = floatstr(Field);
case 8: MetaQuestInfo[questid][steep][mqNpcRot] = floatstr(Field);
case 9: MetaQuestInfo[questid][steep][mqTakeItem]= strval(Field);
case 10: MetaQuestInfo[questid][steep][mqTakeItemID]= strval(Field);
case 11:MetaQuestInfo[questid][steep][mqGiveItem]= strval(Field);
case 12:MetaQuestInfo[questid][steep][mqGiveItemID]= strval(Field);
case 13:MetaQuestInfo[questid][steep][mqEndQuest]= strval(Field);
case 14:strmid(MetaQuestInfo[questid][steep][mqText], Field, 0, strlen(Field), 2048);
case 15: MetaQuestInfo[questid][steep][mqAnimUse] = strval(Field);
case 16: strmid(MetaQuestInfo[questid][steep][mqAnimLib], Field, 0, strlen(Field), 255);
case 17: strmid(MetaQuestInfo[questid][steep][mqAnimName], Field, 0, strlen(Field), 255);
}
rcnt++;
}
return 1;
}
printf("Error, steep %d for quest %d - not loaded",steep,questid);
return 0;
}
stock SayToQuestPlayer(playerid)
{
for(new i = 0; i < sizeof(StartQuestInfo); i++)
{
if(IsPlayerInRangeOfPoint(playerid,3.0,StartQuestInfo[i][sqNpcX], StartQuestInfo[i][sqNpcY], StartQuestInfo[i][sqNpcZ]))
{
if(Quest[playerid]==-1)//начать квест
{
new query[255];
format(query,sizeof(query),"SELECT id FROM questcomplete WHERE Name='%s' AND QuestID=%d",oGetPlayerName(playerid),StartQuestInfo[i][sqQuestID]);
samp_mysql_query(query);
samp_mysql_store_result();
new str[255];
format(str,sizeof(str),"Квест: %s",StartQuestInfo[i][sqName]);
if(samp_mysql_num_rows() != 0)
{
return ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,str,"Прости, у меня для тебя ничего нет","Ок","Ок");
}
if(IsACop(playerid))return ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,str,"Прости, у меня для тебя ничего нет","Ок","Ок");
Quest[playerid]=i;
ShowPlayerDialog(playerid,199,DIALOG_STYLE_MSGBOX,str,StartQuestInfo[i][sqText],"Взять","Не взять");
return 1;
}
else
{
new str[255];
format(str,sizeof(str),"Квест: %s",StartQuestInfo[i][sqName]);
return ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,str,"Прости, у меня для тебя ничего нет","Ок","Ок");
}
}
for(new b = 0; b < StartQuestInfo[i][sqSteeps]; b++)
{
if(IsPlayerInRangeOfPoint(playerid,3.0,MetaQuestInfo[i][b][mqNpcX], MetaQuestInfo[i][b][mqNpcY], MetaQuestInfo[i][b][mqNpcZ]))
{
if(Quest[playerid]!=i)
{
new str[255];
format(str,sizeof(str),"Квест: %s",StartQuestInfo[i][sqName]);
return ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,str,"Прости, у меня для тебя ничего нет","Ок","Ок");
}
if(Steep[playerid]==b)
{
if(MetaQuestInfo[i][b][mqTakeItem])
{
if(FindItem(playerid,MetaQuestInfo[i][b][mqTakeItemID])) DeleteOneItem(playerid,MetaQuestInfo[i][b][mqTakeItemID]);
else EndQuest(playerid,0);
}
new str[255];
format(str,sizeof(str),"Квест: %s",StartQuestInfo[i][sqName]);
ShowPlayerDialog(playerid,200,DIALOG_STYLE_MSGBOX,str,MetaQuestInfo[i][b][mqText],"Ок","Ок");
return 1;
}
else
{
new str[255];
format(str,sizeof(str),"Квест: %s",StartQuestInfo[i][sqName]);
return ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,str,"Прости, у меня для тебя ничего нет","Ок","Ок");
}
}
}
}
return 1;
}
stock QuestDialogResponse(playerid, dialogid, response)
{
switch(dialogid)
{
case 199:
{
if(response)
{
if(StartQuestInfo[Quest[playerid]][sqStartItem])
{
if(!SetItem(playerid,StartQuestInfo[Quest[playerid]][sqStartItemID],1))
{
new str[255];
format(str,sizeof(str),"Квест: %s",StartQuestInfo[Quest[playerid]][sqName]);
Quest[playerid]=-1;
Steep[playerid]=-1;
return ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,str,"Вы не сможете унести это, уберите что нибуть из своих вещей и подойдите ко мне снова.","OK","OK");
}
}
Steep[playerid]=0;
new str[255];
format(str,sizeof(str),"Квест: %s",StartQuestInfo[Quest[playerid]][sqName]);
if(StartQuestInfo[Quest[playerid]][sqUseCheckpoints])
{
SetPlayerCheckpoint(playerid,MetaQuestInfo[Quest[playerid]][Steep[playerid]][mqNpcX], MetaQuestInfo[Quest[playerid]][Steep[playerid]][mqNpcY], MetaQuestInfo[Quest[playerid]][Steep[playerid]][mqNpcZ],4.0);
return ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,str,"На вашем радаре отображен чекпоинт с указанным NPC.","OK","OK");
}
return 1;
}
else
{
Quest[playerid]=-1;
}
}
case 200:
{
if(MetaQuestInfo[Quest[playerid]][Steep[playerid]][mqGiveItem])
{
if(!SetItem(playerid,MetaQuestInfo[Quest[playerid]][Steep[playerid]][mqGiveItemID],1))
{
new str[255];
format(str,sizeof(str),"Квест: %s",StartQuestInfo[Quest[playerid]][sqName]);
return ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,str,"Вы не сможете унести это, уберите что нибуть из своих вещей и подойдите ко мне снова.","OK","OK");
}
}
if(MetaQuestInfo[Quest[playerid]][Steep[playerid]][mqEndQuest]) return EndQuest(playerid, 1);
new str[255];
format(str,sizeof(str),"Квест: %s",StartQuestInfo[Quest[playerid]][sqName]);
Steep[playerid]++;
if(StartQuestInfo[Quest[playerid]][sqUseCheckpoints])
{
SetPlayerCheckpoint(playerid,MetaQuestInfo[Quest[playerid]][Steep[playerid]][mqNpcX], MetaQuestInfo[Quest[playerid]][Steep[playerid]][mqNpcY], MetaQuestInfo[Quest[playerid]][Steep[playerid]][mqNpcZ],4.0);
return ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,str,"На вашем радаре отображен чекпоинт с указанным NPC.","OK","OK");
}
return 1;
}
}
return 1;
}
stock EndQuest(playerid, type)
{
switch(type)
{
case 0://провал
{
new str[255];
DisablePlayerCheckpoint(playerid);
ClearQuestItems(playerid);
format(str,sizeof(str),"Квест: %s",StartQuestInfo[Quest[playerid]][sqName]);
Quest[playerid]=-1;//0-9
Steep[playerid]=-1;//0-7
return ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,str,"Вы провалили квест","Ок","Ок");
}
case 1://выигрыш
{
new str[255];
format(str,sizeof(str),"Квест: %s",StartQuestInfo[Quest[playerid]][sqName]);
if(StartQuestInfo[Quest[playerid]][sqRewardItem])
{
if(!SetItem(playerid,StartQuestInfo[Quest[playerid]][sqRewardItemID],1))
{
return ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,str,"Вы не сможете унести это, уберите что нибуть из своих вещей и подойдите ко мне снова.","OK","OK");
}
}
new str1[255];
format(str1,sizeof(str1),"Вы прошли квест, награда %d",StartQuestInfo[Quest[playerid]][sqPrice]);
new reason[255];
format(reason,sizeof(reason),"Прошел квест %s",StartQuestInfo[Quest[playerid]][sqName]);
DisablePlayerCheckpoint(playerid);
TransferMoney(0,0,playerid,1,StartQuestInfo[Quest[playerid]][sqPrice],reason);
new query[255];
format(query,sizeof(query),"INSERT INTO questcomplete SET Name='%s', QuestID=%d",oGetPlayerName(playerid),StartQuestInfo[Quest[playerid]][sqQuestID]);
samp_mysql_query(query);
Quest[playerid]=-1;//0-9
Steep[playerid]=-1;//0-7
ClearQuestItems(playerid);
return ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,str,str1,"Ок","Ок");
}
}
return 1;
}
stock QuestPlayerConnect(playerid)
{
Quest[playerid]=-1;//0-9
Steep[playerid]=-1;//0-7
return 1;
}
stock QuestPlayerDisconnect(playerid)
{
Quest[playerid]=-1;//0-9
Steep[playerid]=-1;//0-7
return 1;
}
enum equestinfo
{
eqType,
eqStage,
eqQuest,
eqText[2048]
};
new EditQuestInfo[MAX_PLAYERS][equestinfo];
stock StartEditTextForQuest(playerid)
{
for(new n = 0; n < sizeof(StartQuestInfo); n++)
{
if(IsPlayerInRangeOfPoint(playerid,3.0,StartQuestInfo[n][sqNpcX], StartQuestInfo[n][sqNpcY], StartQuestInfo[n][sqNpcZ]))
{
new str[255];
format(str,sizeof(str),"Изменение квеста %d, вы сейчас на старте, введите название:",n);
format(EditQuestInfo[playerid][eqText],2048," ");
EditQuestInfo[playerid][eqType]=-1;
EditQuestInfo[playerid][eqQuest]=n;
ShowPlayerDialog(playerid,221,DIALOG_STYLE_INPUT,str,EditQuestInfo[playerid][eqText],"Добавить строку","Конец");
return 1;
}
for(new i = 0; i < StartQuestInfo[n][sqSteeps]; i++)
{
if(IsPlayerInRangeOfPoint(playerid,3.0,MetaQuestInfo[n][i][mqNpcX], MetaQuestInfo[n][i][mqNpcY], MetaQuestInfo[n][i][mqNpcZ]))
{
EditQuestInfo[playerid][eqType]=1;
EditQuestInfo[playerid][eqQuest]=n;
EditQuestInfo[playerid][eqStage]=i;
new str[255];
format(str,sizeof(str),"Изменение квеста %d, этап %d",n,i);
format(EditQuestInfo[playerid][eqText],2048," ");
ShowPlayerDialog(playerid,221,DIALOG_STYLE_INPUT,str,EditQuestInfo[playerid][eqText],"Добавить строку","Конец");
return 1;
}
}
}
return 0;
}
stock EditQuestDialogResponse(playerid, dialogid, response, inputtext[])
{
switch(dialogid)
{
case 221:
{
if(response)
{
new str[255];
switch(EditQuestInfo[playerid][eqType])
{
case -1:
{
new query[255];
format(query,sizeof(query),"UPDATE quest SET Name=' %s' WHERE id=%d",inputtext,StartQuestInfo[EditQuestInfo[playerid][eqQuest]][sqQuestID]);
samp_mysql_query(query);
format(StartQuestInfo[EditQuestInfo[playerid][eqQuest]][sqName],64,"%s",inputtext);
format(str,sizeof(str),"Изменение квеста %d, текст квеста:",EditQuestInfo[playerid][eqQuest]);
format(EditQuestInfo[playerid][eqText],2048," ");
EditQuestInfo[playerid][eqType]=0;
ShowPlayerDialog(playerid,221,DIALOG_STYLE_INPUT,str,EditQuestInfo[playerid][eqText],"Добавить строку","Конец");
return 1;
}
case 0:format(str,sizeof(str),"Изменение квеста %d",EditQuestInfo[playerid][eqQuest]);
case 1:format(str,sizeof(str),"Изменение квеста %d, этап %d",EditQuestInfo[playerid][eqQuest],EditQuestInfo[playerid][eqStage]);
}
format(EditQuestInfo[playerid][eqText],2048," %s\n%s",EditQuestInfo[playerid][eqText],inputtext);
ShowPlayerDialog(playerid,221,DIALOG_STYLE_INPUT,str,EditQuestInfo[playerid][eqText],"Добавить строку","Конец");
}
else
{
new str[255];
new query[2048];
switch(EditQuestInfo[playerid][eqType])
{
case 0:
{
format(query,sizeof(query),"UPDATE quest SET QuestText='%s' WHERE id=%d",EditQuestInfo[playerid][eqText],StartQuestInfo[EditQuestInfo[playerid][eqQuest]][sqQuestID]);
samp_mysql_query(query);
format(StartQuestInfo[EditQuestInfo[playerid][eqQuest]][sqText],2048,"%s",EditQuestInfo[playerid][eqText]);
format(str,sizeof(str),"Изменение квеста %d",EditQuestInfo[playerid][eqQuest]);
}
case 1:
{
format(query,sizeof(query),"UPDATE questmeta SET QuestText='%s' WHERE QuestID=%d AND SteepID=%d",EditQuestInfo[playerid][eqText],MetaQuestInfo[EditQuestInfo[playerid][eqQuest]][EditQuestInfo[playerid][eqStage]][mqQuestID],MetaQuestInfo[EditQuestInfo[playerid][eqQuest]][EditQuestInfo[playerid][eqStage]][mqSteepID]);
samp_mysql_query(query);
format(MetaQuestInfo[EditQuestInfo[playerid][eqQuest]][EditQuestInfo[playerid][eqStage]][mqText],2048,"%s",EditQuestInfo[playerid][eqText]);
format(str,sizeof(str),"Изменение квеста %d, этап %d",EditQuestInfo[playerid][eqQuest],EditQuestInfo[playerid][eqStage]);
}
}
ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,str,"Сохранено","Ок","Ок");
return 1;
}
}
}
return 1;
}
stock UnloadQuests()
{
foreach(Player,i)
{
if(Quest[i]>=0)
{
new str[255];
DisablePlayerCheckpoint(i);
ClearQuestItems(i);
format(str,sizeof(str),"Квест: %s",StartQuestInfo[Quest[i]][sqName]);
Quest[i]=-1;//0-9
Steep[i]=-1;//0-7
return ShowPlayerDialog(i,0,DIALOG_STYLE_MSGBOX,str,"Квесты были выгружены, и ваше участие отменено","Ок","Ок");
}
}
for(new i = 0; i < sizeof(StartQuestInfo); i++)
{
if(StartQuestInfo[i][sqValid])
{
#if defined CBOTS
DestroyNPC(StartQuestInfo[i][sqNpcID]);
#else
Kick(StartQuestInfo[i][sqNpcID]);
#endif
DestroyDynamic3DTextLabel(StartQuestLabel[i]);
StartQuestInfo[i][sqValid]=0;
for(new b = 0; b < StartQuestInfo[i][sqSteeps]; b++)
{
if(MetaQuestInfo[i][b][mqValid])
{
#if defined CBOTS
DestroyNPC(MetaQuestInfo[i][b][mqNpcID]);
#else
Kick(MetaQuestInfo[i][b][mqNpcID]);
#endif
DestroyDynamic3DTextLabel(MetaQuestLabel[i][b]);
MetaQuestInfo[i][b][mqValid]=0;
}
}
}
}
return 1;
}