[Tutorial] How to script some important admin commands.
#1

Hello guys, I was trying to help some people today with fixing there admin commands so im going to show you how to create some important admin command. To start it off, i do not know if your using pAdmin, pAdminLevel or w.e so just work with me here. Note You might have to change my commands a little to have it work for your script. So lets get started.

In this tutorial im actually using pAdminLevel so if your using that, great. But if not change pAdminLevel in my commands to what you have.

So lets start making a Kick command. If your wanting to create an admin script using Dialogs, i suggest using Y_ini and my friend Kush supplied a tutorial on that.


Click here for Kush's Tutorial.
So for the Kick command, im using sscanf, so yes, you will need to have the include and at the top add


pawn Code:
#include <sscanf>
pawn Code:
CMD:kick(playerid,params[])
    {
        if(PlayerInfo[playerid][pAdminLevel] >=1)
        {
            new id,n[MAX_PLAYER_NAME],reason[35], on[MAX_PLAYER_NAME], string[128], string2[128];
            if(sscanf(params,"uz",id, reason)) return SendClientMessage(playerid,COLOR_RED,"Usage:/kick [ID] [reason]");
            else if(playerid == INVALID_PLAYER_ID) SendClientMessage(playerid,COLOR_RED,"System: Invalid ID");
            if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "System: Invalid ID");
            if(playerid == id) return SendClientMessage(playerid,COLOR_RED, "You cannot kick yourself");
            else
            {
            GetPlayerName(playerid,n,sizeof(n));
            GetPlayerName(id,on,sizeof(on));
            format(string,sizeof(string),"You have been kicked by Admin: %s for %s",n,reason);
            SendClientMessage(playerid,COLOR_RED,string);//
            format(string2, sizeof(string), "Admin Action: %s has kicked %s because: %s",n,on,reason);
            SendClientMessageToAll(COLOR_RED,string2);
            Kick(id);
            }
        }
        else return SendClientMessage(playerid,COLOR_RED,"  You are not allowed to use this command!");
        return 1;
    }
This Allows you to type /kick <Name> <Reason>

This makes it so if your not the correct admin level you will see the message

You are not allowed to use this command!

