SA-MP Forums

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

Thread Tools Display Modes
Old 08/07/2020, 09:49 PM   #1
Big Clucker
Join Date: Jan 2020
Location: Egypt
Posts: 138
Reputation: 3
Default ban command

PHP Code:
banner[MAX_PLAYER_NAME], banned[MAX_PLAYER_NAME], bannedidreason[25], hoursstring[400], secsunbantsip[16], query[180];
IsPlayerAdmin(playerid) && pInfo[playerid][playerAdmin] < 2) return SendClientMessage(playeridCOLOR_RED"You are not admin to use this command");
sscanf(params"uds[25]"bannedidhoursreason)) return SendClientMessage(playerid, -1"Usage: /ban [player name/ID] [hours] [reason]"); 
IsPlayerConnected(bannedid)) return SendClientMessage(playerid, -1"Invalid player name/ID."); 
pInfo[playerid][playerAdmin] < pInfo[bannedid][playerAdmin]) return SendClientMessage(playerid, -1"You cannot ban someone with a higher level than you!"); 
strlen(reason) < || strlen(reason) > 24) return SendClientMessage(playerid, -1"Your reason must be between 3 and 24 characters."); 
hours || hours 720) return SendClientMessage(playerid, -1"Ban hours are between 12 and 720 hours");
secs hours*3600;
unbants gettime()+ secs;
mysql_format(connectionHandlequerysizeof(query), "INSERT INTO bans (ban_id, player, ip, admin, reason, ban_time, unban_time) VALUES('0', '%s', '%s', '%s', '%s', %d, %d)"bannedipbannerreasongettime(), unbants);
format(stringsizeof(string), "%s %s has banned %s for %d hours : %s"GetAdminName(playerid), bannerbannedhoursreason);

i wanna this cmd to ban for mins and hours for example /ban id mins hours reason
makemoneynotfriends is offline   Reply With Quote
Old 08/07/2020, 10:12 PM   #2
Join Date: May 2017
Location: Iran
Posts: 694
Reputation: 63
Default Re: ban command

Try this:
pawn Code:
CMD:ban(playerid, params[])
    new banner[MAX_PLAYER_NAME], banned[MAX_PLAYER_NAME], bannedid, reason[25], hours, mins, string[400], secs, unbants, ip[16], query[180];
    if(!IsPlayerAdmin(playerid) && pInfo[playerid][playerAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "You are not admin to use this command");
    if(sscanf(params, "udds[25]", bannedid, hours, mins, reason)) return SendClientMessage(playerid, -1, "Usage: /ban [player name/ID] [hours] [minutes] [reason]");
    if(!IsPlayerConnected(bannedid)) return SendClientMessage(playerid, -1, "Invalid player name/ID.");
    if(pInfo[playerid][playerAdmin] < pInfo[bannedid][playerAdmin]) return SendClientMessage(playerid, -1, "You cannot ban someone with a higher level than you!");
    if(strlen(reason) < 3 || strlen(reason) > 24) return SendClientMessage(playerid, -1, "Your reason must be between 3 and 24 characters.");
    if(hours < 0 || hours > 720) return SendClientMessage(playerid, -1, "Ban hours are between 12 and 720 hours");
    if(mins < 1 || mins > 59) return SendClientMessage(playerid, -1, "Ban minutes are between 1 and 59 minutes");
    GetPlayerName(playerid, banner, sizeof(banner));
    GetPlayerName(bannedid, banned, sizeof(banned));
    GetPlayerIp(bannedid, ip, sizeof(ip));
    secs = (hours*3600)+(mins*60);
    unbants = gettime()+ secs;
    mysql_format(connectionHandle, query, sizeof(query), "INSERT INTO bans (ban_id, player, ip, admin, reason, ban_time, unban_time) VALUES('0', '%s', '%s', '%s', '%s', %d, %d)", banned, ip, banner, reason, gettime(), unbants);
    mysql_tquery(connectionHandle, query);
    format(string, sizeof(string), "%s %s has banned %s for %d hours %d minutes : %s", GetAdminName(playerid), banner, banned, hours, mins, reason);
    SendClientMessageToAll(COLOR_RED, string);
    SetTimerEx("KickEx", 1000, false, "ibf", playerid, true, 5.1664);
    return 1;
xRadical3 is offline   Reply With Quote

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
Help with YCMD proces command and problem with "Server:Unknown command JoDe Scripting Help 1 20/04/2018 12:12 PM
[Plugin] mcmd Command Engine - Plugin based command processing Mellnik Plugin Development 108 08/05/2016 01:55 PM
i had this command in my gamemode, when i type this in game,it tells server unknow command? Chrisli520 Scripting Help 3 24/11/2013 10:02 AM
Executed ZCMD command returns SERVER: Unknown Command SexTourist Scripting Help 12 03/01/2012 03:38 PM
Slap command returns an Unknown Command when player is not connected HydraX Help Archive 16 01/08/2011 05:19 AM

All times are GMT. The time now is 02:41 PM.

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