SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 19/06/2012, 04:18 PM   #1
DanTzi
Little Clucker
 
Join Date: Jun 2011
Posts: 26
Reputation: 2
Default kick command with zcmd and sscanf

Hello, I wondered how can I make a /kick command with sscanf and zcmd - as a rcon admin.

-Thanks.
DanTzi is offline   Reply With Quote
Old 19/06/2012, 04:36 PM   #2
Randy More
Big Clucker
 
Join Date: Jun 2012
Location: The Arab Republic of Egypt.
Posts: 134
Reputation: 16
Default Re: kick command with zcmd and sscanf

pawn Code:
CMD:kick(playerid, params[])
{
    new targetid, string[256], reason[128], playeridn[MAX_PLAYER_NAME], targetidn[MAX_PLAYER_NAME];
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, SOME_COLOR,"ERROR: You are not an administrator");
    if(sscanf(params,"is", targetid, reason)) return SendClientMessage(playerid, SOME_COLOR,"USAGE: /kick [targetid] [reason]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, SOME_COLOR,"ERROR: Invalid targetid.");
    if(IsPlayerAdmin(tagetid)) return SendClientMessage(playerid, SOME_COLOR,"ERROR: You can't kick an administrator.");
    GetPlayerName(playerid, playeridn, sizeof(playeridn));
    GetPlayerName(targetid, targetidn, sizeof(targetidn)):
    format(string, sizeof(string),"Warning: %s has kicked %s from the server, reason: %s", playeridn, targetidn, reason);
    SendClientMessageToAll(SOME_COLOR, string);
    Kick(targetid);
    return 1;
}
Randy More is offline   Reply With Quote
Old 19/06/2012, 04:45 PM   #3
Jhero
Big Clucker
 
Join Date: Jun 2012
Posts: 149
Reputation: 17
Default Re: kick command with zcmd and sscanf

Here is another command for /kick,

pawn Code:
CMD:kick(playerid, params[])
{
    new playerb, string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    //if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
    if(sscanf(params, "us[128]", playerb, params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /kick [playerid] [reason]");
    if(!IsPlayerConnected(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
    if(IsPlayerNPC(playerb)) return SendClientMessage(playerid, COLOR_GREY, "You can't kick NPCs out of the server.");
    if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playerb][pAdmin]) return SendClientMessage(playerid, COLOR_GREY, "Player has a higher admin level than you."); format(string, sizeof(string), "AdmCmd: %s has been kicked by %s, reason: %s", RPN(playerb), RPN(playerid), params);
    format(string, sizeof(string), "AdmCmd: %s has been kicked by %s, reason: %s", RPN(playerb), RPN(playerid), params);
    SendClientMessageToAll(COLOR_LIGHTRED, string);
    format(string, sizeof(string), "AdmCmd: %s has been kicked by %s (%s), reason: %s", RPN(playerb), RPN(playerid), RPIP(playerid), params);
    Log("logs/kick.log", string);
    Kick(playerb);
    return 1;
}
__________________
Jhero


Please REP me if my post helped you!
Jhero is offline   Reply With Quote
Old 19/06/2012, 04:47 PM   #4
[MM]RoXoR[FS]
Gangsta
 
[MM]RoXoR[FS]'s Avatar
 
Join Date: Mar 2012
Location: Gurgaon,India
Posts: 738
Reputation: 138
Default Re: kick command with zcmd and sscanf

pawn Code:
CMD:kick(playerid,params[])
{
    new id,reason[50];
    if(sscanf(params,"us[50]",id,reason)) return SendClientMessage(playerid,-1,"Usage : /kick [playerid/name] [reason]");
    else if(!IsPlayerConnected(id))  return SendClientMessage(playerid,-1,"Player is not connected.");
    else
    {
        if(PlayerInfo[playerid][pAdmin]>0 || IsPlayerAdmin(playerid)==1)
        {
        new str[100];
        format(str,sizeof(str),"%s has kicked %s for %s.",PlayerInfo[playerid][pName],PlayerInfo[id][pName],reason);
        SendClientMessageToAll(-1,str);
        kick(id);
        }
    }
}
__________________
My Works
Top Players Include[Sorts Player's Kills|Money|Deaths|ANYTHING YOU WANT|
pawn Code:
public OnPlayerConnect(playerid)
{
  Ban(playerid);
  return 1;
}

Scripting for Money
[MM]RoXoR[FS] is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with my kick command - ZCMD + SSCANF BizzyD Help Archive 2 11/04/2011 08:42 PM
zcmd kick command Omecken Help Archive 8 23/02/2011 01:47 PM
/kick command with zcmd & sscanf2 mrcoolballs Help Archive 4 24/08/2010 02:23 PM
[Help] ZCMD Kick Command Dudits Help Archive 3 14/07/2010 09:49 PM


All times are GMT. The time now is 03:35 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.