I think this dialog is causing lag, could someone tell me why? -
Dokins - 22.12.2013
pawn Код:
else if(dialogid == DIALOG_RANDOMS)
{
if(response == 0)
{
ShowPlayerDialog(playerid, DIALOG_PARTLIST, DIALOG_STYLE_LIST, "Part Selection", "{FF0000}Grips\n{FF0000}Frames\n{FF0000}Barrels\n{FF0000}Random Packages", "Select", "Cancel");
}
switch(listitem)
{
case 0://Random Package.
{
new str[128];
if(PlayerMoney[playerid] < 1500)return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much money.");
GivePlayerMoney(playerid, -1500);
new rand[3];
new randStr[3][25];
for(new i = 0; i < sizeof rand; i++)
{
rand[i] = random(3);
switch(rand[i])
{
case 0:
{
format(randStr[i], 25, "Small Grip");
SGrip[playerid] ++;
MySQL_SetInteger(PlayerSQLID[playerid], "SGrip", SGrip[playerid], "accounts");
}
case 1:
{
format(randStr[i], 25, "Medium Grip");
MGrip[playerid] ++;
MySQL_SetInteger(PlayerSQLID[playerid], "MGrip", MGrip[playerid], "accounts");
}
case 2:
{
format(randStr[i], 25, "Large Grip");
LGrip[playerid] ++;
MySQL_SetInteger(PlayerSQLID[playerid], "LGrip", LGrip[playerid], "accounts");
}//case 2
}//switch
}//fornew
format(str, sizeof(str),"You got a {33AA33}%s{FFFFFF}, a {33AA33}%s {FFFFFF}and a {33AA33}%s {FFFFFF}from the package.", randStr[0], randStr[1], randStr[2]);
SendClientMessage(playerid, COLOUR_WHITE, str);
}//actual case
case 1://Random Package.
{
if(PlayerMoney[playerid] < 3000)return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much money.");
GivePlayerMoney(playerid, -3000);
new rand1[3];
new randStr1[3][25];
for(new i = 0; i < sizeof rand1; i++)
{
rand1[i] = random(3);
switch(rand1[i])
{
case 0:
{
format(randStr1[i], 25, "Small Frame");
SFrame[playerid] ++;
MySQL_SetInteger(PlayerSQLID[playerid], "SFrame", SFrame[playerid], "accounts");
}
case 1:
{
format(randStr1[i], 25, "Medium Frame");
MFrame[playerid] ++;
MySQL_SetInteger(PlayerSQLID[playerid], "MFrame", MFrame[playerid], "accounts");
}
case 2:
{
format(randStr1[i], 25, "Large Frame");
LFrame[playerid] ++;
MySQL_SetInteger(PlayerSQLID[playerid], "LFrame", LFrame[playerid], "accounts");
}//case 2
}//switch
}//switch
format(str, sizeof(str),"You got a {33AA33}%s{FFFFFF}, a {33AA33}%s {FFFFFF}and a {33AA33}%s {FFFFFF}from the package.", randStr1[0], randStr1[1], randStr1[2]);
SendClientMessage(playerid, COLOUR_WHITE, str);
}//case
case 2://Random Package.
{
if(PlayerMoney[playerid] < 2000)return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much money.");
GivePlayerMoney(playerid, -2000);
PlayerSQLID[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "id", "accounts");
new rand2[3];
new randStr2[3][25];
for(new i = 0; i < sizeof rand2; i++)
{
rand2[i] = random(3);
switch(rand2[i])
{
case 0:
{
format(randStr2[i], 25, "Small Barrel");
SBarrel[playerid] ++;
MySQL_SetInteger(PlayerSQLID[playerid], "SBarrel", SBarrel[playerid], "accounts");
}
case 1:
{
format(randStr2[i], 25, "Medium Barrel");
MBarrel[playerid] ++;
MySQL_SetInteger(PlayerSQLID[playerid], "MBarrel", MBarrel[playerid], "accounts");
}
case 2:
{
format(randStr2[i], 25, "Large Barrel");
LBarrel[playerid] ++;
MySQL_SetInteger(PlayerSQLID[playerid], "LBarrel", LBarrel[playerid], "accounts");
}//case 2
}//switch
}//for
format(str, sizeof(str),"You got a {33AA33}%s{FFFFFF}, a {33AA33}%s {FFFFFF}and a {33AA33}%s {FFFFFF}from the package.", randStr2[0], randStr2[1], randStr2[2]);
SendClientMessage(playerid, COLOUR_WHITE, str);
}//case
}//switch
}//dialog
Basically, when I open the dialog that has the list to open this, it causes lag, I believe it's this one causing it as it has loops etc..
this has been an issue for a while now, could anyone tell me why?
Re: I think this dialog is causing lag, could someone tell me why? -
Jefff - 22.12.2013
pawn Код:
else if(dialogid == DIALOG_RANDOMS)
{
if(response == 0)
{
ShowPlayerDialog(playerid, DIALOG_PARTLIST, DIALOG_STYLE_LIST, "Part Selection", "{FF0000}Grips\n{FF0000}Frames\n{FF0000}Barrels\n{FF0000}Random Packages", "Select", "Cancel");
return 1;
}
new str[128], randStr[3][25];
switch(listitem)
{
case 0://Random Package.
{
if(PlayerMoney[playerid] < 1500)return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much money.");
GivePlayerMoney(playerid, -1500);
for(new i = 0; i < sizeof(randStr); i++)
{
switch(random(3))
{
case 0:
{
randStr[i] = "Small Grip";
SGrip[playerid] ++;
MySQL_SetInteger(PlayerSQLID[playerid], "SGrip", SGrip[playerid], "accounts");
}
case 1:
{
randStr[i] = "Medium Grip";
MGrip[playerid] ++;
MySQL_SetInteger(PlayerSQLID[playerid], "MGrip", MGrip[playerid], "accounts");
}
default:
{
randStr[i] = "Large Grip";
LGrip[playerid] ++;
MySQL_SetInteger(PlayerSQLID[playerid], "LGrip", LGrip[playerid], "accounts");
}//case 2
}//switch
}//fornew
format(str, sizeof(str),"You got a {33AA33}%s{FFFFFF}, a {33AA33}%s {FFFFFF}and a {33AA33}%s {FFFFFF}from the package.", randStr[0], randStr[1], randStr[2]);
SendClientMessage(playerid, COLOUR_WHITE, str);
}//actual case
case 1://Random Package.
{
if(PlayerMoney[playerid] < 3000)return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much money.");
GivePlayerMoney(playerid, -3000);
for(new i = 0; i < sizeof(randStr); i++)
{
switch(random(3))
{
case 0:
{
randStr[i] = "Small Frame";
SFrame[playerid] ++;
MySQL_SetInteger(PlayerSQLID[playerid], "SFrame", SFrame[playerid], "accounts");
}
case 1:
{
randStr[i] = "Medium Frame";
MFrame[playerid] ++;
MySQL_SetInteger(PlayerSQLID[playerid], "MFrame", MFrame[playerid], "accounts");
}
default:
{
randStr[i] = "Large Frame";
LFrame[playerid] ++;
MySQL_SetInteger(PlayerSQLID[playerid], "LFrame", LFrame[playerid], "accounts");
}//case 2
}//switch
}//switch
format(str, sizeof(str),"You got a {33AA33}%s{FFFFFF}, a {33AA33}%s {FFFFFF}and a {33AA33}%s {FFFFFF}from the package.", randStr[0], randStr[1], randStr[2]);
SendClientMessage(playerid, COLOUR_WHITE, str);
}//case
case 2://Random Package.
{
if(PlayerMoney[playerid] < 2000)return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much money.");
GivePlayerMoney(playerid, -2000);
PlayerSQLID[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "id", "accounts");
for(new i = 0; i < sizeof(randStr); i++)
{
switch(random(3))
{
case 0:
{
randStr[i] = "Small Barrel";
SBarrel[playerid] ++;
MySQL_SetInteger(PlayerSQLID[playerid], "SBarrel", SBarrel[playerid], "accounts");
}
case 1:
{
randStr[i] = "Medium Barrel";
MBarrel[playerid] ++;
MySQL_SetInteger(PlayerSQLID[playerid], "MBarrel", MBarrel[playerid], "accounts");
}
default:
{
randStr[i] = "Large Barrel";
LBarrel[playerid] ++;
MySQL_SetInteger(PlayerSQLID[playerid], "LBarrel", LBarrel[playerid], "accounts");
}//case 2
}//switch
}//for
format(str, sizeof(str),"You got a {33AA33}%s{FFFFFF}, a {33AA33}%s {FFFFFF}and a {33AA33}%s {FFFFFF}from the package.", randStr[0], randStr[1], randStr[2]);
SendClientMessage(playerid, COLOUR_WHITE, str);
}//case
}//switch
}//dialog
if still lag use mysql debug
Re: I think this dialog is causing lag, could someone tell me why? -
Dokins - 22.12.2013
The Functions do work, however I will do so.
Thank you.
Re: I think this dialog is causing lag, could someone tell me why? -
Dokins - 22.12.2013
Okay, it's still lagging, but it actually lags when I open this:
pawn Код:
CMD:buyparts(playerid,params[])
{
new string[64];
if(IsPlayerInRangeOfPoint(playerid, 5.0, -2230.5210,2560.3955,1.8223))
{
format(string, sizeof(string), "Illegal Gun Part Purchasing.");
ShowPlayerDialog(playerid, DIALOG_PARTLIST, DIALOG_STYLE_LIST, string, "{FF0000}Grips\n{FF0000}Frames\n{FF0000}Barrels\n{FF0000}Random Packages", "Select", "Cancel");
}
return 1;
}
Why on EARTH would that take 2-3 seconds to open? I'm so confused.
Re: I think this dialog is causing lag, could someone tell me why? -
Jefff - 22.12.2013
Only this command? no others? maybe you have modified zcmd version ?
Re: I think this dialog is causing lag, could someone tell me why? -
Dokins - 23.12.2013
Yeah only this command?
Re: I think this dialog is causing lag, could someone tell me why? -
park4bmx - 23.12.2013
other things might be running in the background or actually there is not threads in SAMP(only plugin) so there might be things that are running and taking up resources, you need to debug here ;x