02.08.2011, 17:25
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.
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:
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!
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!
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, 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.
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
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