[Solved] Need help with my function - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Solved] Need help with my function (
/showthread.php?tid=82424)
[Solved] Need help with my function -
SiJ - 18.06.2009
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
}
Re: Need help with my function -
The_Tough - 18.06.2009
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; }
|
Re: Need help with my function -
Grim_ - 18.06.2009
trying to fix this, might help
pawn Код:
stock KickPlayer(playerid, reason[], kickerid[MAX_PLAYER_NAME])
{
//and do stuff without formating the reason + kickerid, ect.
}
Re: Need help with my function -
SiJ - 18.06.2009
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!
Re: Need help with my function -
kc - 18.06.2009
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.
Re: Need help with my function -
Grim_ - 18.06.2009
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;
}