Two questions
#1

MY kick command
pawn Код:
dcmd_kick(playerid,params[])
{
    new string[128];
    new ID;
    new cmdreason[100];
    new pname[MAX_PLAYER_NAME];
    new tname[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pname,sizeof(pname));
    GetPlayerName(ID,tname,sizeof(tname));
    if(sscanf(params,"us[100]",ID,cmdreason))
    {
        SendClientMessage(playerid,COLOR_ERROR,"[USAGE] /kick (Player Name/ID) (Reason)");
        return 1;
    }
    if(!IsPlayerConnected(ID))
    {
        format(string,sizeof(string),"[ERROR] The player ID you entered is not connected to the server.");
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    format(string, sizeof(string), "~r~KICKED!");
    GameTextForPlayer(ID, string, 3000, 1);

    format(string,sizeof(string),"[KICKED] Administrator %s(%d) has kicked you from the server. [Reason: %s]",pname,playerid,cmdreason);
    SendClientMessage(ID,COLOR_RED,string);
   
    format(string,sizeof(string),"[ADMIN KICK] Administrator has kicked %s(%d). [Reason: %s]",tname,ID,cmdreason);
    SendClientMessageToAll(COLOR_PINK,string);

    format(string,sizeof(string),"9[ADMIN KICK] Administrator has kicked %s(%d). [Reason: %s]",tname,ID,cmdreason);
    IRC_GroupSay(gGroupID,IRC_CHANNEL,string);

    format(string,sizeof(string),"[ADMIN RADIO] Administrator %s(%d) has kicked %s(%d). [Reason: %s]",pname,playerid,tname,ID,cmdreason);
    SendAdminMessage(COLOR_PINK,string);
    IRC_GroupSay(gGroupID,IRC_ADMINCHANNEL,string);
    Kick(ID);
    return 1;
}
It has something to do 0.3x that Kick is over any text or dialougs..
I need to know how to delay itt..


Second one is..
pawn Код:
dcmd_sethealth(playerid,params[])
{
    new string[128];
    new ID;
    new cmdreason;
    new pname[MAX_PLAYER_NAME];
    new tname[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pname,sizeof(pname));
    GetPlayerName(ID,tname,sizeof(tname));
    if(sscanf(params,"us[100]",ID,cmdreason))
    {
        SendClientMessage(playerid,COLOR_ERROR,"[USAGE] /sethealth (Player Name/ID) (Health)");
        return 1;
    }
    if(!IsPlayerConnected(ID))
    {
        format(string,sizeof(string),"[ERROR] The player ID you entered is not connected to the server.");
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    if(IsSpawned[ID] != 1)
    {
        format(string,sizeof(string),"[ERROR] %s(%d) is not spawned to set his health.",tname,ID);
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    format(string,sizeof(string),"[HEALTH] Administrator %s(%d) has set your health to %d.",pname,playerid,cmdreason);
    SendClientMessage(ID,COLOR_PINK,string);

    format(string,sizeof(string),"[HEALTH] You have set %s(%d)'s health to %d.",tname,ID,cmdreason);
    SendClientMessage(playerid,COLOR_PINK,string);
   
    SetPlayerHealth(ID, cmdreason);
    format(string,sizeof(string),"[ADMIN RADIO] Administrator %s(%d) has set %s(%d)'s health to %d",pname,playerid,tname,ID,cmdreason);
    SendAdminMessage(COLOR_PINK,string);
    IRC_GroupSay(gGroupID,IRC_ADMINCHANNEL,string);
    return 1;
}
Even if player is in server, it always says :"player not connected"


No compiling errors at all
Reply
#2

#1
well you can delay it by using a timer
pawn Код:
forward KickTimer(ID);
public KickTimer(ID)
{
     Kick(ID);
     return 1;
}
SetTimerEx("KickTimer",1000,false,"i",ID);
#2
I notice that you use GetPlayerName before the sscanf statement but that won't fix problem
Reply
#3

You need to show the message and then delay the kick/ban slightly!
Replace
pawn Код:
Kick(playerid)
with
pawn Код:
SetTimerEx("PublicKick", 1000, false, "i", playerid);
You must add the function to your code first, though
pawn Код:
forward PublicKick(playerid);
public PublicKick(playerid) return Kick(playerid);
Reply
#4

I'm done with the first problem, but I'm down to the other..

cmdreason doesn't seem to work with numbers, any help?
Reply
#5

Use this instead:

pawn Код:
// Instead of this
if(!IsPlayerConnected(ID))
{

//Use this

if(ID = INVALID_PLAYER_ID)
{
Try that. I think that should fix your problem, I heard others saying that IsPlayerConnected doesn't work with the user placeholder in sscanf.
Reply
#6

I did that already and it worked, when ever I type a number it's default "49" there's something wrong with cmdreason, can someone post a similar command?
Reply
#7

Woops, didn't understand you.

This is probably why, you are checking if the player typed a string, when infact it's a number. Try this:

pawn Код:
//Wrong
if(sscanf(params,"us[100]",ID,cmdreason)) // s[100] means it checks if you typed a string (max is 100)
{

//Right
if(sscanf(params,"ui", ID, cmdreason)) //cmd reason is an integer, meaning the second letter must be i or d (for integer)
{
Quote:
Originally Posted by RealCop228
Посмотреть сообщение
You don't need to check if a player is connected when using sscanf IIRC since it already does that for you.
Wow, all this time I've been checking if the player was connected. Silly me.
Reply
#8

You don't need to check if a player is connected when using sscanf IIRC since it already does that for you.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)