What I did wrong? :S - 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: What I did wrong? :S (
/showthread.php?tid=344382)
What I did wrong? :S -
Audi_Quattrix - 20.05.2012
I was trying to make /kick [id] [Reason] command with zcmd but i failed,I wish someone will help me...
pawn Код:
COMMAND:kick(playerid,params[] )
{
new name[MAX_PLAYER_NAME];
new giveplayerid;
GetPlayerName(playerid, name, sizeof(name)); // pretty self-explanatory
if (PlayerInfo[playerid][pAdminLevel] >=2 || IsPlayerAdmin(playerid))
{
if(giveplayerid != INVALID_PLAYER_ID) // if the player is online
{
new string[128];
GetPlayerName(playerid, name, sizeof(name));
format(string,sizeof(string),"%s has been kicked by %s, Reason: %s ");
SendClientMessageToAll(0xFFFFFFF,string);
return Kick(playerid); // returns the command to kick the player
}
}
else
SendClientMessage(playerid, COLOR_RED, "[ERROR:] Invalid ID.");
else
SendClientMessage(playerid, COLOR_RED, "[ERROR:] You are not an admin!");
return 1;
}
Re: What I did wrong? :S -
Infinitas - 20.05.2012
What errors are you getting?
Re: What I did wrong? :S -
Audi_Quattrix - 20.05.2012
Nvm....I deleted it. I found out i need sscanf for it but sscanf dont like my computer
So now i will try on rCmd
Re: What I did wrong? :S -
jessejanssen - 21.05.2012
You don't really need sscanf for it.. This is how it should be:
pawn Код:
CMD:kick(playerid,params[])
{
new name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME], string[110], idx;
GetPlayerName(playerid, name, sizeof(name));
if(PlayerInfo[playerid][pAdminLevel] >=2 || IsPlayerAdmin(playerid))
{
string = strtok(params, idx);
if(!strlen(string))
{
SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /kick [id] [reason]");
return 1;
}
new giveplayerid = string;
string = strtok(params, idx);
if(!strlen(string))
{
SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /kick [id] [reason]");
return 1;
}
if(IsPlayerConnected(giveplayerid))
{
new Text[110] = string
GetPlayerName(giveplayerid, name2, sizeof(name2));
format(string,sizeof(string),"%s has been kicked by %s, reason: %s", name2, name, text);
SendClientMessageToAll(0xFFFFFFF,string);
Kick(giveplayerid);
}
else return SendClientMessage(playerid, COLOR_RED, "[ERROR:] That ID is not connected!");
}
else return SendClientMessage(playerid, COLOR_RED, "[ERROR:] You are not an Admin!");
return 1;
}
I hope it helped.
Best regards,
Jesse
Re: What I did wrong? :S -
Audi_Quattrix - 21.05.2012
Thanks Jesse
Re: What I did wrong? :S -
Jeroen52 - 21.05.2012
LOL I can also see that you did this: Kick(playerid); While playerid is the player who executes the command, it should have been giveplayerid .
Also, you have not done format well as well as the GetPlayerName.
I know you got it fixed but just pointing the things out.