24.05.2010, 16:14
can someone give me an example /kick (playerid) command with examples
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1 This is only the define for the command we will be using. Now: public OnPlayerCommandText(playerid, cmdtext[]) { dcmd(kick, 4, cmdtext); return 1; } dcmd_kick(playerid, params[]) { new pName[50]; GetPlayerName(playerid, pName, 50); //<--this gets the name of the player who sends the command (you will need this in the next line) if(!strcmp(pName, "Replacewithyourname", true)) //<--this checks if the playername is your name { new tmp[256],idx; tmp = strtok(params,idx); if(!strlen(tmp)){ //<--this checks if you added something behind the /kick SendClientMessage(playerid,AddAColorHere, "/kick [id]"); return 1; } new pid = strval(tmp); //that "makes" the number you added to a "playerid" if(!IsPlayerConnected(pid)){ SendClientMessage(playerid,AddAColorHere, "This player is not connected."); return 1; }else{ new pname[MAX_PLAYER_NAME], pname2[MAX_PLAYER_NAME], string[256]; GetPlayerName(playerid, pname, sizeof(pname)); //<--this saves you name as "pname" GetPlayerName(pid, pname2, sizeof(pname2)); //<--this saves the name of the id you entered as "pname2" format(string, sizeof(string), "%s kicked %s from the server", pname, pname2); //<---the pname and pname2 at the end are to identify which %s should replace what SendClientMessageToAll(YourColor, string); //this sends the formatted message as a client message to all and will replace the %s with the names Kick(pid); //finally the player needs to be kicked from the server, and this is what it does:D return 1; } return 1; }