PDA

Просмотр полной версии : [Вопрос] Значение переменных в диалоге



Albert
08.01.2015, 15:28
Здравствуйте. Создал систему владения оружием. Хочу чтобы в этом диалоге рядом с названием оружия показывалось колличество патронов в инвентаре (В разгрузке).
https://pp.vk.me/c622230/v622230233/13d7b/mteF8Kcg9Yc.jpg
Вот диалог:


ShowPlayerDialog(playerid,15,DIALOG_STYLE_LIST,"Магазины/Обоймы","Дигл\nКольт\nДробовик\nspas12\nГадюка\nАК\nМ4\nРужьё\nСВД\nРПГ","Зарядить","Отмена");

Переменная отвечающая за хранение патронов дигла: pRdeagle
pInfo[playerid][pPdeagle]


Как мне сделать? Покажите пожалуйста пример с диглом. Я, по образцу, сделаю на остальное оружие

#ball
08.01.2015, 16:08
Попробуй.


format(string, sizeof(string),"Дигл[%d патрон(ов)]\nКольт[%d патрон(ов)]\nДробовик[%d патрон(ов)]\nspas12[%d патрон(ов)]\nГадюка[%d патрон(ов)]\nАК[%d]\nМ4[%d патрон(ов)]\nРужьё[%d патрон(ов)]\nСВД[%d патрон(ов)]\nРПГ[%d патрон(ов)]",pInfo[playerid][pPdeagle], //продолжайте перечислять);
ShowPlayerDialog(playerid,15,DIALOG_STYLE_LIST,"Магазины/Обоймы",string,"Зарядить","Отмена");

Albert
11.01.2015, 19:50
if(newkeys & KEY_YES)// Кнопка Y
{
format(string, sizeof(string),"Дигл[%d патрон(ов)]\nКольт[%d патрон(ов)]\nДробовик[%d патрон(ов)]\nspas12[%d патрон(ов)]\nГадюка[%d патрон(ов)]\nАК[%d]\nМ4[%d патрон(ов)]\nРужьё[%d патрон(ов)]\nСВД[%d патрон(ов)]\nРПГ[%d патрон(ов)]",
pInfo[playerid][pRdeagle],pInfo[playerid][pRcolt],pInfo[playerid][pRshot],
pInfo[playerid][pRspas],pInfo[playerid][pRmp5],pInfo[playerid][pRak],pInfo[playerid][pRm4],pInfo[playerid][pRrifle],
pInfo[playerid][pRsniper],
pInfo[playerid][pRrpg]);
ShowPlayerDialog(playerid,15,DIALOG_STYLE_LIST,"Магазины/Обоймы",string,"Зарядить","Отмена");


}




E:\Program Files\Virtual Reality\SA-MP 0.3z Windows Server\pawno\include\sscanf.inc(3) : warning 219: local variable "string" shadows a variable at a preceding level
E:\Program Files\Virtual Reality\SA-MP 0.3z Windows Server\gamemodes\S.T.A.L.K.E.R..pwn(2841) : warning 219: local variable "string" shadows a variable at a preceding level

L0ndl3m
11.01.2015, 20:11
Перед этим кодом:

new string[128];

Albert
11.01.2015, 20:20
E:\Program Files\Virtual Reality\SA-MP 0.3z Windows Server\pawno\include\sscanf.inc(3) : warning 219: local variable "string" shadows a variable at a preceding level
E:\Program Files\Virtual Reality\SA-MP 0.3z Windows Server\gamemodes\S.T.A.L.K.E.R..pwn(2843) : warning 219: local variable "string" shadows a variable at a preceding level

Удалил лишний паблик. Теперь
E:\Program Files\Virtual Reality\SA-MP 0.3z Windows Server\pawno\include\sscanf.inc(3) : warning 219: local variable "string" shadows a variable at a preceding level

L0ndl3m
11.01.2015, 20:40
new
weap_string[128];

format(weap_string, sizeof(weap_string),"Дигл[%d патрон(ов)]\nКольт[%d патрон(ов)]\nДробовик[%d патрон(ов)]\nspas12[%d патрон(ов)]\nГадюка[%d патрон(ов)]\nАК[%d]\nМ4[%d патрон(ов)]\nРужьё[%d патрон(ов)]\nСВД[%d патрон(ов)]\nРПГ[%d патрон(ов)]", pInfo[playerid][pPdeagle], ...);
Ниже в ShowPlayerDialog найдите аргумент с названием string и замените на weap_string.

Albert
11.01.2015, 20:54
У меня, из далогов, только в регистрации string.

Вот диалог отвечающий за работу диалога над котором мы работаем:




if(dialogid == 15)// Разгрузка
{
if(response)
{
if(listitem == 0) // Дигл
{
if(pInfo[playerid][pRdeagle] >= 7)
{

SetPlayerReload(playerid);
ResetPlayerWeapons(playerid);



GivePlayerWeapon(playerid,24,7); // дигл
pInfo[playerid][pRdeagle] -= 7;
ApplyAnimation(playerid, "COLT45", "COLT45_RELOAD", 4.1, 0, 1, 1, 0, 3000, 1);

}
else
{
SendClientMessage(playerid,0x88AA88AA,"Патроны закончились");
}

}


if(listitem == 1) // Кольт
{

if(pInfo[playerid][pRcolt] >= 17)
{
SetPlayerReload(playerid);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid,22,17);
pInfo[playerid][pRcolt] -= 17;
ApplyAnimation(playerid, "COLT45", "COLT45_RELOAD", 4.1, 0, 1, 1, 0, 3000, 1);


}
else
{
SendClientMessage(playerid,0x88AA88AA,"Патроны закончились");
}

}
if(listitem == 2) // Дробовик
{
if(pInfo[playerid][pRshot] >= 7)
{
SetPlayerReload(playerid);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid,25,7);
pInfo[playerid][pRshot] -= 7;
ApplyAnimation(playerid, "COLT45", "SAWNOFF_RELOAD", 4.1, 0, 1, 1, 0, 5000, 1);


}
else
{
SendClientMessage(playerid,0x88AA88AA,"Патроны закончились");
}

}
if(listitem == 3) // спас 12
{
if(pInfo[playerid][pRspas] >= 7)
{
SetPlayerReload(playerid);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid,27,7);
pInfo[playerid][pRspas] -= 7;
ApplyAnimation(playerid, "COLT45", "SAWNOFF_RELOAD", 4.1, 0, 1, 1, 0, 5000, 1);


}
else
{
SendClientMessage(playerid,0x88AA88AA,"Патроны закончились");
}

}
if(listitem == 4) // МП5
{
if(pInfo[playerid][pRmp5] >= 30)
{
SetPlayerReload(playerid);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid,29,30);
pInfo[playerid][pRmp5] -= 30;
ApplyAnimation(playerid, "UZI", "UZI_RELOAD", 4.1, 0, 1, 1, 0, 2000, 1);


}
else
{
SendClientMessage(playerid,0x88AA88AA,"Патроны закончились");
}

}
if(listitem == 5) // АК
{
if(pInfo[playerid][pRak] >= 30)
{
SetPlayerReload(playerid);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid,30,30);
pInfo[playerid][pRak] -= 30;
ApplyAnimation(playerid, "UZI", "UZI_RELOAD", 4.1, 0, 1, 1, 0, 5000, 1);


}
else
{
SendClientMessage(playerid,0x88AA88AA,"Патроны закончились");
}

}

