[Solved] Need help with my function
#1

Hey,
I have function:
pawn Код:
stock KickPlayer(playerid,reason,kickerid)
{
    if(IsPlayerConnected(playerid))
    {
        //EDIT: Function removed, problem solved ;)
    }
}
But I get error "error 035: argument type mismatch (argument 2)"
in line:
pawn Код:
dcmd_kick(playerid, params[])
{
    //EDIT: removed
}
Reply
#2

Quote:
Originally Posted by Justas [SiJ
Hey,
I have function:

}
[/pawn]
But I get error "error 035: argument type mismatch (argument 2)"
in line:
pawn Код:
dcmd_kick(playerid, params[])
{
    new id, reason[128];
    if (sscanf(params, "us", id, reason)) UsageMsg(playerid, "Usage: /kick <PlayerID/PartOfName> <reason>");
        else if (id == INVALID_PLAYER_ID) ErrorMsg(playerid, "Player not found");
        else
        {
            KickPlayer(playerid,reason); // Try this one
        }
    return 1;
}
Reply
#3

trying to fix this, might help
pawn Код:
stock KickPlayer(playerid, reason[], kickerid[MAX_PLAYER_NAME])
{
  //and do stuff without formating the reason + kickerid, ect.
}
Reply
#4

Quote:
Originally Posted by The_Tough
Quote:
Originally Posted by Justas [SiJ
Hey,
I have function:
}
[/pawn]
But I get error "error 035: argument type mismatch (argument 2)"
in line:
pawn Код:
dcmd_kick(playerid, params[])
{
    new id, reason[128];
    if (sscanf(params, "us", id, reason)) UsageMsg(playerid, "Usage: /kick <PlayerID/PartOfName> <reason>");
        else if (id == INVALID_PLAYER_ID) ErrorMsg(playerid, "Player not found");
        else
        {
            KickPlayer(playerid,reason); // Try this one
        }
    return 1;
}
Use your brains before you reply... If I'd remove stock KickPlayer
KickPlayer(playerid,reason); wouldn't work..


Quote:
Originally Posted by Swift_
trying to fix this, might help
pawn Код:
stock KickPlayer(playerid, reason[], kickerid[MAX_PLAYER_NAME])
{
  //and do stuff without formating the reason + kickerid, ect.
}
I'll try it now..
EDIT: But kickerid cannot be [MAX_PLAYER_NAME] cause it's only ID of kicker... Am I right?
Thanks for help, it works!
Reply
#5


pawn Код:
stock KickPlayer(playerid,reason[],kickerid)
{
    if(IsPlayerConnected(playerid))
    {
        new name[MAX_PLAYER_NAME], kicker[MAX_PLAYER_NAME];
        ClrChat(playerid);
            GetPlayerName(playerid,name,sizeof(name));
            GetPlayerName(kickerid,kicker,sizeof(kicker));
            SendClientMessage(playerid,COLOR_ERROR,"____________________________________________________________");
            SendFMessageToAll(COLOR_ERROR,"Player %s has been kicked by %s",name,kicker); // SendFMessageToAll formats string and sends it to all players
            SendFMessageToAll(COLOR_ERROR,"Reason: %s",reason);
            SendClientMessage(playerid,COLOR_ERROR,"____________________________________________________________");
            Kick(playerid);
    }
}
A simple fix. "reason" is a string, but you defined it as a single cell.
Reply
#6

If that doesn't work, take a look at this. It was taken away from Cartlito's Roleplay and slightly edited. Change it as you want.
pawn Код:
public KickPlayer(targetid, kickedby[MAX_PLAYER_NAME], reason[])
{
  format(str, sizeof str, "Notice: %s has been kicked by %s. (Reason: %s)", PlayerName(targetid), kickedby, reason);
  SendClientMessageToAll(LIGHTRED, str);
  KickLog(str);
  return Kick(targetid);
}

PlayerName(playerid)
{
  new name[MAX_PLAYER_NAME];
  GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  return name;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)