Balkan SA:MP

PAWN skriptanje, gamemodovi, filterskripte, include fajlovi, mape, pluginovi => Razgovor u vezi PAWN - skriptanja => Temu započeo: El Toni poslato Jul 05, 2011, 11:19:48 PRE PODNE

Naslov: [pomoc] dialog
Poruka od: El Toni poslato Jul 05, 2011, 11:19:48 PRE PODNE
Skripta koju koristim: GF
Detaljan opis problema: evo ova komanda da napravim u dialogu koij se djelovi trebaju promenit i sta se drugo treba dodavati....moze mi neko fino kazati?
Dio skripte: if(strcmp(cmd, "/drink", true) == 0)
{
   if(IsPlayerConnected(playerid))
   {
if(IsPlayerInRangeOfPoint(playerid, 5, 1211.5846,-905.1202,42.9272)) // Ovde stavite kordinate gde hocete da vam se nalazi /drink...
{
  if(PlayerDrunk[playerid] < 10)
      {
               new Float:health;
               new x_nr[128];
x_nr = strtok(cmdtext, idx);
if(!strlen(x_nr)) {
SendClientMessage(playerid, COLOR_GREEN, "_______Ladni Pijaloci_______");
SendClientMessage(playerid, COLOR_WHITE, "Komanda: /drink [ime na pijalok]");
  SendClientMessage(playerid, COLOR_GREY, "Momentalno imame: Pivo ($6), Vodka ($10), Viski ($10), Voda ($0), Pepsi ($2)");
SendClientMessage(playerid, COLOR_GREEN, "________________________");
return 1;
}
   if(strcmp(x_nr,"pivo",true) == 0)
{
if(PlayerInfo[playerid][pAge] < 1)
{
   SendClientMessage(playerid, COLOR_WHITE, "Kelner: Izvinite,morate da imate najamlku 16 godini za da piete pivo.");
   return 1;
}
   GivePlayerMoney(playerid, - 6);
   PlayerDrunk[playerid] += 1;
if(PlayerDrunk[playerid] >= 5) { GameTextForPlayer(playerid, "~w~Vie ste~n~~p~pijan", 3500, 1); }
if(GetPlayerHealth(playerid, health) < 100)
{
   if(PlayerInfo[playerid][pAlcoholPerk] > 0) { PlayerDrunk[playerid] += 1; new hp = 2 * PlayerInfo[playerid][pAlcoholPerk]; hp += 15; SetPlayerHealth(playerid, health + hp); }
else { SetPlayerHealth(playerid, health + 15.0); }
}
}
else if(strcmp(x_nr,"vodka",true) == 0)
{
   if(PlayerInfo[playerid][pAge] < 18)
{
   SendClientMessage(playerid, COLOR_WHITE, "Kelner: Izvinite,morate da imate najamlku 16 godini za da piete Vodka.");
   return 1;
}
   GivePlayerMoney(playerid, - 10);
   PlayerDrunk[playerid] += 2;
if(PlayerDrunk[playerid] >= 5) { GameTextForPlayer(playerid, "~w~Vie ste~n~~p~pijan", 3500, 1); }
if(GetPlayerHealth(playerid, health) < 100)
{
   if(PlayerInfo[playerid][pAlcoholPerk] > 0) { PlayerDrunk[playerid] += 1; new hp = 2 * PlayerInfo[playerid][pAlcoholPerk]; hp += 25; SetPlayerHealth(playerid, health + hp); }
else { SetPlayerHealth(playerid, health + 25.0); }
}
}
else if(strcmp(x_nr,"viski",true) == 0)
{
   if(PlayerInfo[playerid][pAge] < 18)
{
   SendClientMessage(playerid, COLOR_WHITE, "Kelner: Izvinite,morate da imate najamlku 16 godini za da piete Viski.");
   return 1;
}
   GivePlayerMoney(playerid, - 10);
   PlayerDrunk[playerid] += 3;
if(PlayerDrunk[playerid] >= 5) { GameTextForPlayer(playerid, "~w~Vie ste~n~~p~pijan", 3500, 1); }
if(GetPlayerHealth(playerid, health) < 100)
{
   if(PlayerInfo[playerid][pAlcoholPerk] > 0) { PlayerDrunk[playerid] += 1; new hp = 2 * PlayerInfo[playerid][pAlcoholPerk]; hp += 27; SetPlayerHealth(playerid, health + hp); }
else { SetPlayerHealth(playerid, health + 27.0); }
}
}
else if(strcmp(x_nr,"voda",true) == 0)
{
   GivePlayerMoney(playerid, 0);
   if(GetPlayerHealth(playerid, health) < 100)
{
   if(PlayerInfo[playerid][pAlcoholPerk] > 0) { new hp = 2 * PlayerInfo[playerid][pAlcoholPerk]; hp += 5; SetPlayerHealth(playerid, health + hp); }
else { SetPlayerHealth(playerid, health + 5.0); }
}
}
else if(strcmp(x_nr,"pepsi",true) == 0)
{
   GivePlayerMoney(playerid, - 2);
   if(GetPlayerHealth(playerid, health) < 100)
{
   if(PlayerInfo[playerid][pAlcoholPerk] > 0) { new hp = 2 * PlayerInfo[playerid][pAlcoholPerk]; hp += 5; SetPlayerHealth(playerid, health + hp); }
else { SetPlayerHealth(playerid, health + 5.0); }
}
}
else
{
   SendClientMessage(playerid, COLOR_WHITE, "Kelner: Momentalno nemame takov pijalok.");
   return 1;
}
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s pije %s.", sendername ,x_nr);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
           }
           else
           {
               SendClientMessage(playerid, COLOR_GREY, "   Nemozete poveke da piete,kje povratite !");
               return 1;
           }
       }
       else
       {
           SendClientMessage(playerid, COLOR_GREY, "   Ne ste na sankot !");
           return 1;
       }
   }
   return 1;
}