if(listitem == 6) // M4
{
if(pInfo[playerid][pRm4] >= 50)
{
SetPlayerReload(playerid);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid,31,50);
pInfo[playerid][pRm4] -= 50;
ApplyAnimation(playerid, "UZI", "UZI_RELOAD", 4.1, 0, 1, 1, 0, 5000, 1);


}
else
{
SendClientMessage(playerid,0x88AA88AA,"Патроны закончились");
}

}
if(listitem == 7) // Ружьё
{
if(pInfo[playerid][pRrifle] >= 10)
{
SetPlayerReload(playerid);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid,33,10);
pInfo[playerid][pRrifle] -= 10;
ApplyAnimation(playerid, "UZI", "UZI_RELOAD", 4.1, 0, 1, 1, 0, 7000, 1);


}
else
{
SendClientMessage(playerid,0x88AA88AA,"Патроны закончились");
}

}
if(listitem == 8) // СВД
{
if(pInfo[playerid][pRsniper] >= 10)
{
SetPlayerReload(playerid);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid,34,10);
pInfo[playerid][pRsniper] -= 10;
ApplyAnimation(playerid, "UZI", "UZI_RELOAD", 4.1, 0, 1, 1, 0, 7000, 1);


}
else
{
SendClientMessage(playerid,0x88AA88AA,"Патроны закончились");
}

}
if(listitem == 9) // РПГ
{
if(pInfo[playerid][pRrpg] >= 1)
{
SetPlayerReload(playerid);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid,35,1);
pInfo[playerid][pRrpg] -= 1;
ApplyAnimation(playerid, "UZI", "UZI_RELOAD", 4.1, 0, 1, 1, 0, 15000, 1);


}
else
{
SendClientMessage(playerid,0x88AA88AA,"Патроны закончились");
}

}
else
{

return 1;
}

}

}

L0ndl3m
11.01.2015, 21:00
Зачем нам это нужно? Ошибки исправили свои?