Spike of lag - 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)
+--- Thread: Spike of lag (
/showthread.php?tid=587752)
Spike of lag -
Lajko1 - 02.09.2015
What is causing 2 seconds spike of lag when I insert Username in this dialog?
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
GetName(playerid) = PlayerInfo[playerid][pName];
switch( dialogid )
{
case DIALOG_CHOOSEUSERNAME:
{
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_CHOOSEUSERNAME, DIALOG_STYLE_INPUT,""COL_GREEN"Choose your Username",""COL_WHITE"Please choose your Username \nUsername lenght must be between 4-10 letters","Confirm","Abort");
if(!(4 <= strlen(inputtext) <= 10)) // to short username
{
//TextDrawSetSelectable(INPText[20], true);
return 1;
}
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"Username");
INI_WriteInt(File,"Username",udb_hash(inputtext));
INI_Close(File);
CorrectUsername[playerid] = 1;
GoodUsername(playerid);
TextDrawSetString(Username[14], inputtext);
TextDrawColor(Username[14], -2147450625);
TextDrawShowForPlayer(playerid, Username[14]);
return 1;
}
return 1;
}
Re: Spike of lag -
Yashas - 02.09.2015
https://sampforum.blast.hk/showthread.php?pid=3506473#pid3506473
But this still shouldn't cause a lag of 2 seconds. Can we see your GoodUsername function?
Re: Spike of lag -
Lajko1 - 03.09.2015
Newest code added to script not using it anywhere
pawn Код:
ValidateWord(const string[]) {
for( ; ; ) {
switch(string[0]) {
case 'a'..'z', '0'..'9', 'A'..'Z': {
#emit load.s.pri string
#emit add.c 4
#emit stor.s.pri string
}
case EOS: {
return true;
}
default: {
break;
}
}
}
return false;
}
Your request:
pawn Код:
GoodUsername(playerid)
{
TextDrawHideForPlayer(playerid, TDUNbad[16]);
TextDrawShowForPlayer(playerid, TDUNgood[19]);
return 1;
}
some other codes..
pawn Код:
GoodPassword(playerid)
{
TextDrawHideForPlayer(playerid, TDPWbad[17]);
TextDrawShowForPlayer(playerid, TDPWgood[18]);
return 1;
}
BadUsername(playerid)
{
TextDrawShowForPlayer(playerid, TDUNup[16]);
TextDrawHideForPlayer(playerid, TDUNdn[19]);
return 1;
}
BadPassword(playerid)
{
TextDrawShowForPlayer(playerid, TDPWup[17]);
TextDrawHideForPlayer(playerid, TDPWdn[18]);
return 1;
}