SA-MP Forums Archive
Problems with a combination of a loop and a string - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problems with a combination of a loop and a string (/showthread.php?tid=263883)



Problems with a combination of a loop and a string - Sasino97 - 23.06.2011

OMG, I really can't understand this bug!

pawn Код:
public OnPlayerSpawn(playerid)
{
  if(GetPlayerTeam(playerid) == 0) ShowPlayerDialog(playerid, DIALOG_SELECT_PLANE, DIALOG_STYLE_LIST, "Scegli un aeroplano in questa lista", "Boeing 737 800\nLockheed C5 Galaxy\nDeHavilland C7 Caribou\nCessna 172\nDouglas C3\nBombardier Learjet 35\nOracle Stunt Plane\nSirosky S-61\nSirosky HH-60\nBell 206 Jet Ranger\nSA 315B Lama", "Spawn", "");
  else if(GetPlayerTeam(playerid) == 1) PutPlayerInVehicle(playerid, CreateVehicle (485,BAGAGLIX, BAGAGLIY, BAGAGLIZ, 0, 1, 1, 1000000), 0);
  else
  {
    new string[256];
    for(new i=0;i<MAX_PLAYERS;i++)
    {
      if(Lavoro[i] == LAVORO_PILOTA && AereoDiLinea[playerid] == 1)
      {
        new name[128];
        if(Destinazione[i] == 0) format(name,sizeof(name), "%s - San Francisco", PlaneName[i]);
        else format(name,sizeof(name), "%s - Las Vegas", PlaneName[i]);
        format(string,sizeof(string), "%s%s\n", string, name);
      }
    }
    if(!strlen(string)) { ShowPlayerDialog(playerid, DIALOG_DIE, DIALOG_STYLE_LIST, "Nessun volo di linea disponibile", "Scegli un altro personaggio", "OK", ""); }
    Lavoro[playerid] = LAVORO_ALTRO;
    ShowPlayerDialog(playerid, DIALOG_SELECT_FLIGHT, DIALOG_STYLE_LIST, "Scegli un volo di linea", string, "Spawn", "");
  }
  return 1;
}
In every case shows the dialog of "if(!strlen(string))", so the string doesn't have any character, but It should!


Re: Problems with a combination of a loop and a string - Sasino97 - 25.06.2011

Quote:
Originally Posted by Colossus_
Посмотреть сообщение
Your using DIALOG_STYLE_LIST under OnPlayerSpawn this means they respond to the dialog by clicking on a list item when they spawn...Wheres the rest of the code. (Hint: OnDialogResponse)

Regardless that code needs a clean up badly (C# uses 4 spaces not 2 spaces) and how can you be getting the length of a string from the planes in the list all in that code? Im suprised it compiles.

Learn how to switch dialog and list item case's and use them.

www.wiki.sa-mp.com can be very useful..Use it as your scripting ******.
Thanks, I solved it, the code was right but the requires for calling it were false in every case because I didn't put a way to make "AereoDiLinea[playerid]" to 1 XD