SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 10/08/2019, 09:14 PM   #1
Danielknow
Big Clucker
 
Join Date: May 2018
Location: United States
Posts: 70
Reputation: 1
Default Making new command.

Code:
CMD:helpers(playerid)
{
	new
	count = 0,
	string[256];
	SendClientMessage(playerid, WHITE,"[Server Staff] Helpers:");
	foreach(new i : Player)
	{
		if(PlayerInfo[i][Helper] == 1)
		{
			format(string, sizeof(string),"Helper: [%d]%s", i, PlayerInfo[i][Nick]);
			SendClientMessage(playerid, Lg, string);
			count++;
		}
	}
	if(count == 0) SendClientMessage(playerid, WHITE,"[Server Staff] Helpers:");
	return 1;
}
Code:
CMD:admins(playerid, params[])
{
	if(PlayerInfo[playerid][Level] >= 0)
	{

		new count = 0, string[256];
		SendClientMessage(playerid, WHITE,"[Server Staff] Administrators:");
		foreach(new i : Player)
		{

			if(PlayerInfo[i][Level] > 0 && !PlayerInfo[i][is_undercover] && !hidden[playerid])
			{

				format(string, sizeof(string),"%s %s: %s", RPALN(playerid), RPNU(playerid), params);
				SendClientMessage(playerid, WHITE, string);
				count++;
			}
		}
		if(!count) SendClientMessage(playerid, blue,"[Server Staff] Administrators:");
	}
	return 1;
}
Well, i want make /admins like this:

[Server Staff] Administrators:
-"my rank name" Daniel (id)
[Server Staff] Helpers:
-Daniel (id)


I need marge between commands.
Thanks for who can help me
Danielknow is offline   Reply With Quote
Old 10/08/2019, 09:44 PM   #2
Calisthenics
Gangsta
 
Join Date: May 2018
Posts: 660
Reputation: 96
Default Re: Making new command.

One way is 2 foreach loops, the other is 2 local arrays. I changed few mistakes you had (playerid to i) and will display messages only if admins or helpers are online.

Make sure you have re-defined MAX_PLAYERS.
pawn Code:
CMD:admins(playerid, params[])
{
    if (PlayerInfo[playerid][Level] >= 0)
    {
        new count_admins, count_helpers,
            string[100],
            admins[MAX_PLAYERS] = {-1, ...}, helpers[MAX_PLAYERS] = {-1, ...};

        foreach(new i: Player)
        {
            if (PlayerInfo[i][Level] > 0 && !PlayerInfo[i][is_undercover] && !hidden[i])
            {
                admins[count_admins++] = i;
            }
            else if (PlayerInfo[i][Helper] == 1)
            {
                helpers[count_helpers++] = i;
            }
        }

        if (count_admins)
        {
            SendClientMessage(playerid, WHITE, "[Server Staff] Administrators:");

            for (new i; i < count_admins; i++)
            {
                format(string, sizeof(string), "-%s %s (%d)", RPALN(admins[i]), RPNU(admins[i]), admins[i]);
                SendClientMessage(playerid, WHITE, string);
            }
        }

        if (count_helpers)
        {
            SendClientMessage(playerid, WHITE, "[Server Staff] Helpers:");

            for (new i; i < count_helpers; i++)
            {
                format(string, sizeof(string), "-%s (%d)", PlayerInfo[helpers[i]][Nick], helpers[i]);
                SendClientMessage(playerid, Lg, string);
            }
        }

        if (!count_admins && !count_helpers) SendClientMessage(playerid, WHITE, "No server staff online.");
    }
    return 1;
}

Last edited by Calisthenics; 11/08/2019 at 05:58 PM.
Calisthenics is offline   Reply With Quote
Old 10/08/2019, 10:42 PM   #3
Danielknow
Big Clucker
 
Join Date: May 2018
Location: United States
Posts: 70
Reputation: 1
Default Re: Making new command.

Quote:
Originally Posted by Calisthenics View Post
One way is 2 foreach loops, the other is 2 local arrays. I changed few mistakes you had (playerid to i) and will display messages only if admins or helpers are online.