Neke slike/video za lakse dobivanje pomoci(neobavezno):
Naslov: Odg: [pomoc] dialog
Poruka od: System32 poslato Jul 05, 2011, 11:20:40 PRE PODNE
Samo koristis ShowPlayerDialog i onda ides dalje u OnDialogResponse, ima tutova o tome
Naslov: Odg: [pomoc] dialog
Poruka od: El Toni poslato Jul 05, 2011, 11:27:02 PRE PODNE
Citat: System32 poslato Jul 05, 2011, 11:20:40 PRE PODNE
Samo koristis ShowPlayerDialog i onda ides dalje u OnDialogResponse, ima tutova o tome
ok pokusacu to da napravim pa ko nesta nie uredu stavicu

moze ova tema lock!
Naslov: Odg: [pomoc] dialog
Poruka od: System32 poslato Jul 05, 2011, 11:28:10 PRE PODNE
ne nemoj locakt, ako zapnes onda ovdje postaj pa cemo ti pomoci
Naslov: Odg: [pomoc] dialog
Poruka od: El Toni poslato Jul 05, 2011, 12:42:19 POSLE PODNE
Citat: Gigov.so poslato Jul 05, 2011, 11:19:48 PRE PODNE
if(strcmp(cmd, "/drink", true) == 0)
{
        ShowPlayerDialog(playerid, TESTDIALOG, DIALOG_STYLE_LIST, "Ladni pijaloci"," Pivo\nVodka\nViski\nVoda\nPepsi ", "Izberi", "Izlez");
return 1;
}
   if(IsPlayerConnected(playerid))
   {
if(IsPlayerInRangeOfPoint(playerid, 5, 1211.5846,-905.1202,42.9272)) // Ovde stavite kordinate gde hocete da vam se nalazi /drink...
{
  if(PlayerDrunk[playerid] < 10)
      {
               new Float:health;
               new x_nr[128];
x_nr = strtok(cmdtext, idx);
if(!strlen(x_nr)) {
SendClientMessage(playerid, COLOR_GREEN, "_______Ladni Pijaloci_______");
SendClientMessage(playerid, COLOR_WHITE, "Komanda: /drink [ime na pijalok]");
  SendClientMessage(playerid, COLOR_GREY, "Momentalno imame: Pivo ($6), Vodka ($10), Viski ($10), Voda ($0), Pepsi ($2)");
SendClientMessage(playerid, COLOR_GREEN, "________________________");
return 1;
}
   if(strcmp(x_nr,"pivo",true) == 0)
{
if(PlayerInfo[playerid][pAge] < 1)
{
   SendClientMessage(playerid, COLOR_WHITE, "Kelner: Izvinite,morate da imate najamlku 16 godini za da piete pivo.");
   return 1;
}
   GivePlayerMoney(playerid, - 6);
   PlayerDrunk[playerid] += 1;
if(PlayerDrunk[playerid] >= 5) { GameTextForPlayer(playerid, "~w~Vie ste~n~~p~pijan", 3500, 1); }
if(GetPlayerHealth(playerid, health) < 100)
{
   if(PlayerInfo[playerid][pAlcoholPerk] > 0) { PlayerDrunk[playerid] += 1; new hp = 2 * PlayerInfo[playerid][pAlcoholPerk]; hp += 15; SetPlayerHealth(playerid, health + hp); }
else { SetPlayerHealth(playerid, health + 15.0); }
}
}
else if(strcmp(x_nr,"vodka",true) == 0)
{
   if(PlayerInfo[playerid][pAge] < 18)
{
   SendClientMessage(playerid, COLOR_WHITE, "Kelner: Izvinite,morate da imate najamlku 16 godini za da piete Vodka.");
   return 1;
}
   GivePlayerMoney(playerid, - 10);
   PlayerDrunk[playerid] += 2;
if(PlayerDrunk[playerid] >= 5) { GameTextForPlayer(playerid, "~w~Vie ste~n~~p~pijan", 3500, 1); }
if(GetPlayerHealth(playerid, health) < 100)
{
   if(PlayerInfo[playerid][pAlcoholPerk] > 0) { PlayerDrunk[playerid] += 1; new hp = 2 * PlayerInfo[playerid][pAlcoholPerk]; hp += 25; SetPlayerHealth(playerid, health + hp); }
else { SetPlayerHealth(playerid, health + 25.0); }
}
}
else if(strcmp(x_nr,"viski",true) == 0)
{
   if(PlayerInfo[playerid][pAge] < 18)
{
   SendClientMessage(playerid, COLOR_WHITE, "Kelner: Izvinite,morate da imate najamlku 16 godini za da piete Viski.");
   return 1;
}
   GivePlayerMoney(playerid, - 10);
   PlayerDrunk[playerid] += 3;
if(PlayerDrunk[playerid] >= 5) { GameTextForPlayer(playerid, "~w~Vie ste~n~~p~pijan", 3500, 1); }
if(GetPlayerHealth(playerid, health) < 100)
{
   if(PlayerInfo[playerid][pAlcoholPerk] > 0) { PlayerDrunk[playerid] += 1; new hp = 2 * PlayerInfo[playerid][pAlcoholPerk]; hp += 27; SetPlayerHealth(playerid, health + hp); }
else { SetPlayerHealth(playerid, health + 27.0); }
}
}
else if(strcmp(x_nr,"voda",true) == 0)
{
   GivePlayerMoney(playerid, 0);
   if(GetPlayerHealth(playerid, health) < 100)
{
   if(PlayerInfo[playerid][pAlcoholPerk] > 0) { new hp = 2 * PlayerInfo[playerid][pAlcoholPerk]; hp += 5; SetPlayerHealth(playerid, health + hp); }
else { SetPlayerHealth(playerid, health + 5.0); }
}
}
else if(strcmp(x_nr,"pepsi",true) == 0)
{
   GivePlayerMoney(playerid, - 2);
   if(GetPlayerHealth(playerid, health) < 100)
{
   if(PlayerInfo[playerid][pAlcoholPerk] > 0) { new hp = 2 * PlayerInfo[playerid][pAlcoholPerk]; hp += 5; SetPlayerHealth(playerid, health + hp); }
else { SetPlayerHealth(playerid, health + 5.0); }
}
}
else
{
   SendClientMessage(playerid, COLOR_WHITE, "Kelner: Momentalno nemame takov pijalok.");
   return 1;
}
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s pije %s.", sendername ,x_nr);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
           }
           else
           {
               SendClientMessage(playerid, COLOR_GREY, "   Nemozete poveke da piete,kje povratite !");
               return 1;
           }
       }
       else
       {
           SendClientMessage(playerid, COLOR_GREY, "   Ne ste na sankot !");
           return 1;
       }
   }
   return 1;
}

