Why does this ... -
[D]ry[D]esert - 29.04.2012
Hello every one
why does this does't work ?
Код:
#include <sscanf2>
dcmd(kick, 4 , cmdtext);
dcmd_kick(playerid, params[])
{
new name1[MAX_PLAYER_NAME];
new name2[MAX_PLAYER_NAME];
new String[286];
new reason[80];
new id[80];
if(AccountInfo[playerid][AdminLevel] <= 1)
{
if (sscanf(params, "us[80]", id,reason)) return SendClientMessage(playerid,COLOR_WHITE,"USAGE: /kick [playerid] [reason]"); //If you didn't fill in the command correctly.
line 1624 if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_WHITE,"This player is not connected."); // Obvious why.
GetPlayerName(playerid, name1, sizeof(name1)); // Getting the name of the playerid
line 1626 GetPlayerName(id, name2, sizeof(name2)); // Getting the name of the target.
format(String,sizeof(String),"%s has been kicked by admin %s Reason: %s",name2,name1,reason); //We're defining the message here. with it's information
SendClientMessageToAll(COLOR_WHITE,String); // Sends the message to everyone.
line 1629 Kick(id); //Will kick the player. Make sure it is id and not playerid because playerid will kick yourself.
return 1; // Stops the command.
}
return 1;
}
Whats Wrong in it
?
Errors Show
Код:
C:\Users\almooo\Desktop\Zombie server\gamemodes\Zm.pwn(1624) : error 035: argument type mismatch(argument 1)
C:\Users\almooo\Desktop\Zombie server\gamemodes\Zm.pwn(1626) : error 035: argument type mismatch (argument 1)
C:\Users\almooo\Desktop\Zombie server\gamemodes\Zm.pwn(1629) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
3 Errors.
Re: Why does this ... -
Finn - 29.04.2012
id shouldn't be an array.
pawn Код:
new id[80];
// --->
new id;
Re: Why does this ... -
Ash. - 29.04.2012
The variable "id" is a string, and you're using functions that require their parameters to be integers. To get the integer value of a string use
Rather than having
, you should have
pawn Код:
IsPlayerConnect(strval(id))
However. You're using the 'u' parameter in sscanf, and therefore you should merely declared 'id' as an integer (- remove the array's size).
Re: Why does this ... -
[D]ry[D]esert - 29.04.2012
Quote:
Originally Posted by Finn
id shouldn't be an array.
pawn Код:
new id[80];
// --->
new id;
|
1.Thanks for the Fast Reply
2.it Works

+rep
Re: Why does this ... -
[D]ry[D]esert - 29.04.2012
But when i add command /heal and /kick no error but consol say
"File or Function is not found"
D: and My gm does't start

any help ?
Re: Why does this ... -
Ash. - 29.04.2012
Is the plugin named "sscanf" loading? Could you show us your server_log.txt (initialisation part)?
Re: Why does this ... -
iRemix - 29.04.2012
Try this:
pawn Код:
dcmd_kick(playerid, params[])
{
if(AccountInfo[playerid][AdminLevel] <=1)
{
new pName[24], pVictim[24], gMessage[250], iD, gReason[250];
if(sscanf(params, "us[250]", iD, gReason)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /kick [playerid] [reason]");
else if(iD == playerid) return SendClientMessage(playerid, 0xFFFFFFFF, "You cannot use this command on yourself.");
else if(!IsPlayerConnected(iD)) return return SendClientMessage(playerid, 0xFFFFFFFF, "That player is not connected.");
else
{
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(iD, gVictim, sizeof(gVictim));
format(gMessage, sizeof(gMessage), "* Server: %s has been kicked from the server by %s. Reason: %s", gVictim, pName, gReason);
SendClientMessageToAll(0xFF0000FF, gMessage);
Kick(iD);
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "* You are not an admin.");
}
return 1;
}
If that fails to load, make sure you've downloaded the correct version of sscanf, and also make sure that you've added it to the plugins line on your config.ini
+ Rep if I've helped.
Re: Why does this ... -
[D]ry[D]esert - 29.04.2012
Quote:
Originally Posted by funky1234
Is the plugin named "sscanf" loading? Could you show us your server_log.txt (initialisation part)?
|
Quote:
Originally Posted by iRemix
Try this:
pawn Код:
dcmd_kick(playerid, params[]) { if(AccountInfo[playerid][AdminLevel] <=1) { new pName[24], pVictim[24], gMessage[250], iD, gReason[250]; if(sscanf(params, "us[250]", iD, gReason)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /kick [playerid] [reason]"); else if(iD == playerid) return SendClientMessage(playerid, 0xFFFFFFFF, "You cannot use this command on yourself."); else if(!IsPlayerConnected(iD)) return return SendClientMessage(playerid, 0xFFFFFFFF, "That player is not connected."); else { GetPlayerName(playerid, pName, sizeof(pName)); GetPlayerName(iD, gVictim, sizeof(gVictim)); format(gMessage, sizeof(gMessage), "* Server: %s has been kicked from the server by %s. Reason: %s", gVictim, pName, gReason); SendClientMessageToAll(0xFF0000FF, gMessage); Kick(iD); } } else { SendClientMessage(playerid, COLOR_RED, "* You are not an admin."); } return 1; }
If that fails to load, make sure you've downloaded the correct version of sscanf, and also make sure that you've added it to the plugins line on your config.ini
+ Rep if I've helped.
|
Yeah i forget to plugins sscanf
both thanks and Rep
Re: Why does this ... -
[D]ry[D]esert - 29.04.2012
but Why these Command does't work in game :\
Re: Why does this ... -
Crazymax - 29.04.2012
Quote:
Originally Posted by [D]ry[D]esert
but Why these Command does't work in game :\
|
explain what happens... does it say server Unknown command?