SA-MP Forums Archive
make /kick with exmplanations? - 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: make /kick with exmplanations? (/showthread.php?tid=150020)



make /kick with exmplanations? - hardstop - 24.05.2010

can someone give me an example /kick (playerid) command with examples


Re: how can i make any command like /commandname (other player id) - shady91 - 24.05.2010

use sscanf is the best/easiest way.


Re: make /kick with exmplanations? - Sascha - 24.05.2010

add this at the other #defines:

Код:
#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;
}
I hope this works and I could help you a bit

Edit: put into code for DJDhan


Re: make /kick with exmplanations? - DJDhan - 24.05.2010

Sascha, please use ["code"] and ["/code"] (without the qoutes).It messes the screen and script without that.


Re: make /kick with exmplanations? - hardstop - 25.05.2010

thnx now i understand tyvm