Neke slike/video za lakse dobivanje pomoci(neobavezno):

jel to tako treba stajati gore showplayerdialog???
i ovo jel treba da trgnim
if(!strlen(x_nr)) {
SendClientMessage(playerid, COLOR_GREEN, "_______Ladni Pijaloci_______");
SendClientMessage(playerid, COLOR_WHITE, "Komanda: /drink [ime na pijalok]");
  SendClientMessage(playerid, COLOR_GREY, "Momentalno imame: Pivo ($6), Vodka ($10), Viski ($10), Voda ($0), Pepsi ($2)");
SendClientMessage(playerid, COLOR_GREEN, "________________________");
return 1;
}
Naslov: Odg: [pomoc] dialog
Poruka od: System32 poslato Jul 05, 2011, 13:02:37 POSLE PODNE
ne, posljec ti ja napravit, i ne koristi IsPlayerConnected
Naslov: Odg: [pomoc] dialog
Poruka od: X poslato Jul 05, 2011, 13:06:25 POSLE PODNE
if(strcmp(cmd, "/drink", true) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 5, 1211.5846,-905.1202,42.9272)//ako je igrac na toj koordinati prikazuje mu dialog
{
ShowPlayerDialog(playerid, TESTDIALOG, DIALOG_STYLE_LIST, "Ladni pijaloci","Pivo\nVodka\nViski\nVoda\nPepsi ", "Izberi", "Izlez");
return 1;
}
else //igrac nije na toj koordinati pa mu vraca poruku
{
SendClientMessage(playerid, COLOR_GREY, "   Ne ste na sankot !");
return 1;
}
return 1;
}