Now for Ban:
pawn Code:
CMD:ban(playerid, params[])
{
    new id, reason[50], string[128], banned[MAX_PLAYER_NAME];
    if(PlayerInfo[playerid][pAdminLevel] >= 5 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not allowed to use this command!");
    if(sscanf(params, "uz", id, reason)) return SendClientMessage(playerid, -1, "USAGE: /ban [ID] [Reason]");
    if(playerid == id) return SendClientMessage(playerid,COLOR_RED, "You cannot kick yourself");
    GetPlayerName(id, banned, sizeof(banned));
    format(string, sizeof(string), "AdmCmd: %s has been banned by %s. reason: %s", banned, GetName(playerid), reason);
    SendClientMessageToAll(COLOR_RED, string);
    BanEx(id, reason);
    return 1;
}
This is pretty much the same as kick, except you never get unbanned. Unless an Admin unbans you

pawn Code:
CMD:god(playerid, params[])
{
    if(PlayerInfo[playerid][pAdminLevel] >= 3)
    {
        SetPlayerHealth(playerid,100000);
        SendClientMessage(playerid,COLOR_GREEN,"|__God Activated__|");
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You are not allowed to use this command!");
    }
    return 1;
}
This makes your health go to unlimited, it will send you a message saying |__God Activated__|

If you are not the admin level you will get You are not allowed to use this command!
pawn Code:
CMD:godoff(playerid, params[])
{
    if(PlayerInfo[playerid][pAdminLevel] >= 3)
    {
        SetPlayerHealth(playerid, 100);
        SendClientMessage(playerid,COLOR_RED,"|__God Deactivated__|");
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You are not allowed to use this command!");
    }
    return 1;
}
This is pretty much the same as last command, except it returns your health back to 100 instead of unlimited, You will recieve the message |__God Deactivated__|

And if your not admin you will get You are not allowed to use this command!
pawn Code:
CMD:godcar(playerid, params[])
{
    if(PlayerInfo[playerid][pAdminLevel] >= 3)
    {
        if(IsPlayerInAnyVehicle(playerid))
            {
            SetVehicleHealth(playerid, 999999);
            SendClientMessage(playerid,COLOR_GREEN,"|__GodCar Activated__|");
    }
        else
    {
        SendClientMessage(playerid, COLOR_RED, "You are not allowed to use this command!");
    }
        SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle to use this command!");
    }
    return 1;
}
This is exactly like /God but it makes your vehicle God. If your not in a vehicle you will see the message
You are not allowed to use this command!" And if you are not admin you will see You are not allowed to use this command.
Then you will need a way to turn that off so,

pawn Code:
CMD:godcaroff(playerid, params[])
{
    if(PlayerInfo[playerid][pAdminLevel] >= 3)
    {
        if(IsPlayerInAnyVehicle(playerid))
            {
            SetVehicleHealth(playerid, 1000);
            SendClientMessage(playerid,COLOR_GREEN,"|__GodCar DeActivated__|");
    }
        else
    {
        SendClientMessage(playerid, COLOR_RED, "You are not allowed to use this command!");
    }
        SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle to use this command!");
    }
    return 1;
}
This is Exactly like /Godoff except it returns your car health to 1000. If your not in a vehicle you will see the message You are not allowed to use this command!" And if you are not admin you will see You are not allowed to use this command.

Thats pretty much the tutorial, it could have been better, but i by accidently click Save Changes before i was done posting so i had to rush it. Thank you guys
Reply
#2

good job
Reply
#3

"This makes your health go to unlimited, it will send you a message saying |__God Activated__|"

That is not unlimited, and you can be easily killed with a minigun.
Reply
#4

Quote:
Originally Posted by linuxthefish
View Post
"This makes your health go to unlimited, it will send you a message saying |__God Activated__|"

That is not unlimited, and you can be easily killed with a minigun.
Your wrong, SetPlayerHealth(playerid,100000); is god.
Reply
#5

What? All you did is "copy paste this". Be more specific next time.
Reply
#6

Quote:
Originally Posted by Shockey HD
View Post
Your wrong, SetPlayerHealth(playerid,100000); is god.
100000 is not god, most people believe you have unlimited health because the HP bar flashes, this is a common misconception.

If you see, in the weapons.dat file in your GTA:SA data directory, you will notice the mini-gun inflicts 140HP of damage per shot. At a rate of I-have-no-idea-but-it's-fast, 100000HP will be gone in next to no time.

Infinity is good.
Reply
#7

for god i recommand using a timer you get 100000 health every second so you will never die
Reply
#8

Hello,

I cannot script really great and I really want to know this:

Quote:

CMD:ban(playerid, params[])

Whats params? Whats Playerid? Whats CMD

Quote:

new id, reason[50], string[128], banned[MAX_PLAYER_NAME];

What does this mean? There's [50], [128], [MAX_PLAYER_NAME], are they suppose to be values?

Quote:

if(PlayerInfo[playerid][pAdminLevel] >= 5 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not allowed to use this command!");

I get a error, it says I haven't got pAdminLevel defined

Quote:

if(sscanf(params, "uz", id, reason)) return SendClientMessage(playerid, -1, "USAGE: /ban [ID] [Reason]");

What is this? sscanf "uz" id and reason

Quote:

if(playerid == id) return SendClientMessage(playerid,COLOR_RED, "You cannot kick yourself");

Whats ID and playerid? I don't get it.

Quote:

GetPlayerName(id, banned, sizeof(banned));
format(string, sizeof(string), "AdmCmd: %s has been banned by %s. reason: %s", banned, GetName(playerid), reason);
SendClientMessageToAll(COLOR_RED, string);
BanEx(id, reason);

Whats GetPlayerName, there's many stuff like 'sizeof'

Whats format?

whats SendClientMessageToAll?

Whats BanEx? What will it exactly do to the values


It's not a god damn tutorial!
Reply
#9

Quote:
Originally Posted by Lorenc_
View Post
Hello,

I cannot script really great and I really want to know this:



Whats params? Whats Playerid? Whats CMD



What does this mean? There's [50], [128], [MAX_PLAYER_NAME], are they suppose to be values?



I get a error, it says I haven't got pAdminLevel defined



What is this? sscanf "uz" id and reason



Whats ID and playerid? I don't get it.



Whats GetPlayerName, there's many stuff like 'sizeof'

Whats format?

whats SendClientMessageToAll?

Whats BanEx? What will it exactly do to the values


It's not a god damn tutorial!
Yes i Agree, When making a [TUT] you should first explain all that stuff, that "Lorenc_" kindly pointed out an what it actually does!
so then people have a little understanding on how it all works, anybody can CTRL+C an CTRL+V.

And also,
pawn Code:
else if(playerid == INVALID_PLAYER_ID) SendClientMessage(playerid,COLOR_RED,"System: Invalid ID");// like wtf, when will this ever happen?, your the playerid an your sending the cmd, how can it be invalid? and "else if" what for??
correct me if i am wrong please as i use standard string compare still...
Reply
#10

Quote:
Originally Posted by Lorenc_
View Post
Whats params? Whats Playerid? Whats CMD
How the heck did you get that emoticon?

Anyhow, bad tutorial. It's just copy this, paste that and hope it works.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)