String Command error
#1

Hello. I want my command to be shown like this.

AdminRank ServerName / ForumName (On Duty)
AdminRank ServerName / ForumName (Off Duty)


But instead, it shows like this.

AdminRank Servername AdminRank2 ServerName2 (without line break.)


And, I want to add a new command /forumname and to show if admin is adminduty.

Can you help me? Beside that, if no admin is online, it won't show the " Nici un admin online"

My command

Code:
CMD:admins(playerid, params[])
{
	if(pInfo[playerid][pHour] >= 0)
	{
	    new adminstring[128];
	    new text[128];
	    if(IsPlayerConnected(playerid))
	    {
	        for (new i = 0; i < MAX_PLAYERS; i++)
	        {
	            if(IsPlayerConnected(i))
	            {
	                if(pInfo[i][pAdminLevel] > 0)
	                {
	                    format(adminstring, sizeof(adminstring),"%s%s %s\n / %s", adminstring, GetAdminName(i), PlayerName(i), ForumName(i));
                        format(text, sizeof(text),"Administratori Online");
	                }
	            }
	        }
	        SendClientMessage(playerid,COLOR_WHITE, text);
	        SendClientMessage(playerid,COLOR_GREEN, adminstring);
		}
 		else return SendClientMessage(playerid,-1,"*"COL_LGREEN" Nici un admin online");
	}
    return 1;
}

ForumName command

Code:
CMD:forumname(playerid,params[])
{
    if(pInfo[playerid][pAdminLevel] >= 5)
	{
		new targetid,nume,string[180];
		if(sscanf(params, "ud", targetid, nume)) return  SendClientMessage(playerid,-1,""chat" /forumname [playerid] [nume]");
		if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,""chat" Player is not online");

        pInfo[targetid][ForumName] = nume;

		format(string, sizeof(string), "*"COL_RED" %s %s i-a setat numele de forum la %d lui %s",GetAdminName(playerid),PlayerName(playerid),nume,PlayerName(targetid));
		SendMessageToAllAdmins(string, -1);
	}
	else {
		SendClientMessage(playerid,-1,"*"COL_RED" Nu esti autorizat sa folosesti comanda!");
	}
	return 1;
}
aduty cmd

HTML Code:
CMD:aduty(playerid, params[])
{

	if (pInfo[playerid][pAdminLevel] < 1)
	    return SendClientMessage(playerid,COLOR_WHITE, "Nu esti Admin.");


    if (!pInfo[playerid][pAdminDuty])
	{
		SetPlayerColor(playerid,COLOR_PURPLE);
		SetPlayerSkin(playerid,280);


		pInfo[playerid][pAdminDuty] = 1;

        new string[128];
        GetPlayerName(playerid, string, 24);
        format(string, sizeof(string), "{FF0000} %s este acum Admin Duty. Foloseste (/report) pentru a cere ajutor" ,string);
		SendClientMessageToAll(-1, string);
	}
	else
	{
	    SetPlayerColor(playerid, COLOR_WHITE);
	    SetPlayerSkin(playerid,NORMAL);

		pInfo[playerid][pAdminDuty] = 0;
		new str[76], name[24];
        GetPlayerName(playerid, name, 24);
        format(str, sizeof(str), "{FF0000}%s nu mai este Admin Duty", name);
        SendClientMessageToAll(COLOR_GREEN, str);
	}
	return 1;
}
Reply
#2

And those are the errors

Code:
 : error 012: invalid function call, not a valid address
: warning 215: expression has no effect
: error 001: expected token: ";", but found ")"
 : error 029: invalid expression, assumed zero
 : fatal error 107: too many error messages on one line
all of them this line


format(adminstring, sizeof(adminstring),"%s%s %s\n / %s", adminstring, GetAdminName(i), PlayerName(i), ForumName(i));
Reply
#3

To show that no admins are online you could add a bool variable that you set to true, if there are any admins online. After you finish looping through players you could check if the value is true, if yes - print the admin list, if not - print that there is no admins online.

Those errors you are getting are I think because you are using the wrong type of brackets. When accessing arrays use [ i ] not ( i ). So it would be PlayerName[i], ForumName[i], etc.
Reply
#4

Quote:
Originally Posted by AdamsLT
View Post
Those errors you are getting are I think because you are using the wrong type of brackets. When accessing arrays use [ i ] not ( i ). So it would be PlayerName[i], ForumName[i], etc.
Doesn't work. It worked fine until i added ForumName(i))
Reply
#5

help me pls
Reply
#6

In forumname, if nume is a string, then you shouldn't be using %d in the format for it, nor should you be using d in sscanf for the command input of nume.


24 hour bumps only too.


And what you're doing in that format in the first example in admins command, won't work as that's not how you use format, and pass things to SendClientMessage.

Simply use 2 strings, and do 2 SendClientMessages.
Reply
#7

Quote:
Originally Posted by Sew_Sumi
View Post
In forumname, if nume is a string, then you shouldn't be using %d in the format for it, nor should you be using d in sscanf for the command input of nume.


24 hour bumps only too.


And what you're doing in that format in the first example in admins command, won't work as that's not how you use format, and pass things to SendClientMessage.

Simply use 2 strings, and do 2 SendClientMessages.

How about now ?

HTML Code:
function Forumname(playerid,forumname[])
{
	new str[24],fname[16];

	format(fname,sizeof(fname),"%s",ForumName);

	pInfo[ForumName] = fname;

	new stra[256];
	format(stra,sizeof(stra),"*"COL_LGREEN" Admin %s(%i) has set your forumname to %s(%i)",PlayerName(playerid),playerid, ForumName);
	SendClientMessage(playerid,-1,stra);
	return 1;
}
Reply
#8

No, because now you are going to have an error on that line... You have 4 format specifiers, and only 3 arguments.

Your code also has another problem in this small segment. /forumname is executed by the player, setting their own forumname, so the reply from this command will be... (Excluding the last %i as that's not even needed.)


Admin User (0) has set your username to UsersName...


Nothing the 'admin' did actually did this.
Reply
#9

And how do I make that code? I don't know how to.
Reply
#10

'/n' : It's only for dialog text, and you can't use it into a 'SendClientMessage' , it won't work.

Test if it's working
Actually, Sew_Sumi has already noticed it for you
Quote:
Originally Posted by Sew_Sumi
View Post
And what you're doing in that format in the first example in admins command, won't work as that's not how you use format, and pass things to SendClientMessage.
PHP Code:
CMD:admins(playeridparams[])
{
    if(
pInfo[playerid][pHour] >= 0)
    {
        new 
adminstring[128];
        new 
text[128];
        if(
IsPlayerConnected(playerid))
        {
            for (new 
0MAX_PLAYERSi++)
            {
                if(
IsPlayerConnected(i))
                {
                    if(
pInfo[i][pAdminLevel] > 0)
                    {
                        
format(adminstringsizeof(adminstring),"%s %s / %s"GetAdminName(i), PlayerName(i), ForumName(i));
                        
format(textsizeof(text),"Administratori Online");
                    }
                }
            }
            
SendClientMessage(playerid,COLOR_WHITEtext);
            
SendClientMessage(playerid,COLOR_GREENadminstring);
        }
         
//else return SendClientMessage(playerid,-1,"*"COL_LGREEN" Nici un admin online"); Currently this message it won't be showed to the players.
    
}
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)