Sad kreiras dialog response, tj sta ce se desiti kada u nekom odredjenom dijalogu, u tvom slucaju, odaberes nesto sa liste.
Nadji public OnDialogResponse i ispod njega dodajes:
if(dialogid == TESTDIALOG)
{
if(response)
{
if(listitem == 0)//ako odabere ono sto je prvo na listi odradi sljedeci kod, u ovom slucaju pivo, tu kopiraj ono sto ti se nalazi ispod onog dijela "if(strcmp(x_nr,"pivo",true) == 0)"
{
if(PlayerInfo[playerid][pAge] < 1)
{
SendClientMessage(playerid, COLOR_WHITE, "Kelner: Izvinite,morate da imate najamlku 16 godini za da piete pivo.");
return 1;
}
GivePlayerMoney(playerid, - 6);
PlayerDrunk[playerid] += 1;
if(PlayerDrunk[playerid] >= 5) { GameTextForPlayer(playerid, "~w~Vie ste~n~~p~pijan", 3500, 1); }
if(GetPlayerHealth(playerid, health) < 100)
{
if(PlayerInfo[playerid][pAlcoholPerk] > 0) { PlayerDrunk[playerid] += 1; new hp = 2 * PlayerInfo[playerid][pAlcoholPerk]; hp += 15; SetPlayerHealth(playerid, health + hp); }
else { SetPlayerHealth(playerid, health + 15.0); }
}
}
else if(listitem ==1)//ako odabere drugu opciju odradi sljedeci kod, itd, itd
{
}
.
.
.
}
}


Nadam se da ti je jasnije
Pod dialog response, mozes umjesto if,else if strukture koristiti i switch, ali ce ti i ovako raditi.
Naslov: Odg: [pomoc] dialog
Poruka od: System32 poslato Jul 05, 2011, 13:07:23 POSLE PODNE
eto on ti je dao samo, ne treba ele if u OnDialogResonse samo if(listitem..
Naslov: Odg: [pomoc] dialog
Poruka od: El Toni poslato Jul 05, 2011, 14:42:59 POSLE PODNE
ok sredio sam

moze lock!