Does this work?
#1

Hello folks,today out of boredom i saw a command i tried to make a BAN CMD and idk what took my computer when i compiled there were no errors and im not an scripter i just edit script and learn very small small things so idk how i made the code.Just wanted to check if it really works.I dont have GTA SA installed in my PC.Hence,i cant check so i wanted a volunteer to check it out for me.here is the code>
Код:
COMMAND:ban(playerid,params[])
{
		   new targetid,[playerid];
		   if (PInfo[playerid][Level] > 1 || (!IsPlayerAdmin [playerid] return 0
		   else if (sscanf(params,"us',targetid,name)SendClientMessage,(playerid,YELLOW,"Usage /ban [playerid].");
		   else {
				 Ban(targetid)
			format(string,sizeof(string),"Administrator %s has banned %s[ID:%d]",Name,targetid,n,playerid;
			SendClientMessageToAll(playerid,PINK,string);
			}
				 return 1;
}
EDIT:Need ZCMD for this code!
Reply
#2

Was not code giving mistakes? Dafuq

pawn Код:
COMMAND:ban(playerid,params[])
{
    new targetid;
    if(PInfo[playerid][Level] > 1 || !IsPlayerAdmin(playerid)) return 0;
    else if(sscanf(params, "ds", targetid, name) return SendClientMessage(playerid, YELLOW, "Usage /ban [playerid].");
    else if(!IsPlayerConnected(targetid)) return 0;
    else
    {
        Ban(targetid);
        format(string, sizeof(string), "Administrator %s has banned %s[ID:%d]", Name, targetid, playerid);
        SendClientMessageToAll(playerid, PINK, string);
    }
    return 1;
}
Reply
#3

Nope.?
EDIT:Only Warnings.
Reply
#4

pawn Код:
COMMAND:ban(playerid,params[])
{
    if(PInfo[playerid][Level] > 1 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "Only Administrators can use this command.");
    new targetid, reason[50];
    if(sscanf(params, "uS[50](No Reason)", targetid, reason)) return SendClientMessage(playerid, 0xFFFF00FF, "Usage: /ban [id/name] [Optional: reason]");
    if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000FF, "Player is not connected.");
    if(targetid == playerid) return SendClientMessage(playerid, 0xFF0000FF, "You cannot ban yourself.");
    new string[150], AdminName[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, AdminName, sizeof(AdminName));
    GetPlayerName(targetid, PlayerName, sizeof(PlayerName));
    format(string, sizeof(string), "Administrator %s has banned %s[ID:%d] | Reason: %s", AdminName, PlayerName, targetid, reason);
    SendClientMessageToAll(PINK, string);
    BanEx(targetid, reason);
    return 1;
}
You need the following at the TOP of your script:
pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
ZCMD by Zeex: https://sampforum.blast.hk/showthread.php?tid=91354
SSCANF by ******: https://sampforum.blast.hk/showthread.php?tid=120356
Reply
#5

But what about the code i provided?Isn't it good at all?Because it gave me only Warnings
Reply
#6

Yes, your code is horrible. I will show you where you went wrong in your code. (NOTE: Even after being fixed, it still will not work the way you want it to, so use the one I have provided for you.)

pawn Код:
COMMAND:ban(playerid, params[])
{
           //if (PInfo[playerid][Level] > 1 || (!IsPlayerAdmin [playerid] return 0
    if(PInfo[playerid][Level] < 1 && !IsPlayerAdmin(playerid)) return 0; //This line translates to: If the player's admin level is LESS than 1, AND they are not
    //logged into RCON, then return 0 and do not process the command.
           //new targetid,[playerid];
    new targetid; //playerid is already defined in the COMMAND:ban(playerid... line. Indentation is not very good here.
    //Also, you should add this AFTER you check if they're an admin, otherwise you will create this for no reason if they're not one.
           //else if (sscanf(params,"us',targetid,name)SendClientMessage,(playerid,YELLOW,"Usage /ban [playerid].");
    if(sscanf(params, "u", targetid) return SendClientMessage(playerid, YELLOW, "Usage: /ban [playerid].");
    //There is no need to use an 'else if' statement here. Also, make sure you RETURN SendClientMessage, or the code will still continue.
    //You do not need an 'else' statement here, as the code will end if the above if statement is not met because of the 'return'.
    Ban(targetid); //Missing a ';' at the end.
    new string[85], Name[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME]; //You need to define 'string' before you use it... (Unless you have a global variable, which I highly do not recommend)
    GetPlayerName(playerid, Name, sizeof(Name));
    GetPlayerName(targetid, pName, sizeof(pName));
    format(string, sizeof(string), "Administrator %s has banned %s[ID:%d]", Name, pName, targetid);
    SendClientMessageToAll(playerid, PINK, string);
    return 1;
}
I stopped commenting about half way through because there was just too many things wrong with it. Keep practicing and you will get there in as little as a few weeks. To be honest, I learned how to script by editing releases of other people's filterscripts and gamemodes. Just read it, understand what it's doing, learn it, remember it, master it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)