SA-MP Forums Archive
Kick command showing an unwanted error. - 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: Kick command showing an unwanted error. (/showthread.php?tid=546705)



Kick command showing an unwanted error. - Accent - 17.11.2014

Hi fellas,so this is my kick command
Код:
CMD:kick(playerid,params[])
{
	new id,string[128],PlayerName[MAX_PLAYER_NAME],reason[100];
	if(PlayerInfo[playerid][pAdmin] < 1) return SCM(playerid, -1,"{FF0000}You are not authorized to use this command.");
 	if(sscanf(params,"us[100]",id,reason)) return SCM(playerid, -1,"{FF0000}/kick [ID]");
 	GetPlayerName(playerid, PlayerName,sizeof(PlayerName));
 	if(id == INVALID_PLAYER_ID) return SCM(playerid, -1,"{FF0000}Player is not connected.");
	if(playerid == id) return SCM(playerid, -1,"{FF0000}You cannot kick yourself,fool");
	format(string,sizeof(string),"{FF0000}Player %s has been kicked by Admin %s for %s",PlayerName,PlayerName,reason);
	SendClientMessageToAll(COL_WHITE,string);
	Kick(id);
	return 1;
}
Error is
Код:
pwn(494) : error 035: argument type mismatch (argument 1)
Line 494 is
Код:
	SendClientMessageToAll(COL_WHITE,string);
i really don't know what the problem is.For those who know,kindly help me out,can't figure out what the problem is actually.


Re: Kick command showing an unwanted error. - OsteeN - 17.11.2014

-removed-

Give me a second and I'll update this post.

Edit: I'm not having a problem compiling this. Have you tried compiling without this command? (kick)
Also, note that the player getting kicked might not be able to see the message as Kick(id) might be quicker than the message sending. Also, it will show "Player UserWhoUsedKickCommand has been kicked by Admin UserWhoUsedKickCommand for whatever reason.", even if the administrator kicked someone else.


Re: Kick command showing an unwanted error. - Zex Tan - 17.11.2014

Possibly you put the wrong colour format? I tried the code that you posted with SendClientMessageToAll and it gives me the same error when I added a hashtag like "#0x2123"


Re: Kick command showing an unwanted error. - Accent - 17.11.2014

Did it not compile well?
EDIT:This is also a problem of mine,/admins shows only for my level and when i set the other player's level,it shows for himself and not for both.
Код:
CMD:admins(playerid,params[])
{
	new admin = 0;
	new string[128];
	new PlayerName[28];
	GetPlayerName(playerid, PlayerName, 28);
	admin++;
 	for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][pAdmin] > 0)
        {
            format(string,sizeof(string),"The following admin(s) are currently online:\nName: %s Level: %d ID: %i\n",PlayerName,PlayerInfo[i][pAdmin],i);
            ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Online Admins",string,"Okay","Close");
            return 1;
        }
    }
}
Help me with this also.I do not want to create multiple threads for all my problems.


Re: Kick command showing an unwanted error. - OsteeN - 17.11.2014

Quote:
Originally Posted by Accent
Посмотреть сообщение
Did it not compile well?
EDIT:This is also a problem of mine,/admins shows only for my level and when i set the other player's level,it shows for himself and not for both.
Код:
CMD:admins(playerid,params[])
{
	new admin = 0;
	new string[128];
	new PlayerName[28];
	GetPlayerName(playerid, PlayerName, 28);
	admin++;
 	for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][pAdmin] > 0)
        {
            format(string,sizeof(string),"The following admin(s) are currently online:\nName: %s Level: %d ID: %i\n",PlayerName,PlayerInfo[i][pAdmin],i);
            ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Online Admins",string,"Okay","Close");
            return 1;
        }
    }
}
Help me with this also.I do not want to create multiple threads for all my problems.
Use strcat to add each admin into one message or alike.


Re: Kick command showing an unwanted error. - Accent - 17.11.2014

Nope,i cant estimate the exact number of admins or i may have wrongly read your answer.I don't think your solution fits in.Anyone else?


Re: Kick command showing an unwanted error. - Banana_Ghost - 17.11.2014

pawn Код:
CMD:admins(playerid,params[])
{
    new admin = 0;
    new string[128];
    new PlayerName[24];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][pAdmin] > 0)
        {
            admin++;
            format(string,sizeof(string),"The following admin(s) are currently online:\n%sName: %s Level: %d ID: %i\n",string, PlayerName,PlayerInfo[i][pAdmin],i);
            ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Online Admins",string,"Okay","Close");
            return 1;
        }
    }
}
try this


