SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 26/03/2020, 08:30 PM   #1
MarianImmortalGod
Big Clucker
 
Join Date: Mar 2018
Posts: 66
Reputation: 1
Default Can't use command

Hello, i have a command that give's me more time to compile, before adding it i had 2 sec compile time, now i have 8 sec.

HTML Code:
CMD:members(playerid, params[]) 
{
	new szQuery[256], string[180], MemberString[700], szResult[21];
	new name[21], rank[3], days[11], raport[3], tmembers;
	format(szQuery, sizeof(szQuery), "SELECT * FROM `users` WHERE `Member` = '%d' ORDER BY `users`.`Rank` DESC", PlayerInfo[playerid][pLeader]);
	new Cache: result = mysql_query(handle, szQuery);
	strcat(MemberString, "Nume\tGrad\tZile\n");
	for(new i, j = cache_num_rows(); i != j; ++i)
	{
		cache_get_value_name(i, "Name", szResult); format(name, 21, szResult);
		cache_get_value_name_int(i, "Rank", PlayerInfo[i][pRank]); format(rank, 3, PlayerInfo[i][pRank]);
		cache_get_value_name_int(i, "FactionDays", PlayerInfo[i][pFactionDays]); format(days, 11, PlayerInfo[i][pFactionDays]);
		cache_get_value_name_int(i, "FactionRaport", PlayerInfo[i][pFactionRaport]); format(raport, 3, PlayerInfo[i][pFactionRaport]);
		format(Selected[playerid][tmembers], MAX_PLAYER_NAME, name);
		new userID = GetPlayerID(name);	
		
        if(userID != INVALID_PLAYER_ID) 
        {
            format(string, sizeof(string), "%s\t%d (%d rapoarte) Online\t%d\n", name, rank, raport, days);
			strcat(MemberString, string, sizeof(MemberString));
        }
        else 
        {
            format(string, sizeof(string), "%s\t%d (%d rapoarte) Offline\t%d\n", name, rank, raport, days);
            strcat(MemberString, string, sizeof(MemberString));
        }
		tmembers++;
	}
	cache_delete(result);
	ShowPlayerDialog(playerid, DIALOG_FACTIONMEMBERS, DIALOG_STYLE_TABLIST_HEADERS, "Membri factiunii tale", MemberString, "Ok", "Exit");
	return 1;
}
Any idea ? and maybe how to make it smaller ? i have mysql r-41
MarianImmortalGod is offline   Reply With Quote
Old 26/03/2020, 09:20 PM   #2
l0gic
Big Clucker
 
Join Date: Aug 2019
Posts: 103
Reputation: 16
Default Re: Can't use command

https://forum.sa-mp.com/showthread.php?t=481257
It would save some memory
PHP Code:
#include <ps-format>
CMD:members(playeridparams[]) {
    new 
s[100];
    
format(s100"select * from users where member = '%d' order by rank desc"PlayerInfo[playerid][pLeader]);
    new 
Cache:cq mysql_query(handles);
    new 
Packed:bs[1024] = !"Nume\tGrad\tZile\n",
        
name[24],
        
rank,
        
days,
        
raport;
    for(new 
icache_num_rows(); ji++){
        
// getting database variable into local variable, makes sense not other way
        
cache_get_value_name(i"Name"name);
        
cache_get_value_name_int(i"Rank"rank);
        
cache_get_value_name_int(i"FactionDays"days);
        
cache_get_value_name_int(i"FactionRaport"raport);
        
format(bs1024, !"%s%s\t%d (%d rapoarte) %s\t%d\n"
            
bsnamerankraportGetPlayerID(name) != INVALID_PLAYER_ID ? ("Online") : ("Offline"), days);
    }
    
cache_delete(cq);
    
ShowPlayerDialog(playeridDIALOG_FACTIONMEMBERSDIALOG_STYLE_TABLIST_HEADERS"Membri factiunii tale"bs"Ok""Exit");
    return 
1;

__________________
Coding experience with: PAWN, Java, Python, Javascript, PHP and SQL for about 6 years.

Last edited by l0gic; 26/03/2020 at 10:16 PM.
l0gic is offline   Reply With Quote
Old 26/03/2020, 10:35 PM   #3
MarianImmortalGod
Big Clucker
 
Join Date: Mar 2018
Posts: 66
Reputation: 1
Default Re: Can't use command

Quote:
Originally Posted by l0gic View Post
https://forum.sa-mp.com/showthread.php?t=481257
It would save some memory
PHP Code:
#include <ps-format>
CMD:members(playeridparams[]) {
    new 
s[100];
    
format(s100"select * from users where member = '%d' order by rank desc"PlayerInfo[playerid][pLeader]);
    new 
Cache:cq mysql_query(handles);
    new 
Packed:bs[1024] = !"Nume\tGrad\tZile\n",
        
name[24],
        
rank,
        
days,
        
raport;
    for(new 
icache_num_rows(); ji++){
        
// getting database variable into local variable, makes sense not other way
        
cache_get_value_name(i"Name"name);
        
cache_get_value_name_int(i"Rank"rank);
        
cache_get_value_name_int(i"FactionDays"days);
        
cache_get_value_name_int(i"FactionRaport"raport);
        
format(bs1024, !"%s%s\t%d (%d rapoarte) %s\t%d\n"
            
bsnamerankraportGetPlayerID(name) != INVALID_PLAYER_ID ? ("Online") : ("Offline"), days);
    }
    
cache_delete(cq);
    
ShowPlayerDialog(playeridDIALOG_FACTIONMEMBERSDIALOG_STYLE_TABLIST_HEADERS"Membri factiunii tale"bs"Ok""Exit");
    return 
1;

Thx, but i the download link from that ps-format expired. link ?
MarianImmortalGod is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with YCMD proces command and problem with "Server:Unknown command JoDe Scripting Help 1 20/04/2018 12:12 PM
[Plugin] mcmd Command Engine - Plugin based command processing Mellnik Plugin Development 108 08/05/2016 01:55 PM
i had this command in my gamemode, when i type this in game,it tells server unknow command? Chrisli520 Scripting Help 3 24/11/2013 10:02 AM
Executed ZCMD command returns SERVER: Unknown Command SexTourist Scripting Help 12 03/01/2012 03:38 PM
Slap command returns an Unknown Command when player is not connected HydraX Help Archive 16 01/08/2011 05:19 AM


All times are GMT. The time now is 08:58 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.