Make sure you have re-defined MAX_PLAYERS.
Thank you
by the way i want remove the " " from the rank name. tried but got errors
Danielknow is offline   Reply With Quote
Old 10/08/2019, 11:30 PM   #4
Fuzzy
Little Clucker
 
Join Date: May 2019
Posts: 37
Reputation: 0
Default Re: Making new command.

Code:
                format(string, sizeof(string), "-\%s\ %s (%d)", RPALN(i), RPNU(i), i);
                SendClientMessage(playerid, WHITE, string);
__________________
My Releases:
Fuzzy is offline   Reply With Quote
Old 10/08/2019, 11:38 PM   #5
Danielknow
Big Clucker
 
Join Date: May 2018
Location: United States
Posts: 70
Reputation: 1
Default Re: Making new command.

Quote:
Originally Posted by Fuzzy View Post
Code:
                format(string, sizeof(string), "-\%s\ %s (%d)", RPALN(i), RPNU(i), i);
                SendClientMessage(playerid, WHITE, string);
Code:
error 027: invalid character constant
same line, i got it too.
Danielknow is offline   Reply With Quote
Old 11/08/2019, 04:36 AM   #6
Scottas
Huge Clucker
 
Scottas's Avatar
 
Join Date: Jul 2010
Location: Lithuania
Posts: 336
Reputation: 28
Default Re: Making new command.

if you want to print backslash, you have to use escape character:

Code:
format(string, sizeof(string), "-\\%s\\ %s (%d)", RPALN(i), RPNU(i), i);
SendClientMessage(playerid, WHITE, string);
Scottas is offline   Reply With Quote
Old 11/08/2019, 07:16 AM   #7
KeyOfKey
Huge Clucker
 
KeyOfKey's Avatar
 
Join Date: Apr 2019
Location: Italy
Posts: 427
Reputation: 16
Default Re: Making new command.

Just for curiosity, what is RPALN and RPNU?
__________________


Symon's Cops and Robbers - Grand opening: October 1st 2019.

Discord: https://discord.gg/QH2qmBj
IP: (Add it on your favourites to be ready on launch!) Click me

We're waiting you.
KeyOfKey is offline   Reply With Quote
Old 11/08/2019, 08:57 AM   #8
Calisthenics
Gangsta
 
Join Date: May 2018
Posts: 660
Reputation: 96
Default Re: Making new command.

I forgot to replace i with the array so replace with:
pawn Code:
format(string, sizeof(string), "-%s %s (%d)", RPALN(admins[i]), RPNU(admins[i]), admins[i]);
Calisthenics is offline   Reply With Quote
Old 11/08/2019, 09:32 AM   #9
Danielknow
Big Clucker
 
Join Date: May 2018
Location: United States
Posts: 70
Reputation: 1
Default Re: Making new command.

Quote:
Originally Posted by KeyOfKey View Post
Just for curiosity, what is RPALN and RPNU?
Code:
stock RPALN(playerid)
{
	new name[32];
	if(PlayerInfo[playerid][Level] == 1) format(name, sizeof(name), "Trial Admin");
	else if(PlayerInfo[playerid][Level] == 8) format(name, sizeof(name), "Owner");
	else if(PlayerInfo[playerid][Helper] == 1) format(name, sizeof(name), "Helper");
	return name;
}

stock RPNU(playerid)
{
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	return name;
}
I got tip to change it but i still didn't because i wont fuck up the script.
Newbie
Danielknow 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
How can i save position from one command and put it in another command with out making new file RockyGamer Scripting Help 2 16/10/2014 10:57 AM
Hi. I need help making a command that destroys all vehicles spawned with a command MoeSal Scripting Help 3 24/01/2014 01:26 AM
need help making a command codebreaker23 Scripting Help 1 27/06/2012 10:34 AM
Making a command to display command. TheDominator Scripting Help 4 10/03/2012 12:25 AM
Need Help With Making A New Command tyyler0 Help Archive 2 15/02/2010 03:02 AM


All times are GMT. The time now is 12:23 PM.


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