Re: Kick command showing an unwanted error. - OsteeN - 17.11.2014

Quote:
Originally Posted by Banana_Ghost
Посмотреть сообщение
pawn Код:
CMD:admins(playerid,params[])
{
    new admin = 0;
    new string[128];
    new PlayerName[24];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][pAdmin] > 0)
        {
            admin++;
            format(string,sizeof(string),"The following admin(s) are currently online:\n%sName: %s Level: %d ID: %i\n",string, PlayerName,PlayerInfo[i][pAdmin],i);
            ShowPlayerDialog(playerid,1,DIALOG_STYLE_MSGBOX,"Online Admins",string,"Okay","Close");
            return 1;
        }
    }
}
try this
That would attempt to create a dialog for each administrator, wouldn't it? (edit: Noticed you had a return; that will only show the first administrator it finds, yes?)

This might be sloppy written, but I'm in a bit of a hurry so here's something you can try, OP:
pawn Код:
CMD:admin(playerid, params[])
{
    new string[512], admin[126], pName[MAX_PLAYER_NAME]; // Edit this to the size you'll prefer and based on how much you think you need
    format(string, sizeof(string), "Administrators Online:\n\n"); // Title of your dialog
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][pAdmin] > 0) // For each player, check if they're an administrator
        {
            GetPlayerName(i, pName, sizeof(pName)); // Get the administrators name
            format(admin, sizeof(admin), "Name: %s | Level: %d\n", pName, PlayerInfo[i][pAdmin]);
            strcat(string, admin); // Attach the formatted text to the string
        }
    }
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Administrators", string, "Close", "");
    return 1;
}
Haven't tested it tho.


Re: Kick command showing an unwanted error. - Accent - 17.11.2014

Still a NO.Help me out with the kick command first.


Re: Kick command showing an unwanted error. - Banana_Ghost - 18.11.2014

Quote:
Originally Posted by OsteeN
Посмотреть сообщение
That would attempt to create a dialog for each administrator, wouldn't it? (edit: Noticed you had a return; that will only show the first administrator it finds, yes?)

This might be sloppy written, but I'm in a bit of a hurry so here's something you can try, OP:
pawn Код:
CMD:admin(playerid, params[])
{
    new string[512], admin[126], pName[MAX_PLAYER_NAME]; // Edit this to the size you'll prefer and based on how much you think you need
    format(string, sizeof(string), "Administrators Online:\n\n"); // Title of your dialog
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][pAdmin] > 0) // For each player, check if they're an administrator
        {
            GetPlayerName(i, pName, sizeof(pName)); // Get the administrators name
            format(admin, sizeof(admin), "Name: %s | Level: %d\n", pName, PlayerInfo[i][pAdmin]);
            strcat(string, admin); // Attach the formatted text to the string
        }
    }
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Administrators", string, "Close", "");
    return 1;
}
Haven't tested it tho.
it was a quick edit, i see my errors now lol.

Kick Command:
pawn Код:
//Use this to start the timer to kick the player, thus showing the message before kicking them.
forward kickplayer(playerid);
public kickplayer(playerid)
{
    Kick(playerid);
    return 1;
}

CMD:kick(playerid,params[])
{
    new id,string[128],PlayerName[MAX_PLAYER_NAME],TargetName[MAX_PLAYER_NAME],reason[100];//Added TargetName[MAX_PLAYER_NAME] to hold the name of the player (id).
    if(PlayerInfo[playerid][pAdmin] < 1) return SCM(playerid, -1,"{FF0000}You are not authorized to use this command.");
    if(sscanf(params,"us[100]",id,reason)) return SCM(playerid, -1,"{FF0000}/kick [ID] [reason]");
    if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id))) return SCM(playerid, -1,"{FF0000}Player is not connected.");
    if(playerid == id) return SCM(playerid, -1,"{FF0000}You cannot kick yourself,fool");
    GetPlayerName(playerid, PlayerName,sizeof(PlayerName));
    GetPlayerName(id,TargetName,sizeof(TargetName));//Added this to get the name of the player kicked.
    format(string,sizeof(string),"{FF0000}Player %s has been kicked by Admin %s for %s",TargetName,PlayerName,reason);
    SendClientMessageToAll(COL_WHITE,string);
    SetTimerEx("kickplayer", 1000, false, "i", id);//This is the timer used to kick the player so they will see the string above.
    return 1;
}
//try this