SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 07/12/2019, 07:16 PM   #1
Hazon
Big Clucker
 
Hazon's Avatar
 
Join Date: May 2018
Location: Who cares ?
Posts: 157
Reputation: 26
Default CMD.

How to edit this command to less lines.

Code:
CMD:gstats(playerid, params[])
{
    if(PInfo[playerid][pgangID] == -1)
		return SCM(playerid, COLOR_TOMATO, "* You must be in a gang to use this command!");
    
	new string[200], DIALOG[500], id;
	if(sscanf(params,"d",id))
	{
	    if(PInfo[playerid][pgangID] == -1)
			return SCM(playerid, COLOR_TOMATO, "[USAGE]: {FFFFFF}/gstats [gangid]");
			
  		format(string, sizeof(string), ""COL_GREEN"You are now viewing %s[%d] gang statistic\n\n", gangInfo[PInfo[playerid][pgangID]][gName], PInfo[playerid][pgangID]);
		strcat(DIALOG, string);
		format(string, sizeof(string), ""COL_GREEN"- Gang ID: "COL_WHITE"%d\n", PInfo[playerid][pgangID]);
		strcat(DIALOG, string);
		format(string, sizeof(string), ""COL_GREEN"- Members: "COL_WHITE"%d\n", gangInfo[PInfo[playerid][pgangID]][gMembers]);
		strcat(DIALOG, string);
		format(string, sizeof(string), ""COL_GREEN"- Gang Score: "COL_WHITE"%d\n", gangInfo[PInfo[playerid][pgangID]][gScore]);
		strcat(DIALOG, string);
		format(string, sizeof(string), ""COL_GREEN"- Leader: "COL_WHITE"%s\n", gangInfo[PInfo[playerid][pgangID]][gLeaderName]);
		strcat(DIALOG, string);
		format(string, sizeof(string), ""COL_GREEN"- Tag: "COL_WHITE"%s\n", gangInfo[PInfo[playerid][pgangID]][gTag]);
		strcat(DIALOG, string);
		ShowPlayerDialog(playerid, DIALOG_STATS, DIALOG_STYLE_MSGBOX, " {FFFFFF}Gangs", DIALOG, "Close", "");
	}
	else
	{
	    if(gangInfo[id][gActive] == 0)
			return SCM(playerid, COLOR_TOMATO, "* Gang ID doesen't exist.");
			
		format(string, sizeof(string), ""COL_GREEN"You are now viewing %s[%d] gang statistic\n\n", gangInfo[PInfo[id][pgangID]][gName], PInfo[id][pgangID]);
		strcat(DIALOG, string);
		format(string, sizeof(string), ""COL_GREEN"- Gang ID: "COL_WHITE"%d\n", PInfo[id][pgangID]);
		strcat(DIALOG, string);
		format(string, sizeof(string), ""COL_GREEN"- Members: "COL_WHITE"%d\n", gangInfo[PInfo[id][pgangID]][gMembers]);
		strcat(DIALOG, string);
		format(string, sizeof(string), ""COL_GREEN"- Gang Score: "COL_WHITE"%d\n", gangInfo[PInfo[id][pgangID]][gScore]);
		strcat(DIALOG, string);
		format(string, sizeof(string), ""COL_GREEN"- Leader: "COL_WHITE"%s\n", gangInfo[PInfo[id][pgangID]][gLeaderName]);
		strcat(DIALOG, string);
		format(string, sizeof(string), ""COL_GREEN"- Tag: "COL_WHITE"%s\n", gangInfo[PInfo[id][pgangID]][gTag]);
		strcat(DIALOG, string);
		ShowPlayerDialog(playerid, DIALOG_STATS, DIALOG_STYLE_MSGBOX, " {FFFFFF}Gangs", DIALOG, "Close", "");
	}
	return 1;
}
Hazon is offline   Reply With Quote
Old 07/12/2019, 09:10 PM   #2
Kaliber
High-roller
 
Kaliber's Avatar
 
Join Date: Jun 2012
Location: Localhost
Posts: 1,068
Reputation: 149
Default Re: CMD.

Try:

PHP Code:
CMD:gstats(playeridparams[])
{
    if(
PInfo[playerid][pgangID] == -1) return SCM(playeridCOLOR_TOMATO"* You must be in a gang to use this command!");
    new 
string[250], idgangID;
    if(
sscanf(params,"d",id)) return SCM(playeridCOLOR_TOMATO"[USAGE]: {FFFFFF}/gstats [gangid]");
    if(
gangInfo[id][gActive] == 0)    return SCM(playeridCOLOR_TOMATO"* Gang ID doesen't exist.");
    
gangID PInfo[id][pgangID];
    
format(stringsizeof(string),"\
    "
COL_GREEN"You are now viewing %s[%d] gang statistic\n\n\
    "
COL_GREEN"- Gang ID: "COL_WHITE"%d\n\
    "
COL_GREEN"- Members: "COL_WHITE"%d\n\
    "
COL_GREEN"- Gang Score: "COL_WHITE"%d\n\
    "
COL_GREEN"- Leader: "COL_WHITE"%s\n\
    "
COL_GREEN"- Tag: "COL_WHITE"%s\n",
    
gangInfo[gangID][gName],gangID,gangID,gangInfo[gangID][gMembers],gangInfo[gangID][gScore],gangInfo[gangID][gLeaderName],gangInfo[gangID][gTag]);
    
ShowPlayerDialog(playeridDIALOG_STATSDIALOG_STYLE_MSGBOX" {FFFFFF}Gangs"string"Close""");
    return 
1;

__________________
Kaliber 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



All times are GMT. The time now is 02:24 AM.


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