11.07.2016, 22:02
Hello, i am making dynamic teleport system, and now i ran into a problem.
I want to devide system into 3 teleport categories. And i do, i list all of them correctly, but the problem is with IDs, when i put all teleport locations into one dialog, i can do something like
new id = listitem;
and then it goes from 0, but if i devide it into 3 categories i have no idea how to get an id for each.
code:
dialogs:
I want to devide system into 3 teleport categories. And i do, i list all of them correctly, but the problem is with IDs, when i put all teleport locations into one dialog, i can do something like
new id = listitem;
and then it goes from 0, but if i devide it into 3 categories i have no idea how to get an id for each.
code:
pawn Код:
CMD:createport(playerid, params[])
{
if(PI[playerid][Admin] < 6) return SCM(playerid, ERRORCOLOR, "ERROR: Niste ovlasteni za upotrebu ove komande - nemate admin level.");
new Float:Poz[3], kate, ime[36], upit[256], inter, vw, id = TeleportaUcitano, str[128];
if(sscanf(params, "is[36]", kate, ime)) return SCM(playerid, UPUTABOJA, "UPUTA: /createport [Kategorija 1-3] [Ime Lokacije]");
GetPlayerPos(playerid, Poz[0], Poz[1], Poz[2]);
inter = GetPlayerInterior(playerid);
vw = GetPlayerVirtualWorld(playerid);
Teleport[id][ID] = id;
strmid(Teleport[id][tpIme], ime, 0, strlen(ime), 255);
Teleport[id][PozX] = Poz[0];
Teleport[id][PozY] = Poz[1];
Teleport[id][PozZ] = Poz[2];
Teleport[id][Interior] = inter;
Teleport[id][VW] = vw;
Teleport[id][Kategorija] = kate;
mysql_format(konekt, upit, sizeof(upit), "INSERT INTO `Ports` (`ID`, `Ime`, `PozX`, `PozY`, `PozZ`, `Interior`, `VW`, `Kategorija`) VALUES ('%d', '%e', '%f', '%f', '%f', '%d', '%d', '%d')", id, ime, Poz[0], Poz[1], Poz[2], inter, vw, kate);
mysql_tquery(konekt, upit);
TeleportaUcitano ++;
format(str, sizeof(str), "ID: %d | TP Created: %s | %f | %f | %f | %d | %d | %d", Teleport[id][ID], Teleport[id][tpIme], Teleport[id][PozX], Teleport[id][PozY], Teleport[id][PozZ], Teleport[id][Interior], Teleport[id][VW], Teleport[id][Kategorija]);
SCM(playerid, RED, str);
return 1;
}
CMD:port(playerid, params[])
{
if(PI[playerid][Admin] == 0) return SCM(playerid, ERRORCOLOR, "ERROR: Niste ovlasteni za upotrebu ove komande - nemate admin level.");
SPD(playerid, DIALOG_PORTLISTA, DIALOG_STYLE_LIST, "Odaberite kategoriju", "Javna mesta\nOrganizacije\nOstalo", "Odaberi", "Izlaz");
/*new info[2100];
for(new i = 0; i < 35; i++)
{
new str[128];
format(str, sizeof(str), "%s\n", Teleport[i][tpIme]);
strcat(info, str, sizeof(info));
}
SPD(playerid, DIALOG_KATE1PORT, DIALOG_STYLE_LIST, "Lokacije", info, "Odaberi", "");*/
return 1;
}
pawn Код:
case DIALOG_PORTLISTA:
{
new info[2100];
if(response)
{
switch(listitem)
{
case 0:
{
for(new i = 0; i < 50; i++)
{
if(Teleport[i][Kategorija] == 1)
{
new str[128];
format(str, sizeof(str), "%s\n", Teleport[i][tpIme]);
strcat(info, str, sizeof(info));
}
}
SPD(playerid, DIALOG_KATE1PORT, DIALOG_STYLE_LIST, "Lokacije", info, "Odaberi", "");
}
case 1:
{
for(new i = 0; i < 50; i++)
{
if(Teleport[i][Kategorija] == 2)
{
new str[128];
format(str, sizeof(str), "%s\n", Teleport[i][tpIme]);
strcat(info, str, sizeof(info));
}
}
SPD(playerid, DIALOG_KATE1PORT, DIALOG_STYLE_LIST, "Lokacije", info, "Odaberi", "");
}
case 2:
{
for(new i = 0; i < 50; i++)
{
if(Teleport[i][Kategorija] == 3)
{
new str[128];
format(str, sizeof(str), "%s\n", Teleport[i][tpIme]);
strcat(info, str, sizeof(info));
}
}
SPD(playerid, DIALOG_KATE1PORT, DIALOG_STYLE_LIST, "Lokacije", info, "Odaberi", "");
}
}
}
}
case DIALOG_KATE1PORT:
{
if(response)
{
new str[128];
new id = listitem;
if(IsPlayerInAnyVehicle(playerid))
{
SetPlayerVehPos(GetPlayerVehicleID(playerid), Teleport[id][PozX],Teleport[id][PozY],Teleport[id][PozZ]);
}
else
{
SetPlayerPos_H(playerid,Teleport[id][PozX],Teleport[id][PozY],Teleport[id][PozZ]);
}
format(str, sizeof(str), "Teleportovani ste do %s.", Teleport[id][tpIme]);
SCM(playerid, -1, str);
id = -1;
}
}